w3resource

HTML charset attribute

charset

The purpose of the HTML charset attribute is to define the character encoding style of a given linked resource.

Supported elements

HTML charset attribute supports a, link, script element.

Syntax

<ElementName charset="value" >.....</ElementName>

Where ElementName is any supported element.

Type of value

Type of value of HTML charset attribute is a character set.

Value

A character encoding type.

Default value

There is no default value. But most of the modern browsers use ISO-8859-1 as a default value.

Supported doctypes

HTML 4.01 strict, HTML 4.01 transitional, HTML 4.01 frameset.

Example of HTML charset attribute with a

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Example of HTML charset attribute with a </title>
</head>
<body>
<a charset="UTF-8" href="https://www.w3resource.com">www.w3resource.com</a>
</body>
</html>

Result

html charset attribute with a

View this example in a separate browser window

Example of HTML charset attribute with a.

Example of HTML charset attribute with link

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Example of HTML charset attribute with link</title>
<link href="w3resource_unicode.htm" rel="parent" charset="utf-8" />
</head>
<body>
<p>w3resource has an html page written in unicode</p> 
</body>
</html>

Usage of HTML charset attribute with script

<script type="text/javascript" src="w3rscripts.js" charset="UTF-8"></script>

Previous: HTML charoff attribute
Next: HTML checked attribute

Test your Programming skills with w3resource's quiz.



Follow us on Facebook and Twitter for latest update.