yatongen yatongen - 9 months ago 42
HTTP Question

http-equiv="content-language" doesn't work (element.lang = "")

console.log("lang = " + document.documentElement.lang);

<meta http-equiv="content-language" content="es">


According to specification, If neither the node nor any of the node’s ancestors, including the root element, have either attribute set, but there is a pragma-set default language set, then that is the language of the node.

Joe Joe

The specification says:

This feature is non-conforming. Authors are encouraged to use the lang attribute instead.

Another note says:

The Content-Language value for an http-equiv attribute on a meta element should no longer be used.

As What is the HTML5 alternative to the obsolete meta http-equiv=content-language. suggests, using lang= instead works:

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

If your aim is to set the language, that's a better way to do it.