Missing charset declaration or it is not defined in the first 1024 bytes of the HTML
Description
Rule ID: missing-charset
This rule determines if the charset is set for HTML and if it’s defined within the first 1024 bytes of the HTML.
Why is the charset rule so important for HTML files?
The charset
rule is important for HTML files because it ensures that the document is encoded correctly and can be displayed correctly in different browsers and devices. By specifying the charset, you are telling the browser which character set to use when rendering the document, which helps to prevent display issues and ensure that special characters are represented correctly.
Always declare the encoding of your document using a meta element with a charset
attribute or using the http-equiv
and content
attributes (called a pragma directive). The declaration should fit completely within the first 1024 bytes at the start of the file, so it’s best to put it immediately after the opening <head>
tag.
How to fix it
- Define
<meta charset="utf-8"/>
or<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
within the first 1024 bytes at the start of the file. Ideally, immediately after the opening<head>
tag
Standard
SiteLint, Quality, Best Practice