# Bad value “text/html; charset=windows-1252” for attribute “content” on element “meta”: “charset=” must be followed by “utf-8”.

> Canonical HTML version: https://rocketvalidator.com/html-validation/bad-value-text-html-charset-windows-1252-for-attribute-content-on-element-meta-charset-must-be-followed-by-utf-8
> Attribution: Rocket Validator (https://rocketvalidator.com)
> License: CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/)

The HTML specification mandates that documents must be encoded in UTF-8. This requirement exists because UTF-8 is the universal character encoding that supports virtually every character from every writing system in the world. Older encodings like `windows-1252`, `iso-8859-1`, or `shift_jis` only support a limited subset of characters and can cause text to display incorrectly — showing garbled characters or question marks — especially for users in different locales or when content includes special symbols, accented letters, or emoji.

When the validator encounters `charset=windows-1252` in your `<meta>` tag, it flags this as an error because the HTML living standard (WHATWG) explicitly states that the character encoding declaration must specify `utf-8` as the encoding. This isn't just a stylistic preference — browsers and other tools rely on this declaration to correctly interpret the bytes in your document. Using a non-UTF-8 encoding can lead to security vulnerabilities (such as encoding-based XSS attacks) and accessibility issues when assistive technologies misinterpret characters.

To fix this issue, take two steps:

1. **Update the `<meta>` tag** to declare `utf-8` as the charset.
2. **Re-save your file** with UTF-8 encoding. Most modern code editors (VS Code, Sublime Text, etc.) let you choose the encoding when saving — look for an option like "Save with Encoding" or check the status bar for the current encoding. If your file was originally in `windows-1252`, simply changing the `<meta>` tag without re-encoding the file could cause existing special characters to display incorrectly.

The HTML spec also recommends using the shorter `<meta charset="utf-8">` form rather than the longer `<meta http-equiv="Content-Type" ...>` pragma directive, as it's simpler and achieves the same result. Either form is valid, but the charset declaration must appear within the first 1024 bytes of the document.

## Examples

### Incorrect: Using `windows-1252` charset

```html
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
```

This triggers the validator error because the charset is not `utf-8`.

### Correct: Using the short `charset` declaration (recommended)

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

### Correct: Using the `http-equiv` pragma directive with `utf-8`

```html
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
```

### Full document example

```html
<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <title>My Page</title>
  </head>
  <body>
    <p>Hello, world!</p>
  </body>
</html>
```

Note that the `<meta charset="utf-8">` tag should be the first element inside `<head>`, before any other elements (including `<title>`), so the browser knows the encoding before it starts parsing the rest of the document.
