Meta tags

charset

Declares the character encoding used by the HTML document. In modern HTML, the value must be UTF-8.

Code examples

Good example
<meta charset="utf-8">
The required character encoding for modern HTML.
Avoid this example
<meta charset="iso-8859-1">
The charset attribute does not allow legacy encodings in a conforming HTML document.
Avoid this example
<meta charset="utf-16">
UTF-16 is not a valid value for the HTML charset attribute.
Avoid this example
<meta charset="">
An empty value does not declare an encoding.

Recommendations

  • 01
    Use UTF-8
    UTF-8 is the only conforming value for the charset attribute in an HTML document.
  • 02
    Declare Early
    Put the complete declaration within the first 1024 bytes of the document so the browser can determine the encoding before parsing much of the page.
  • 03
    Keep Declarations Consistent
    Serve the document as UTF-8 too. Do not combine a charset tag with the older content-type pragma.

Related documentation

Related meta tags

charset

charset

Declares the character encoding used by the HTML document. In modern HTML, the value must be UTF-8.

<meta charset="utf-8">
The required character encoding for modern HTML.