HTML Basics
HTML Charsets
A character set (charset) defines how bytes are turned into the letters and symbols you see. Declaring the right one prevents strange, garbled characters.
What is a Character Set?
Computers store text as numbers. A character set is the map that connects each number to a specific character. If the browser guesses the wrong map, you get broken text like ' instead of an apostrophe.
Declaring the Charset
Always declare the charset as the first thing inside the head. The modern standard is UTF-8, which supports virtually every language and symbol.
<head>
<meta charset="UTF-8">
<title>My Page</title>
</head>Common Character Sets
| Charset | Description |
|---|---|
| UTF-8 | Unicode covering nearly all languages; the recommended default |
| ASCII | The original set: English letters, digits, and basic symbols only |
| ISO-8859-1 | An older Western European set (Latin-1), now largely replaced by UTF-8 |
Place the charset meta tag within the first 1024 bytes of the document, ideally as the very first line inside head. Declaring it late can cause the browser to reload and re-parse the page.
