http-equiv="content-language" 不起作用 (element.lang = "")
http-equiv="content-language" doesn't work (element.lang = "")
console.log("lang = " + document.documentElement.lang);
<html>
<head>
<meta http-equiv="content-language" content="es">
</head>
<body></body>
<html>
为什么?
According to specification,如果节点和节点的任何祖先(包括根元素)都没有设置任何属性,但是有 pragma-set 默认语言集,那么是节点的语言.
This feature is non-conforming. Authors are encouraged to use the lang attribute instead.
Another note 说:
The Content-Language
value for an http-equiv
attribute on a meta
element should no longer be used.
正如 所建议的那样,使用 lang=
是可行的:
console.log("lang = " + document.documentElement.lang);
<html lang="es">
如果您的目标是设置语言,这是更好的方法。
console.log("lang = " + document.documentElement.lang);
<html>
<head>
<meta http-equiv="content-language" content="es">
</head>
<body></body>
<html>
为什么?
According to specification,如果节点和节点的任何祖先(包括根元素)都没有设置任何属性,但是有 pragma-set 默认语言集,那么是节点的语言.
This feature is non-conforming. Authors are encouraged to use the lang attribute instead.
Another note 说:
The
Content-Language
value for anhttp-equiv
attribute on ameta
element should no longer be used.
正如 所建议的那样,使用 lang=
是可行的:
console.log("lang = " + document.documentElement.lang);
<html lang="es">
如果您的目标是设置语言,这是更好的方法。