Charsets in HTML
Character Sets (Charsets) in HTML
A character set or charset tells the browser how to interpret the bytes in your HTML file as readable characters — letters, numbers, symbols, and more.
Why Charset Matters
Ensures text appears correctly on the web page
Supports multiple languages and symbols (like emojis)
Prevents "mojibake" — garbled or unreadable text
Common Charsets Used in HTML
| Charset | Description | Usage |
|---|---|---|
| UTF-8 | Unicode, supports nearly all characters and languages | The recommended standard for modern web |
| ISO-8859-1 | Western European languages | Older websites, legacy systems |
| ASCII | Basic English letters and symbols | Very basic, mostly obsolete |
How to Specify Charset in HTML
Use the <meta> tag inside the <head> section:
<meta charset="UTF-8">This tag tells the browser to use UTF-8 encoding, the most widely used charset on the web.
Example HTML Template with Charset
<!DOCTYPE html><html lang="en"><head> <meta charset="UTF-8"> <title>Charset Example</title></head><body> <p>Special characters: é, ñ, ü, ??, ?</p></body></html>Tips
Always save your HTML files as UTF-8 encoded in your text editor
Place the charset meta tag as early as possible inside
<head>for browsers to interpret it correctlyUse HTML entities (
&,<,©, etc.) for special characters if needed
Would you like to learn about HTML entities for special characters next?