To display HTML pages correctly, web browsers must use a character set (Character Set). Refer to the following Mytour article for detailed insights into the HTML Character Set.
Responsive Web Design in HTML
Article Contents:
1. What is Character Encoding?
2. HTML Charset Attribute
3. HTML Character Set
4. ASCII Character Set
5. ANSI Character Set (Windows-1252)
6. ISO-8859-1 Character Set
7. UTF-8 Character Set
8. CSS @charset Rule
1. What is Character Encoding?
ISO-8859-1 serves as the default character set for HTML 4, supporting 256 different character codes.
ANSI (Windows - 1252) is the original Windows character set. The ANSI character set is similar to ISO-8859-1, except for the addition of 32 additional characters.
Due to the limitations of ANSI and ISO-8859-1 character sets, HTML 4 also supports UTF-8. UTF-8 (Unicode) encompasses almost all characters and symbols worldwide.
UTF-8 is the default character set for HTML5.
2. HTML Charset Attribute
To display HTML pages accurately, web browsers must know the character set used on the page. This is specified within the meta tag:
If the browser detects ISO-8859-1 on a webpage, it will default to ANSI.
3. HTML Character Set
Below is a comprehensive list of character sets used in HTML:
4. ASCII Character Set
- ASCII utilizes values from 0 to 31 (and 127) for control characters.
- ASCII employs values from 32 to 126 for letters, numbers, and symbols.
- ASCII does not utilize values from 128 to 255.
5. ANSI Character Set (Windows-1252)
- The ANSI character set is similar to ASCII for values from 0 to 127.
- ANSI includes proprietary characters for values from 128 to 159.
- The ANSI character set is akin to UTF-8 for values from 160 to 255.
6. ISO-8859-1 Character Set
- ISO-8859-1 character set is similar to ASCII for values from 0 to 127.
- This character set does not use values from 128 to 159.
- ISO-8859-1 character set is similar to UTF-8 for values from 160 to 255.
7. UTF-8 Character Set
- UTF-8 character set is similar to ASCII for values from 0 to 127.
- UTF-8 does not use values from 128 to 159.
- UTF-8 character set is akin to ANSI and 8859-1 for values from 160 to 255.
- UTF-8 extends from value 256 with over 10,000 different characters.
8. CSS @charset Rule
We can employ the CSS @charset rule to specify the character encoding used in the style sheet.
Example: To set the character encoding of the style sheet to Unicode UTF-8, we use:
@charset 'UTF-8';
In this article, Mytour has introduced you to the character set in HTML. If you have any questions or need clarification on HTML, readers can leave their comments below the article. In the next article, Mytour will continue to delve into URL in HTML.