HTML Character Sets
A character set maps bytes to characters. UTF-8 is the modern default and the only one you should be picking today.
Why UTF-8 won
| Property | Why it matters |
|---|---|
| Covers every Unicode character | Every language, every symbol, every emoji works on one page. |
| Backwards compatible with ASCII | Plain English text is the same bytes either way. |
| Variable-width | ASCII characters are 1 byte; rare characters take 2–4 bytes. Small files for English; full coverage for everything else. |
| Universal | The web, JSON, modern programming languages, databases, and operating systems all default to UTF-8. |
Common charsets and what they cover
| Charset | Covers |
|---|---|
| UTF-8 | All Unicode (over 150,000 characters). |
| UTF-16 | Same coverage; uses 2 or 4 bytes per character. |
| ISO-8859-1 (Latin-1) | Western European Latin alphabets. |
| ISO-8859-5 | Cyrillic. |
| Windows-1252 | Latin-1 with extra punctuation. |
| Shift_JIS | Japanese. |
| GB2312 / GBK | Simplified Chinese. |
| Big5 | Traditional Chinese. |
| ASCII | Basic English only (128 characters). |
Use UTF-8. Declare it with
<meta charset="UTF-8"> as the first line of <head>, and make sure your editor saves the file with that encoding.Example
Example
<!DOCTYPE html>
<html>
<head>
<title>HTML Character Sets</title>
</head>
<body>
<h1>HTML Character Sets</h1>
<p>This is a demo page for the "HTML Character Sets" lesson.</p>
</body>
</html>
Try it Yourself »
Exercise
Which character set covers virtually every written language?
Three letters and a digit.
Discussion
Loading…