---
title: "charset · Meta Tag · zhead"
canonical_url: "https://zhead.dev/meta/charset"
last_updated: "2026-08-19T02:35:56.729Z"
meta:
  description: "Declares the character encoding used by the HTML document. In modern HTML, the value must be UTF-8."
  "og:description": "Declares the character encoding used by the HTML document. In modern HTML, the value must be UTF-8."
  "og:title": "charset · Meta Tag · zhead"
---

Meta tags

# charset

Declares the character encoding used by the HTML document. In modern HTML, the value must be UTF-8.

## Code examples

Good example

```
<meta charset="utf-8">
```

The required character encoding for modern HTML.

Avoid this example

```
<meta charset="iso-8859-1">
```

The charset attribute does not allow legacy encodings in a conforming HTML document.

Avoid this example

```
<meta charset="utf-16">
```

UTF-16 is not a valid value for the HTML charset attribute.

Avoid this example

```
<meta charset="">
```

An empty value does not declare an encoding.

## Recommendations

- 01 Use UTF-8 UTF-8 is the only conforming value for the charset attribute in an HTML document.
- 02 Declare Early Put the complete declaration within the first 1024 bytes of the document so the browser can determine the encoding before parsing much of the page.
- 03 Keep Declarations Consistent Serve the document as UTF-8 too. Do not combine a charset tag with the older content-type pragma.

## Related documentation

- [HTML Living Standard: Semantics](https://html.spec.whatwg.org/multipage/semantics.html#attr-meta-charset)
- [W3C: Qa Html Encoding Declarations.En](https://www.w3.org/International/questions/qa-html-encoding-declarations.en)

## Related meta tags

### [charset](https://zhead.dev/meta/charset)

charset

Declares the character encoding used by the HTML document. In modern HTML, the value must be UTF-8.

```
<meta charset="utf-8">
```

The required character encoding for modern HTML.