This page is Ready to Use

Notice: The WebPlatform project, supported by various stewards between 2012 and 2015, has been discontinued. This site is now available on github.

charset

Summary

The charset attribute is used to declare the character encoding of the document.

Applies to [HTMLMetaElement](/dom/HTMLMetaElement)
The character encoding declaration must be fit within the first 1024 bytes of an HTML file, hence should be the first child in the the head element. Only one such declaration is allowed within a document.

Note that BOM and declaration in the HTTP header take precedence over in-document declaration.

It’s good practice to declare the character encoding inside the document for situations when the document will be used locally with no HTTP header involved, and as a visual cue in the source code.

Examples

<meta charset="utf-8"/>

Related specifications

HTML Document Representation
W3C Recommendation