Skip to main content

HTML Encoding (Character Sets)

HTML encoding (or character encoding) is a way of representing characters in HTML documents.

It is necessary because not all characters can be represented directly in HTML.

For example, characters such as the greater than symbol (>) and the less than symbol (<) have special meanings in HTML and cannot be used to represent themselves.

There are many different character sets that can be used for HTML encoding. The most common character set is UTF-8, which can represent all characters in the Unicode character set. UTF-8 is widely supported and recommended for use in modern web development.

To specify the character set used in an HTML document, the <meta> tag can be used in the <head> section of the document.

As an example:

Below code specify UTF-8 encoding.

<meta charset="UTF-8" />
note

<meta charset="UTF-8" /> tag should be placed before any other content in the <head> section of the document.