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.
Tech Lead/Team Lead. Senior WebDev.
Intermediate Grade on Computer Systems-
High Grade on Web Application Development-
MBA (+Marketing+HHRR).
Studied a bit of law, economics and design
Location
Spain
Education
Higher Level Education Certificate on Web Application Development
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.
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.thank you, still a little bit confused, but i'll do more research based on what you mentioned, thanks man!
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.
Complete CSS Guide for beginners and not so beginners
JoelBonetR ・ Jun 23 '20 ・ 30 min read
Hope it helps 😁