Table of Contents
Character Encoding in HTML (Charset) is easier to understand when the core ideas are paired with practical examples. The sections below explain the topic clearly, highlight useful steps, and point out details that can prevent common errors.
To display a proper HTML page, the web browser needs to know which character set to use (character encoding).
What is character encoding?
ASCII is the first character encoding (character encoding) (also known as character set). ASCII defines 128 alphanumeric characters: numbers from 0 to 9, English letters from A to Z and some special characters like! $ + - () @ <>.
ANSI (Windows-1252) is the first Windows character set that supports 256 different characters. ISO-8859-1 is the default character set for HTML 4, which also supports 256 characters.
Because ANSI and ISO-8859-1 are very limited, HTML 4 also supports UTF-8. UTF-8 (Unicode) includes almost all the characters and symbols in the world. HTML5 uses the UTF-8 character set by default.
Charset properties in HTML
The browser displays the HTML page with a set of characters specified in the tag .
With HTML 4
With HTML 5
If the browser detects ISO-8859-1 on the web, it will default to ANSI because ANSI is the same as ISO-8859-1, except that there are 32 other characters.
Differences between character sets
The table below shows the difference between the above character sets.
No.ASCIIANSI8859UTF-8Description32 white space 33!!!! exclamation point 34 "" "" quotation mark 35 # # # # sign up $ 36 $ dollar sign 37%%%% 38 percent sign & & & & sign and 39 '' '' single quotes 40 ((((opening quotes 41)))) closing quotes 42 * * * * asterisk 43 + + + + plus signs 44,,,, comma 45 - - - - dash 46.... dot 47 / / / / slash mark 48 0 0 0 0 number 0 49 1 1 1 1 number 1 50 2 2 2 2 number 2 51 3 3 3 3 3 3 4 4 4 4 4 4 53 5 5 5 5 number 5 54 6 6 6 6 6 6 55 7 7 7 7 7 7 8 8 8 8 8 8 8 9 9 9 9 9 9 58:::: comma 59;;;; semicolon 60 <<<>ASCII character set
ASCII uses values from 0 to 31 (and 127) to control characters, from 32 to 126 for letters, numbers and symbols. ASCII does not use values and 128 to 255.
ANSI character set (Windows-1252)
ANSI is like ASCII with values from 0 to 127, with value characters from 128 to 159, similar to UTF-8 in values from 160 to 255.
ISO-8859-1 character set
8859-1 is similar to ASCII in values from 0 to 127, not using values from 128 to 159, like UTF-8 in values from 160 to 255.
UTF-8 character set
UTF-8 is ASCII-like in values from 0 to 127, not using values between 128 and 159, both ANSI and 8859-1 are between 160 and 255, followed by values from 256 to more than 10,000 other characters.
FAQ
What is Character Encoding in HTML (Charset)?
To display a proper HTML page, the web browser needs to know which character set to use (character encoding).
Why is Character Encoding in HTML (Charset) important?
A clear understanding of Character Encoding in HTML (Charset) helps you make informed decisions, avoid common mistakes, and use the relevant tools or techniques more effectively.
How should beginners approach Character Encoding in HTML (Charset)?
Start with the fundamental concepts, follow the examples step by step, and test each change in a safe environment before applying it to important systems or data.
Reader Comments 0
Sign in with email or Google to join the discussion.