Early Access

Meta Tags

charset

Learn how to use the charset meta tag to improve your site.

Defines the character encoding standard for the HTML document. Character encoding is essential for rendering text correctly in browsers.

Code Examples

<meta charset="charset" content="UTF-8" />
Declares UTF-8 as the character encoding for the HTML document, supporting most characters and symbols in use today.
<meta charset="charset" content="ISO-8859-1" />
Defines ISO-8859-1 (Latin-1) as the character encoding, suitable for documents with Western European content.
<meta charset="charset" content="UTF-16" />
While UTF-16 supports most characters like UTF-8, it is less common and may lead to compatibility issues with older browsers or third-party tools.
<meta charset="charset" content="" />
Omitting the charset attribute or providing an invalid value can lead to incorrect text rendering or garbled characters.

Recommendations

  • Prefer Unicode (UTF-8)
    UTF-8 is the most universally accepted encoding, supporting all characters from all scripts. It ensures maximum compatibility and accessibility worldwide.
  • Declare Early
    Place the charset declaration as early as possible within the <head> tag. This speeds up rendering and prevents potential security issues with incorrectly interpreted characters.
  • Encoding Conflict Avoidance
    Ensure that your server’s HTTP response header and the charset meta tag in the HTML document match. Mismatched declarations can lead to rendering issues or security vulnerabilities.

Related Documentation

Related Meta Tags

charset

charset

Defines the character encoding standard for the HTML document. Character encoding is essential for rendering text correctly in browsers.

<meta charset="charset" content="UTF-8">
Declares UTF-8 as the character encoding for the HTML document, supporting most characters and symbols in use today.