HTML Meta Charset Tag Guide | Generated by AI

Home 2025.11

The <meta charset="..."> tag is the modern and recommended way to tell the browser which character encoding (character set) your HTML document uses. Almost all modern websites use UTF-8, so this is what you’ll see 99% of the time.

Correct placement and syntax (HTML5)

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>My Page</title>
</head>
<body>
    ...
</body>
</html>

Key rules you must follow

  1. It must be within the first 1024 bytes of the HTML file.
    → Put it as one of the very first lines in <head> (right after the opening <head> tag is safest).

  2. Use exactly this simple syntax in HTML5:
    <meta charset="UTF-8">
    

    No closing slash needed, no content attribute, no complicated stuff.

  3. Always use UTF-8 in 2025+
    Unless you have a very specific legacy reason, just use:
    <meta charset="UTF-8">
    

    UTF-8 handles English, European languages, Arabic, Chinese, Japanese, emojis, everything.

Old/obsolete ways (you’ll still see them in old code)

<!-- HTML 4.01 way (obsolete) -->
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

<!-- Sometimes people write the long version even in HTML5 (works, but unnecessary) -->
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

These older versions still work, but the short <meta charset="UTF-8"> is cleaner, faster for the browser to parse, and the official HTML5 standard.

What happens if you forget it?

One-line summary

Always put this as the first or second line in your <head>:

<meta charset="UTF-8">

That’s it — you’re good for virtually every language and symbol in the world.


Back

x-ai/grok-4.1-fast

Donate