Example 1 — UTF-8 meta Tag
<head>
<meta charset="UTF-8">
<title>UTF-8 page</title>
</head> How It Works
One line in head tells every browser to decode the page as UTF-8.

Character encoding tells the browser how to turn the bytes in your HTML file into readable text. Without the correct charset, accented letters, symbols, and non-English scripts can display as gibberish.
This tutorial explains what charset means, why UTF-8 is the web standard, how to declare it with <meta charset>, and how different encodings compare.
Encoding.
Standard.
Declare it.
Compare.
Multilingual.
Mojibake.
HTML charset refers to the character encoding used to interpret and display text in an HTML document. It defines how numeric byte values map to characters you see on screen.
The most widely used charset today is UTF-8 (Unicode Transformation Format, 8-bit). It supports virtually all writing systems, is backward-compatible with ASCII, and is the recommended default for every new HTML page.
To declare charset, use the <meta> tag in <head>:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>HTML Document</title>
</head>
<body>
<!-- Content of the HTML document -->
</body>
</html> The browser reads charset="UTF-8" and decodes the file accordingly. The charset in your HTML must match how the file is saved in your editor—both should be UTF-8.
Place <meta charset="UTF-8"> within the first 1024 bytes of the document (ideally right after <head>) so the browser detects encoding before parsing body text.
Several character encodings exist. Here are the ones you are most likely to encounter:
Recommendation: Use UTF-8 for all new HTML documents unless you have a specific legacy requirement.
The table below shows how the same numeric code points appear in different encodings. For basic ASCII range (0–127), ASCII, Latin-1, and UTF-8 agree. Extended characters differ—UTF-8 handles all of them.
| Code | ASCII | Windows-1252 | ISO-8859-1 | UTF-8 | Description |
|---|---|---|---|---|---|
| 32 | (space) | (space) | (space) | (space) | space |
| 65 | A | A | A | A | Latin capital letter A |
| 97 | a | a | a | a | Latin small letter a |
| 128 | — | € | — | — | euro sign (Windows-1252 only) |
| 169 | — | © | © | © | copyright sign |
| 233 | — | é | é | é | Latin small letter e with acute |
| 241 | — | ñ | ñ | ñ | Latin small letter n with tilde |
| 8364 | — | — | — | € | euro (Unicode code point in UTF-8) |
| 12354 | — | — | — | あ | Hiragana letter a (UTF-8 only) |
| 127757 | — | — | — | 🌍 | globe emoji (UTF-8 only) |
ASCII and ISO-8859-1 cannot represent emoji or most non-Latin scripts. UTF-8 encodes the full Unicode range using one to four bytes per character.
When charset declaration and file encoding disagree, you see mojibake—broken characters like é instead of é, or 🌠instead of emoji.
<meta charset="UTF-8"> in <head>.Content-Type: text/html; charset=utf-8 (most servers do by default for .html).| Task | Code / action |
|---|---|
| Declare UTF-8 (HTML5) | <meta charset="UTF-8"> |
| Legacy HTML4 form | <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> |
| Recommended encoding | UTF-8 |
| Save file in editor | UTF-8 (not ANSI / Windows-1252) |
| Pair with language | <html lang="en"> — see Language Code |
| Special characters in HTML | UTF-8 directly or HTML entities |
Six examples showing UTF-8 in action. Each includes View Output and Try It Yourself.
<head>
<meta charset="UTF-8">
<title>UTF-8 page</title>
</head> One line in head tells every browser to decode the page as UTF-8.
<h1>Café & naïve</h1>
<p>El niño comió jalapeños. Ça va bien!</p> UTF-8 encodes accented Latin letters. Without UTF-8, these often appear as question marks or mojibake.
<h1>Hello 🌍</h1>
<p>Price: €19 · Rating: ★★★★☆ · Check ✓</p> Emoji and symbols like € require UTF-8 (or entities). ASCII alone cannot represent them.
<head>
<meta charset="UTF-8">
</head>
<body>
<h1>Multilingual UTF-8</h1>
<p>English: Hello</p>
<p>Japanese: こんにちは</p>
<p>Arabic: مرحبا</p>
<p>Hindi: नमस्ते</p>
</body> One UTF-8 page can mix scripts. Pair with lang attributes for accessibility (see Language Code).
<head>
<meta charset="UTF-8">
</head>
<body>
<h1>Entities & UTF-8</h1>
<p>Copyright: © 2026</p>
<p>Less than: <tag></p>
<p>Numeric ref: é = é</p>
</body> With UTF-8 you can type characters directly. Entities remain useful for <, &, and legacy workflows. See HTML Entities.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Global Website</title>
</head>
<body>
<header><h1>Welcome / Bienvenue / 欢迎</h1></header>
<main>
<p>UTF-8 lets one page display text from many languages.</p>
</main>
</body>
</html> Combines meta charset, viewport, and international content—the pattern every global site should follow.
<meta charset="UTF-8"> on every page<head>lang on <html>All modern browsers support UTF-8 when declared with meta charset. UTF-8 has been the dominant web encoding for over a decade.
All modern browsers support UTF-8 when declared with meta charset. UTF-8 has been the dominant web encoding for over a decade.
Bottom line: UTF-8 is safe everywhere. No fallback encoding needed for new sites.
HTML charset defines how browsers interpret your text. UTF-8 is the clear standard: declare it with <meta charset="UTF-8">, save files as UTF-8, and your pages will display any language or emoji correctly.
For attribute-level details, see the charset attribute reference. Next, learn how to build data tables with HTML Table.
Use always.
StandardIn head.
DeclareUTF-8 file.
EditorAll scripts.
GlobalNo mojibake.
FixOver 98% of web pages use UTF-8. The W3C recommends UTF-8 as the default encoding for HTML. Before UTF-8 dominated, sites often maintained separate encodings per language—UTF-8 eliminated that complexity by supporting all Unicode in one format.
Add accented text and emoji, set meta charset, and confirm everything renders correctly.
6 people found this page helpful