When writing HTML you write markup using ASCII character set.ASCII character set consists of 128 characters.
The ASCII character set consists of :
- alphanumeric characters
- Numbers from 0 to 9
- English letters from A to Z
- Special characters such as! $ + – ( ) @ <
In HTML you specify the character set to use using the meta tag such as:
<meta http-equiv="Content-Type" content="text/html;charset=ISO-8859-1">
In HTML 5 you use UTF-8 :
In HTML 5 character encoding used is UTF-8.
So all browsers understands characters in the ASCII set.When you write HTML markup it is converted by the browser into numeric values understood by browsers.This is why you use the characters like <b> when using character encoding.These characters are directly understood by the browser.
Now when you characters from different character set then ASCII ,the browser may not understand the characters.
When browsers sends the request to server and receives the response from the server it is in ASCII character set.So encoding is the interface by which both the server and browser understand the same characters.
When you write HTML markup,it is not sufficient to consider that it will be understood by the browser.If you are using characters which are not in the ASCII character set then you need to escape them to their equivalent entity set character.
Encoding is used even in the URL.You might have observed the character %20 in the URL.The represents the space character.
HTML Entity set
HTML entity character begins with “&” and ends with the semicolon “;” character.The Entity set is understood and parsed by the browser.
Following are some the characters and their equivalent HTML entity.
|Character to use||Equivalent HTML entity character|
|greater-than character “>”||>|
|ampersand character “&”||&|
|Quotation mark “||"|
|Exclamation mark “!”||! !|
|Dollar sign||$ $|
So if you write < it will be correctly understood by the browser since it is an equivalent character which browser understands.