How to obtain lang attribute in HTML using JavaScript?

Spread the love

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.

Leave a Reply

Your email address will not be published. Required fields are marked *