# Internal encoding declaration X disagrees with the actual encoding of the document (“utf-8”).

> Canonical HTML version: https://rocketvalidator.com/html-validation/internal-encoding-declaration-x-disagrees-with-the-actual-encoding-of-the-document-utf-8
> Attribution: Rocket Validator (https://rocketvalidator.com)
> License: CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/)

A `<meta>` element declares a legacy encoding such as `iso-8859-1`, but the document is actually read as UTF-8.

A browser picks a page's character encoding by checking several sources in a fixed order. A byte order mark at the very start of the file wins, then the `charset` parameter of the HTTP `Content-Type` header, and only after those the `<meta charset>` or `<meta http-equiv="Content-Type">` declaration inside the page. When the server sends `Content-Type: text/html; charset=utf-8`, the browser reads the page as UTF-8 and ignores the `<meta>` element. The validator reports the mismatch because the markup and the server say different things.

This usually comes from an old template or CMS theme that still carries `charset=iso-8859-1` after the server and the files moved to UTF-8. The page may look fine today, but the declaration takes over whenever the header is missing, for example when the file is opened from disk or moved to a server that doesn't send a charset. The browser then decodes the UTF-8 bytes with the declared encoding, and an `é` turns into `Ã©`.

HTML only allows UTF-8, so the fix is to declare `utf-8`. The shorter `<meta charset="utf-8">` is equivalent to the `http-equiv` form. Put it first inside `<head>` so it falls within the first 1024 bytes of the document. The same change clears the related errors the validator reports about the `charset` value.

If accented characters on the page already show up as `�`, the file itself is saved in the legacy encoding while the server announces UTF-8. Re-save the file as UTF-8 in your editor before changing the declaration.

## Invalid example

On a page served as UTF-8:

```html
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
  <title>Café menu</title>
</head>
```

## Valid example

```html
<head>
  <meta charset="utf-8">
  <title>Café menu</title>
</head>
```
