Avoid Nesting
We use modular CSS naming conventions like BEM and SUIT. One thing these all have in common is a recommendation to decrease the specificity of your selectors whenever possible. This leads to practical guidance like avoiding ID selectors in favor of class selectors and avoiding cascading selectors whenever possible.
Here’s a practical example. If you’ve got a .button
class and you’ve got a modifier to make it larger, like .button.is-large
, that’ll work great — until someone adds a rule saying that buttons in the sidebar should be extra-large (.sidebar .button
). Now even if you put the .is-large
modifier on your sidebar button, it won’t change, because the sidebar rule came later in the stylesheet, and they’re equal specificity. Suddenly you’re caught in an arms race, updating the modifier to use !important
or specificity hacks like
Email us: contact@neptunesolution.in
Call: 0172-4102740, +91-9780373638, 7495055288 for more details.
Visit us: www.neptunesolution.in
Office address: Sector 34-A, SCO 156-157, second floor, Near Verka Corporate Office, Chandigarh – 160022