--- title: "" category: foundations status: required url: https://webspecification.com/spec/foundations/meta-charset/ updated: "2026-05-29T09:13:20.000Z" sources: - title: "HTML Living Standard — Specifying the document's character encoding" url: "https://html.spec.whatwg.org/multipage/semantics.html#charset" publisher: "WHATWG" - title: "MDN — : charset" url: "https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/meta#charset" publisher: "MDN" - title: "WHATWG Encoding Standard" url: "https://encoding.spec.whatwg.org/" publisher: "WHATWG" source_repo: undefined licence: CC-BY-4.0 --- # > Declare UTF-8 as the document character encoding in the first 1024 bytes of the HTML, so browsers parse text correctly before they hit any non-ASCII content. ## What it is `` tells the browser how to decode the bytes of the HTML document into characters. In 2026 there is only one correct value: ```html ``` It must appear inside `
`, and the entire `` element must fit within the **first 1024 bytes** of the response. Browsers stop sniffing after that point; anything declared later is ignored. ## Why it matters Before the browser can parse a single character of your page, it has to decide which encoding to apply to the byte stream. Without an explicit declaration, it guesses — based on the `Content-Type` HTTP header, a byte-order mark, or heuristics over the first chunk of bytes. Guessing goes wrong: - A page with a curly apostrophe (`'`) shows mojibake (`’`) when the browser picks Windows-1252. - Form submissions get encoded in the wrong charset, corrupting non-ASCII input. - Right-to-left text reorders incorrectly. - Search engines index garbled strings. **UTF-8 is the only encoding you should use.** It is a superset of ASCII, supports every script (Latin, Cyrillic, Arabic, Chinese, emoji), is the default for JSON and XML, and is what every modern build tool produces. Legacy encodings (`iso-8859-1`, `windows-1252`, `shift_jis`) exist only as compatibility for old documents — do not create new content in them. ## How to implement Put the charset declaration as the very first child of ``, before `