In short. UTF-8 declarations identify an encoding, while correct decoding also requires matching file bytes and server metadata.
Definition: UTF-8 encoding is a way to represent Unicode text as bytes for storage and transmission. An encoding declaration identifies how software should decode those bytes back into text.
Key facts
- The WHATWG Encoding Standard requires authors to use UTF-8 and identify it with the case-insensitive label
utf-8. - The WHATWG HTML Standard requires an HTML meta encoding declaration to fit completely within the first 1024 bytes of the document.
- W3C's conversion guidance requires saving or converting the data to UTF-8 as well as changing its declaration.
- W3C's encoding introduction explains that missing encoding information can impair readability, search engine processing and other machine processing.
How does an HTML page declare UTF-8?
The HTML Standard's meta element rules define charset as the attribute identifying the document's character encoding. Its value must match utf-8 without regard to letter case, and a document can contain only one meta-based encoding declaration.
W3C's conversion example places the declaration at the beginning of the HTML head element:
<meta charset="utf-8">
The same guidance explains that a server can send a conflicting encoding in an HTTP header, the response metadata accompanying the page. The Content-Type header is therefore part of the encoding check even when the HTML declaration is correct.
A byte order mark, or BOM, is an encoding signature at the beginning of a byte stream. The HTML parsing rules give a leading BOM precedence over the supplied encoding and skip the mark itself. The encoding selection algorithm checks supported transport-layer encoding information before scanning the HTML for a declaration.
What causes decoding failures?
An encoding maps bytes to characters. W3C's encoding introduction explains that incorrect encoding information makes software look up the wrong characters. It also distinguishes this problem from missing font glyphs: a font supplies the shapes used to display characters after decoding.
Malformed input is another failure. The Encoding Standard's decoder rules define replacement and fatal error modes. Replacement mode emits the replacement character U+FFFD (�) for a decoding error. The standard's TextDecoder JavaScript interface throws a TypeError when its decoder encounters an error in fatal mode.
For a response body held in a byte array named bytes, this expression checks decoding in fatal mode:
new TextDecoder("utf-8", { fatal: true }).decode(bytes);
The HTML parsing specification also identifies invalid UTF-8 byte sequences as errors that conformance checkers are expected to report.
How can a website's encoding be checked?
W3C's conversion procedure starts with the saved data. For hand-edited files, the editor must save UTF-8 bytes. For pages built from scripts and databases, conversion and scripting settings must produce the intended encoding.
The procedure then checks the page declaration and the server response. Its Internationalization Checker displays an HTTP Content-Type row under Character Encoding, where the expected result is UTF-8 or No encoding information found. A different server declaration requires correction because it takes precedence over encoding information inside the page.
Related terms
FAQ
Does adding a meta charset declaration convert my file?
You must also save or convert the bytes. W3C's conversion guidance explicitly requires the data itself to be encoded in UTF-8.
Is an encoding declaration needed for an English-only page?
The HTML Standard requires a declaration even when all characters are in the ASCII range. It names form input and script-generated URLs as reasons the document still needs an encoding.
Does a square box always indicate an encoding error?
W3C's font explanation describes square boxes and question marks as possible results of missing glyphs. You can check font coverage as well as the encoding.
Sources
- WHATWG, "Encoding Standard", updated 21 May 2026
- WHATWG, "HTML Standard: Document metadata", accessed 17 October 2026
- WHATWG, "HTML Standard: Parsing HTML documents", accessed 17 October 2026
- W3C, "Changing an HTML page to Unicode", accessed 17 October 2026
- W3C, "Character encodings for beginners", accessed 17 October 2026
Check how a page reads to answer engines. Open the GEO score analyzer