English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

HTML Reference Manual

HTML Tag Directory

HTML meta charset attribute

The charset attribute specifies the character encoding of the HTML document. The format is: <meta charset="UTF-8">

 HTML <meta> tag

Online Example

Specify the character encoding of the HTML document:

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>HTML: <meta> charset attribute - Basic Tutorial Network(oldtoolbag.com)</title>
</head>
<body>
<h1>My Website</h1>
<p>Some text.../p>
</body>
</html>
Test to see ‹/›

Browser Compatibility

IEFirefoxOperaChromeSafari

All major browsers support the charset attribute.

Definition and Usage

The charset attribute specifies the character encoding of the HTML document.

Tip:charset attribute can be overridden by the lang attribute on any element.

HTML 4.01 with HTML5differences

charset attribute is HTML5The new features added in, replacing the need for the following content: <meta http-equiv ="Content-Type" content ="text / html; charset = UTF-8">.

Still allows the use of http-The equiv attribute specifies the character set, but the new method requires less code.

Syntax

<meta charset="character_set">

Attribute value

ValueDescription
character_setSpecifies the character encoding of the HTML document.

Common values:

  • UTF-8 - Unicode character encoding

  • ISO-8859-1 - Character encoding of the Latin alphabet

In theory, any character encoding can be used, but not all browsers can understand them. The more widely a character encoding is used, the more likely a browser is to understand it.

To view all available character encodings, please visit IANA Character Set.
 HTML <meta> tag