Lesson 72 +5 XP

HTML Character Set Reference

HTML Character Set Reference

A character set (charset) is the "alphabet" a browser uses to turn numbers into characters. Picking the right one makes every letter and emoji show up correctly.

The one you need: UTF-8

UTF-8 is the modern standard. It handles every language and every emoji. Always use it:

<meta charset="UTF-8">

Put it inside <head>, as early as possible.

Common character sets

CharsetWhat it isStill used?
UTF-8All Unicode characters, web standardYes: use this!
ASCII128 characters: letters, numbers, symbolsLegacy
ISO-8859-1Latin-1: Western EuropeanLegacy (was common)
Windows-1252ANSI: Western European + extrasLegacy
UTF-16Unicode, 2 bytes per characterRare on the web
GB2312 / GBKChineseSome regions
Shift_JISJapaneseSome regions
EUC-KRKoreanSome regions

The history in one breath

  1. ASCII came first: 128 characters. No accents, no emojis.
  2. ANSI (Windows-1252) added European characters.
  3. Different regions got their own sets (Chinese, Japanese, Korean).
  4. Unicode arrived with a code for EVERY character in the world.
  5. UTF-8 is how Unicode is stored on the web. Winner!

What happens without a charset?

The browser has to guess. Guesses can be wrong, and you'll see gibberish like é instead of é. Setting <meta charset="UTF-8"> prevents this.

The UTF-8 character ranges

Unicode groups characters into ranges. A few famous ones:

RangeCharacters
U+0000 - U+007FASCII (basic Latin)
U+0080 - U+024FLatin (accents: é, ñ, ü)
U+0370 - U+03FFGreek (α, β, π)
U+0400 - U+04FFCyrillic (Russian, etc.)
U+0600 - U+06FFArabic
U+3040 - U+30FFJapanese Hiragana and Katakana
U+4E00 - U+9FFFCJK Unified Ideographs (Chinese)
U+1F600 - U+1F64FEmoticons (emojis)
U+2190 - U+21FFArrows

You don't need to memorize these. They just show you how Unicode organizes the world's characters.

Entities are part of the story

When a character is hard to type (or has a special meaning), use an HTML entity:

&lt;   &gt;   &amp;   &nbsp;   &copy;

Entities start with & and end with ;. See the HTML Entity Reference lesson for the full list!

TL;DR

  • Always use <meta charset="UTF-8"> in the head.
  • UTF-8 covers every language and emoji.
  • Old charsets (ASCII, ANSI, ISO-8859-1) can't show everything.
  • Without a charset, characters can look like gibberish.
  • Use entities for special characters that are hard to type.