How to obtain lang
attribute in HTML using JavaScript?
Just.
document.getElementsByTagName('html')[0].getAttribute('lang');
And with the namespace
document.getElementsByTagName('html')[0].getAttribute('xml:lang');
If both attributes agree on their values (as they should), it's enough to read either of them. I'd suggest using
document.documentElement.lang