HTML5 替代过时的元 http-equiv=content-language 的方法是什么?
我正在完成一个混合英语和普通话的 HTML5 网站。
我的验证器(FF 的 HTML5 验证器附加组件)给了我这个错误:
error: Using the “meta” element to specify the document-wide default
language is obsolete. Consider specifying the language on the root
element instead.
At line 6, column 9: <meta http-equiv="Content-Language" content="en-us" />
相关代码是:
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
检查 W3.org 将我带到此页面: 告诉我,是的,它已经过时了
我必须承认我不明白我应该如何使该代码符合要求?
我不知道“在根元素上指定语言”是什么意思,或者如何做到这一点?
当然 不足以满足
UTF-8
吗?
I'm finishing up an HTML5 site that has a mixture of English and Mandarin Chinese.
My validator (HTML5 Validator add-on for FF) is giving me this error:
error: Using the “meta” element to specify the document-wide default
language is obsolete. Consider specifying the language on the root
element instead.
At line 6, column 9: <meta http-equiv="Content-Language" content="en-us" />
the relevant code is:
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
checking W3.org leads me to this page: telling me that yes, it's obsolete
I must confess I don't understand how I am supposed to bring this code into compliance?
I don't know what "specifying the language on the root element" means, or how to do it?
Surely <html lang="en">
doesn't suffice for UTF-8
?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
在 HTML5 中,您实际上可以为每个元素定义
lang
。这意味着如果您有一个包含中文普通话的div
,只需为该 div 定义一个属性lang="zh-CN"
,例如。
In HTML5 you can actually define
lang
for each element. That means if you have adiv
that contains Mandarin Chinese in it, just define an attributelang="zh-CN"
for that div, like<div lang="zh-CN">
.请参阅下文了解语言和字符集设置
See below for language and charset settings