• Tutorial List

HTML Charset

Last updated Jul 08, 2020
HTML charset How to specify UTF-8 Unicode charset in HTML5

HTML charset is also known as HTML character set and HTML encoding. It is used to display the alphabets, numbers, and some other symbols correctly on a webpage.


How to specify charset in HTML?

A web browser must know the character set used in an HTML page to display the HTML page correctly.

The charset attribute of the <meta> tag is used to specify the charset in HTML5.

Syntax:

<meta charset="char_set">

Specifying UTF-8 Unicode charset in HTML5

<meta charset="UTF-8">
<!DOCTYPE html>
<html>
<head>
  
  <!-- Charset -->
  <meta charset="UTF-8">
  
  <title>Page Title</title>
  
</head>
  
<body>
  ...
</body>
</html>

How does it work?

There are various types of HTML Character Encoding, such as – 1) ASCII, 2) ANSI, 3) ISO-8859-1, 4) UTF-8. And each character encoding type contains a set of characters.

If you use an X character encoding type in your HTML page and write a character that is not available in the X character set, then the character will not display properly in your HTML page.

Example:

The Trademark symbol () is not available in ISO-8859-1, but it is available in UTF-8.

<!DOCTYPE html>
<html>
<head>
  <meta charset="ISO-8859-1">  
  <title>ISO-8859-1 Charset</title>
</head>
<body>

  Trademark Sign in ISO-8859-1 - ™
  
</body>
</html>
<!DOCTYPE html>
<html>
<head>
  <meta charset="UTF-8">  
  <title>UTF-8 Charset</title>
</head>
<body>

  Trademark Sign in UTF-8 - ™
  
</body>
</html>

Result

Meta charset Example Result
Meta charset Example Result

UTF-8 Unicode Character Set

The UTF-8 Unicode charset covers almost all characters and symbols in the world, that’s why this character encoding type is used on most websites, and the default character set for HTML5 is UTF-8.

HTML Charset List (PDF)

Ask Questions

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