Today, web host applications for different geographies and languages and different languages use different character sets, or charsets. To inform the browser about character set used in HTML5 document, you need to use the meta tag with attribute name charset
.
Let’s see an example of charset
declaration of UTF-8
.
<meta charset = "UTF-8" />
If you want to provide the charset information using old manner, then you will use below format. It’s given here for information purpose, and is not recommended.
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
XHTML documents have a third option: to express the character encoding via XML declaration:
<?xml version="1.0" encoding="UTF-8"?>
- While
UTF-8
will work in most instances, a lot of developers have found that usingISO-8859-1
as the charset gives even more flexibility. - Another charset,
UTF-16
, sometimes results in wrong characters and, in some cases, applications operating improperly. - Most modern web browsers feature automatic character encoding detection – if not declared explicitely.
Happy Learning !!
References:
https://www.w3.org/International/articles/http-charset/index
https://en.wikipedia.org/wiki/Character_encodings_in_HTML