Latest web development tutorials

HTML meta charset attribute

HTML meta tags Reference Manual HTML <meta> tag

Examples

The provisions of the character encoding of an HTML document:

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

try it"

Browser Support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support the charset attribute.


Definition and Usage

charset attribute specifies the character encoding of an HTML document.

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


Differences between HTML 4.01 and HTML5

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

Still allows the use of http-equiv attribute to specify the character set, but using the new method can reduce the amount of code.


grammar

<meta charset="character_set">

Property Value

描述
character_set 规定 HTML 文档的字符编码。

常用的值:

  • UTF-8 - Unicode 字符编码
  • ISO-8859-1 - 拉丁字母表的字符编码

在理论上,可以使用任何字符编码,但并不是所有浏览器都能够理解它们。某种字符编码使用的范围越广,浏览器就越有可能理解它。

如需查看所有可用的字符编码,请访问 IANA 字符集


HTML meta tags Reference Manual HTML <meta> tag