CKTIS / HTML
charset: declare UTF-8 early
Make the declared encoding agree with the actual bytes and the HTTP response.
Version: HTML Living Standard
Syntax
<meta charset="utf-8">On a metadata element, charset declares the HTML document’s character encoding. Modern conforming markup uses utf-8; place the entire declaration within the first 1024 bytes, normally near the start of the head. Use at most one such metadata declaration and save the file with the encoding it declares. Merely changing the label cannot repair incorrectly encoded bytes.
The browser also considers a byte-order mark and transport metadata such as the HTTP Content-Type charset. A conflicting server declaration can change how bytes are decoded, so configure both the server and document consistently. This attribute does not choose the page language, translate text, or provide the encoding declaration for an XML document.
The fixture sends actual UTF-8 bytes without a byte-order mark and without an HTTP charset. The browser reads the early declaration and preserves accented letters and an emoji. The script exposes the resulting document encoding and text, making decoding errors visible rather than only checking the attribute string.
Examples
<!doctype html><meta charset="utf-8">
<p id="word">Zażółć 🙂</p><output id="result"></output><script>
document.querySelector('#result').textContent = document.characterSet + '; ' + document.querySelector('#word').textContent;
</script>Result
UTF-8; Zażółć 🙂
The HTTP fixture intentionally omits a charset so this test genuinely exercises the early HTML declaration.