We use meta tags to tell more information about a document. For example the lang
attribute on HTML tag, provides more information about the document. Why we don’t use it as meta
tag attribute?
Why do we use in HTML tag?
We use meta tags to tell more information about a document. For example the lang
attribute on HTML tag, provides more information about the document. Why we don’t use it as meta
tag attribute?
Why do we use in HTML tag?
2
Answers
This use of the content-language value for an http-equiv attribute is deprecated by the HTML specification, and should no longer be used. Instead, you should always use a lang attribute on the html tag to declare the default language of the text in the page.
There used to a meta tag to indicate language.
<meta http-equiv="Content-Language" content="en-US">
http-equiv attribute is set to provide information equivalent to what can be given by a similarly-named HTTP header.
The header it tries to mock is
Content-Language: de, en
. It is to describe the language(s) intended for the audience.From the docs:
So even before it was deprecated it had a different purpose.
lang
attribute is used to define the language of the element. It does not indicate any intended audience, and is more about what is the content inside the tag. It can be put on<p>
,<li>
etc. Elements might be having content in a different language. You can have different divs in your web page having different languages. Defining one lang attribute in helps propagate it to all children, unless overridden.