DEV Community

Discussion on: I'm not sure how this CSS Class code works!

Collapse
 
alohci profile image
Nicholas Stimpson

In the exact example you've given, you probably can. But if you just use .contact__container as your selector, you're relying on DOM ordering to ensure that it overrides the .container rule, which can be fragile in some contexts. By using .container.contact__container you're using a higher specificity selector and guaranteeing that it will override the .container rule.

Collapse
 
starman1999 profile image
Mounir Dekali

thank you, still a little bit confused, but i'll do more research based on what you mentioned, thanks man!

Collapse
 
joelbonetr profile image
JoelBonetR 🥇 • Edited

Check out my profile, I've some posts about CSS, you can find this one linked below specially useful. Here you can find an extense explanation on how CSS handles priorities and how you can handle specificity.

Hope it helps 😁