HTML charset Attribute


The charset attribute of the <meta> element is used to specify the character encoding for the HTML document. You can use the charset attribute on <meta> as well as <script> element.

Different charsets include ASCII, ANSI, ISO-8859-1, UTF-8, etc. ISO-8859-1 supports 256 different character codes. ASCII defined 128 different alphanumeric characters. The charset attribute in HTML is used with the <meta> to specify the character encoding.

Let us now see an example to implement the charset attribute of the <meta> element:

Example

 Live Demo

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
</head>
<body>
   <h1>Demo Heading</h1>
   <p>This is demo text.</p>
   <p>We are learning about the charset attribute of the meta element in HTML.</p>
</body>
</html>

Output

In the above example, we have set the charset using the <meta> element:

<meta charset="UTF-8">

Updated on: 30-Jul-2019

482 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements