To obtain lang attribute in HTML using JavaScript, we use the document.documentElement.lang
property.
For instance, we write
const lang = document.documentElement.lang;
to get the html element with document.documentElement
.
And we get the lang attribute value of the html element with the lang=
property.