HTML5 替代过时的元 http-equiv=content-language 的方法是什么?

发布于 2024-12-15 14:32:47 字数 813 浏览 1 评论 0原文

我正在完成一个混合英语和普通话的 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

药祭#氼 2024-12-22 14:32:48

在 HTML5 中,您实际上可以为每个元素定义 lang。这意味着如果您有一个包含中文普通话的 div,只需为该 div 定义一个属性 lang="zh-CN",例如

In HTML5 you can actually define lang for each element. That means if you have a div that contains Mandarin Chinese in it, just define an attribute lang="zh-CN" for that div, like <div lang="zh-CN">.

生活了然无味 2024-12-22 14:32:48

请参阅下文了解语言和字符集设置

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>title</title>
.....

See below for language and charset settings

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>title</title>
.....
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文