如果不是元元素,我应该在哪里指定我的字符集?

时间:2013-10-25 15:17:23

标签: html html5 validation

我收到以下行的HTML验证错误,如果我不在元标记内执行此操作,我不确定在哪里指定我的字符集。

Line 5, Column 70: Attribute charset not allowed on element meta at this point.

<meta http-equiv="Content-Type" content="text/html" charset="utf-8"/>

2 个答案:

答案 0 :(得分:9)

这是因为您将其放在Content-type元标记中,这是不允许的。

只需制作一个单独的元标记,例如

<meta charset="utf-8" />

这应该为你验证。

答案 1 :(得分:4)

是。您应该使用html5中的建议,这是一个新的推荐。

下面是一个简单的html5布局:

<!DOCTYPE html>
<html> 
<head> 
<meta charset="UTF-8"> 
<title>Title of the document</title> 
</head>

<body> 
Content of the document...... 
</body>

</html>