D DevBrainBox

HTML5 Meta Charset & Encoding

HTML

What is character encoding?

Character encoding tells the browser how to interpret the bytes in your HTML file and turn them into readable characters (letters, symbols, etc.). For example, should the byte 0x61 be shown as a? Or something else?

Without proper encoding, special characters (like special characters é, ü, , , ) might show up as weird symbols or question marks .

The HTML5 meta charset

In HTML5, we specify the character encoding using this meta tag inside <head>:

<meta charset="UTF-8">

Why use UTF-8?

Supports many languages at once. Handles special symbols, currency signs, emojis. Widely supported by browsers and servers. That’s why it’s the standard encoding for the modern web.

In HTML4 meta charset

you often saw a longer meta tag:

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

Where does it go?

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>My UTF-8 Page</title>
</head>
<body>
    <p>Symbols: €, ₹, ✓, 你好, مرحبا</p>
</body>
</html>

On this page