0

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

Why?

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.

Iaroslav Baranov
  • 1,100
  • 9
  • 17
  • Possible duplicate of [What is the HTML5 alternative to the obsolete meta http-equiv=content-language.](http://stackoverflow.com/questions/8116812/what-is-the-html5-alternative-to-the-obsolete-meta-http-equiv-content-language) – Joe Sep 10 '16 at 11:50

1 Answers1

2

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.

Community
  • 1
  • 1
Joe
  • 29,416
  • 12
  • 68
  • 88