Let’s make some things clear to facilitate understanding. Basically the :lang()
is just a selector. It serves nothing but to indicate the element to which the CSS should be applied.
For example:
p:lang(it) {
color:red;
}
That means only that the element <p>
that has the attribute lang="it"
shall be red in colour
p:lang(it) {
color:red;
}
<p lang="it">Cosa nostra!</p>
Now the HTML attribute lang=""
goes far beyond just being used as a selector in CSS, it determines the language with is contained in the element, and it can be very useful in accessibility issues, semantics, and even as a reference for indexing in search engines and for automatic translators and screen readers.
Indicated is to determine the language of the document content in the tag html
, guy: <html lang="en">
. This will indicate to search engines, or screen readers or translators that the language of the document is in English, however if within this document you have a quote in Italian vc can put a <p lang="it">Cosa nostra!</p>
this will make the element more semantic and accessible to screen readrs and translators.
Interesting article from W3C about lang
How should I set the language of the content in my HTML page?
"How to set the content language in my HTML page?"
Always use a language attribute on the html tag to declare the default language of the text in the page. When the page contains content in Another language, add a language attribute to an element surrounding that content.
PORTUGUÊS: "Always use a language attribute in the html tag to declare the default language of the text on the page. When the page contains content in another language, add a language attribute to an element around that content."
https://www.w3.org/International/questions/qa-html-language-declarations
Thanks again man, if it’s fucking
– user139915
@Leandronascimento not so much young rss! The question was interesting, the examples they use around for
lang
is that they leave things confusing, but basically it’s an HTML attribute like another qq, which you can use in CSS to define where you will apply the style. Not much... []s– hugocsl