DocsContentLanguage and encoding
Language and encoding
Declared language and charset, so text is interpreted correctly.
Why an agent cares
An undeclared or late charset makes an agent guess, and a wrong guess corrupts every non-ASCII character it reads. A malformed lang tag is a smaller problem but the same kind: the declaration is there and cannot be used.
Adoption
Web baseline. Standard equipment on the web. Its absence is the exception rather than its presence.
Direction of travel: ► flat, as at .
BCP 47 and UTF-8 are near-universal; UTF-8 is on roughly 98% of pages (W3Techs).
What we check
| Check | Severity | Raises | On whose authority |
|---|---|---|---|
| Charset Missing | high | conformance, usability | specification: WHATWG HTML — the lang attribute |
Supporting documents: WHATWG HTML — the lang attribute Required by WHATWG HTML — the lang attribute. Bad: neither the HTTP Content-Type header nor an in-page <meta charset> declares the encoding, so agents may decode the bytes wrongly and garble the text. Fix: declare UTF-8, ideally in the header: Content-Type: text/html; charset=utf-8. | |||
| Lang Missing | medium | usability | specification: WHATWG HTML — the lang attribute |
Supporting documents: WHATWG HTML — the lang attribute Related guidance in WHATWG HTML — the lang attribute. Bad: <html> has no lang attribute, so agents and translators must guess the page language and can guess wrong. Fix: declare it on the root element, e.g. <html lang="en">. | |||
| Lang Invalid BCP 47 | medium | usability | Lumar readiness bar, beyond BCP 47 — Tags for Identifying Languages |
Supporting documents: BCP 47 — Tags for Identifying Languages Lumar readiness bar: no specification requires this. Bad: the lang value isn't a usable BCP 47 tag (a name like "english", or an underscore form like "en_US"), so consumers ignore it. Fix: use a valid tag such as "en" or "en-US" (hyphen, not underscore). | |||
| Charset Non-UTF-8 | medium | conformance, usability | specification: WHATWG HTML — the lang attribute |
Supporting documents: WHATWG HTML — the lang attribute Required by WHATWG HTML — the lang attribute. Bad: the page's effective encoding isn't UTF-8, which HTML requires of every document and which modern agents assume, so characters can arrive corrupted in anything that reads it. Fix: re-save the page as UTF-8 and declare it, either as Content-Type: text/html; charset=utf-8 or as <meta charset="utf-8"> — the Charset Declaration Source column says which one to change. | |||
| Charset Late | medium | conformance, usability | specification: WHATWG HTML — the lang attribute |
Supporting documents: WHATWG HTML — the lang attribute Required by WHATWG HTML — the lang attribute. Bad: the charset <meta> ends after the first 1024 bytes of the document, past where parsers pre-scan, so it may be ignored. Fix: put <meta charset="utf-8"> first in <head>, or declare the charset in the Content-Type header. | |||
Examples
Both run through the same checks as a live scan: the first passes, the second is flagged.
<html lang="en">
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>How agent-readiness works — Example</title>
<link rel="canonical" href="https://example.com/content/correct.html" /><html lang="english">
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>How agent-readiness works — Example</title>
<meta name="description" content="aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" />
<meta charset="ISO-8859-1" />Specifications
| Document | Revision | Kind |
|---|---|---|
| BCP 47 — Tags for Identifying Languages | Current best practice | specification |
| WHATWG HTML — the lang attribute | Living Standard | specification |
| WHATWG Encoding Standard | Living Standard | specification |
| WHATWG HTML — meta charset (within the first 1024 bytes) | Living Standard | specification |
Last re-read against the published documents: .