HTML Encoding (Character Sets)

HTML Encoding (Character Sets)

HTML encoding defines how characters are represented in a webpage. A character set ensures that text displays correctly in all browsers, including special characters, symbols, and non-English languages.


Why Encoding is Important

  • Prevents garbled text (mojibake) for special characters.

  • Supports multiple languages and scripts.

  • Ensures proper display of symbols, emojis, and HTML entities.


Common Character Sets

Character Set Description
UTF-8 Most widely used, supports all languages and symbols
ISO-8859-1 Western European languages
ASCII English characters and basic symbols only

Recommendation: Always use UTF-8 for modern web development.


Setting Character Encoding in HTML

The <meta> tag in the <head> section defines the character set:


 

Output:

  • Special characters display correctly: © ® € ™

  • Japanese text displays correctly: こんにちは


Key Points

  1. Place the <meta charset="UTF-8"> as early as possible in <head>.

  2. Always save your HTML file in UTF-8 encoding.

  3. UTF-8 supports all Unicode characters, including emojis.

CodeCapsule

Sanjit Sinha — Web Developer | PHP • Laravel • CodeIgniter • MySQL • Bootstrap Founder, CodeCapsule — Student projects & practical coding guides. Email: info@codecapsule.in • Website: CodeCapsule.in

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *