HTML <meta> charsetAttribute

HTML meta 标签参考手册HTML <meta> Tag

Examples

Specifies the character encoding for the HTML document:

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

Try it Yourself »

Browser Support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support the charset attribute.


Definition and Usage

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

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


Differences between HTML 4.01 and HTML5

The charset attribute is new in HTML5 and replaces: <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

It is still allowed to use the http-equiv attribute to specify the character set, but using the new method can reduce the amount of code.


Syntax

<meta charset="character_set">

Attribute Values

Value Description
character_set Specifies the character encoding for the HTML document.

Common values:

  • UTF-8 - Unicode character encoding
  • ISO-8859-1 - Character encoding for the Latin alphabet

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

To view all available character encodings, visitIANA character sets。


HTML meta 标签参考手册HTML <meta> Tag Other Extensions