javascript - http-equiv ="content-language"不起作用(element.lang = "")

标签 javascript html http meta

console.log("lang = " + document.documentElement.lang);
    <html>
    <head>
        <meta http-equiv="content-language" content="es">
    </head>
    <body></body>
    <html>

为什么?

According to specification ,如果该节点或该节点的任何祖先(包括根元素)都没有设置任一属性,但存在 pragma-set 默认语言设置,则该语言就是该节点的语言

最佳答案

specification says :

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.

What is the HTML5 alternative to the obsolete meta http-equiv=content-language.建议,使用 lang= 代替可以:

console.log("lang = " + document.documentElement.lang);
    <html lang="es">

如果您的目标是设置语言,这是一个更好的方法。

关于javascript - http-equiv ="content-language"不起作用(element.lang = ""),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39423840/

相关文章:

html - 浏览器读取 CSS 但不渲染它?

javascript - 如何使按钮显示表格 onclick

HTTP/2 推送 promise 行为

c++ - 在卡萨布兰卡获取 HTTP 请求的 IP

javascript - 单击按钮时设置新对象位置?

javascript - (多个)axios Post请求/参数问题

javascript - 警告 : Each child in an array or iterator should have a unique "key" prop. ; key 属性已经添加到 li 中

javascript - 我如何模拟用户单击 JQuery 中的链接?

javascript - 我如何获得本周的星期一?

macos - 我必须以某种方式输入 https ://explicitly when chrome returns ERR_EMPTY_RESPONSE