Jump to content

html[lang="en-us"] in css still work?


c64girl

Recommended Posts

17 hours ago, c64girl said:

I am using 1.7.x and i cant make this code work

html[lang="en-us"] #category h1 {

display:none !important;

}

Do the lang= still work?

in CSS, it is a better practice to use the :lang() pseudo-class, so your example to hide the category h1 elements en English would look like this:

html:lang(en) #category h1 {
  display:none !important;
}

This is because the browser might use other ways of determining the language of the page, other than the HTML "lang" attribute. Furthermore, the pseudo class can be used directly in nested elements, you don't need to use it on the root html tag. For instance, you could also write your rule like this for the same effect:

#category h1:lang(en) {
	display:none !important;
}

 

Link to comment
Share on other sites

13 hours ago, El Patron said:

We wrote this couple years back, maybe not for your question but does use ietf laungae like top end sites like Microsoft.  Most people don't know this is best in class solution.

 

https://prestaheroes.com/collections/all-modules/products/google-international-friendly-url

Stop spaming threads with links to modules! I dont need module to use css...

Link to comment
Share on other sites

17 hours ago, w3bsolutions said:

in CSS, it is a better practice to use the :lang() pseudo-class, so your example to hide the category h1 elements en English would look like this:

html:lang(en) #category h1 {
  display:none !important;
}

This is because the browser might use other ways of determining the language of the page, other than the HTML "lang" attribute. Furthermore, the pseudo class can be used directly in nested elements, you don't need to use it on the root html tag. For instance, you could also write your rule like this for the same effect:

#category h1:lang(en) {
	display:none !important;
}

 

Thx working

html.lang(en)

Link to comment
Share on other sites

10 hours ago, c64girl said:

Stop spaming threads with links to modules! I dont need module to use css...

You don't know what best in class is, that's your problem.  And it is on topic, it's an ietf module.  So your remark is rude and unnecessary.  I have 18 person agency and don't need to sell a module here.  At any rate If you dont understand localizing your shop using ietf language you should do some research and catch up with current best practices.

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
×
×
  • Create New...