了解HTML元字符集 [英] Understanding HTML meta charset
问题描述
以下是我编写了解的关于 meta charset
标记的示例HTML。
<!DOCTYPE html>
< html lang =en>
< HEAD>
< meta charset =ANSI/>
< / head>
< body>
如
< / body>
< / html>
此HTML的BODY标签包含中文字符。
因为chareset设置为ANSI,所以我期待中文字符不会显示在浏览器中,而是会显示一些垃圾字符。
我想知道为什么中文字符显示正确,即使charset是ANSI而不是UTF-8。
ANSI对于<$不是有效值 c $ c> charset 。
浏览器也可以忽略< meta>
tag if:
- HTTP
Content-Type
/ li>
- 在HTML的开头有一个BOM;或
- 浏览器不认为该页面位于指定的字符集中(请参阅这个过程来确定一个页面的字符编码)。
Below is the sample HTML I have written to understand about meta charset
tag.
<!DOCTYPE html>
<html lang="en">
<HEAD>
<meta charset="ANSI" />
</head>
<body>
如
</body>
</html>
The BODY tag of this HTML contains chinese character.
Because chareset is set to "ANSI" , I was expecting that the chinese character will not be displayed in the browser, instead some junk character will get displayed.
I would like to know why chinese character is getting displayed correctly, even though charset is "ANSI" instead of UTF-8.
"ANSI" is not a valid value for charset
.
A browser may also ignore the <meta>
tag if:
- the HTTP
Content-Type
header tells it otherwise; - there is a BOM at the beginning of the HTML; or
- the browser does not think the page is in the named charset (see this process for determining a page's character encoding).
这篇关于了解HTML元字符集的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!