HTML Encoding (Character Sets)
HTML Encoding is a way to tell the browser how to read the text on your webpage. It ensures that special characters, emojis, and symbols display correctly.
1. What is a Character Set?
A character set (charset) is a list of characters that a webpage can display. Examples:
- UTF-8 - Supports almost all characters in the world, including emojis.
- ISO-8859-1 - Supports basic Latin characters.
2. How to Set Character Encoding in HTML
Use the <meta> tag inside the <head> section:
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>My Website</title> </head> <body> <p>Hello World! 🌍</p> </body> </html>
Hello World! 🌍
3. Why Use UTF-8?
- Supports almost every language and symbol.
- Ensures emojis and special characters display correctly.
- Recommended for all modern websites.
4. Example of Incorrect Encoding
If you don’t use proper encoding, special characters may appear as broken symbols:
Some characters may appear like this: � � �
Next Lesson → HTML vs XHTML
Previous Lesson → Using Emojis in HTML