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
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4