HTML Basics
HTML Charsets
A character set, or charset, tells the browser how to turn the bytes in your file into readable letters and symbols. Declaring UTF-8 is a must for every modern page.
What is a Character Set?
Computers store text as numbers. A character set (charset) is the mapping between those numbers and the actual characters you see. If the browser guesses the wrong charset, text appears as strange symbols known as mojibake.
UTF-8 is the character set of the web. It can represent virtually every character from every language — English, Hindi, emoji, currency symbols — which is why nearly all pages use it.
Syntax
<meta charset="UTF-8">Example: A Correctly Encoded Page
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Multilingual Page</title>
</head>
<body>
<p>English: Hello</p>
<p>Hindi: नमस्ते</p>
<p>Japanese: こんにちは</p>
<p>Emoji: 🎉 💻 🚀</p>
</body>
</html>More Examples
<!DOCTYPE html>
<html>
<head><meta charset="UTF-8"></head>
<body>
<p>Prices: ₹499, €10, £8, ¥1000</p>
<p>Names: José, Zoë, François</p>
</body>
</html>Charset Facts
| Item | Detail |
|---|---|
| Recommended charset | UTF-8 |
| Where to declare it | First thing inside <head> |
| Characters supported | All Unicode: every language plus emoji |
| If omitted | Browser may guess wrong and show garbled text |
Put <meta charset="UTF-8"> as the very first element inside <head>, before the title. The browser must know the encoding before it reads the text.
Also make sure your editor saves the file itself as UTF-8. Declaring UTF-8 but saving in another encoding still produces garbled characters.
Key Takeaways
- A charset maps stored numbers to visible characters.
- UTF-8 supports every language and emoji, and is the web standard.
- Declare it with <meta charset="UTF-8"> at the top of <head>.
- Save your file as UTF-8 too, or text may still break.
