What HTML attribute specifies the character encoding for a web page?

The story behind the answer

The HTML attribute that specifies a web page’s character encoding is `charset`.

It is most familiar in the document head as `<meta charset="UTF-8">`. This declaration tells the browser how to interpret the page’s bytes as text, helping characters such as accented letters, mathematical symbols, and scripts from around the world display correctly. In modern HTML, UTF-8 is the standard encoding and the only encoding permitted for a `meta` charset declaration.

The declaration should appear near the beginning of the document: HTML requires a character-encoding `<meta>` element to be entirely within the first 1,024 bytes. That allows browsers to discover the encoding before they process much of the page.

`charset` is often confused with `lang`. The `lang` attribute identifies the human language, such as English or Hindi; it does not describe how bytes are encoded. `Content-Type` is also important, but it is an HTTP response header rather than an HTML attribute. Older HTML commonly used a longer `http-equiv` form, while HTML5 introduced the concise syntax.

Source: Wikipedia · fact-checked Aug. 2026

Add question to a list

Choose a list to keep this question in: