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.
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 anhttp-equiv
attribute on ameta
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.