missing-charset

⌘K
  1. Home
  2. SiteLint
  3. Quality Rules
  4. missing-charset

missing-charset

Print this article

Description

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

Was this article helpful to you? No Yes

How can we help?