HTML Charset

HTML Charset HTML Character Sets or HTML Encoding specify which character set to use. It is necessary for displaying an HTML page properly and correctly. The character set is specified in the <meta> tag:

Example:

<meta charset="UTF-8">

Types of HTML Charset or HTML Character Sets or HTML Encoding:

There are various types of Character Encoding in HTML, including:

  • ASCII Character Set:

The American Standard Code for Information Interchange or ASCII is also HTML’s first-ever character encoding standard. With 128 different alphanumeric characters including, numbers (0-9), English letters (A-Z), and some special characters like! $ + – ( ) @ <>, ASCII encoding still contains a limited range of characters.

  • ANSI Character Set:

The American National Standard Institute or ANSI is an extended version of the standard ASCII character set. This character set standard supports a 256-character set and was also the default character set for Windows up to Windows 95, and is often called Windows-1252.

  • ISO-8859-1 Character Set:

Being the default character set in HTML 2.0, the ISO-8859-1 character set uses full bytes (8 bits) to show characters and is an extension of the ASCII standard with International characters.

  • UTF-8 Character Set:

UTF-8 covers almost all of the characters and symbols in the world. It is a variable-width character encoding. ANSI is the original Windows character set, supporting 256 different character codes. Similarly, the ISO-8859-1, the default character set for HTML 4, also supported 256 different character codes, but still, ANSI and ISO-8859-1 were so limited that HTML 4 also supported UTF-8. This explains why the default character encoding for HTML5 is UTF-8.

HTML4 UTF-8 syntax:
<meta http-equiv="Content-Type" content="text/html;charset=ISO-8859-1">
HTML5 UTF-8 syntax:
<meta charset="UTF-8">
Syntax to set the encoding of the style sheet to Unicode UTF-8:
@charset "UTF-8";