CSS Inheritance, The Cascade And Global Scope: Your New Old Worst Best Friends
CSS Inheritance, The Cascade And Global Scope: Your New Old Worst Best Friends As luck would have it, there is already a technology, called CSS, which is designed specifically to solve this problem. Using CSS, I can propagate styles that cross the borders of my HTML components, ensuring a consistent design with minimal effort . This is largely thanks to two key CSS features: inheritance, the cascade (the “C” in CSS). Despite these features enabling a DRY , efficient way to style web documents and despite them being the very reason CSS exists, they have fallen remarkably out of favor. From CSS methodologies such as BEM and Atomic CSS through to programmatically encapsulated CSS modules, many are doing their best to sidestep or otherwise suppress these features. This gives developers more control over their CSS, but only an autocratic sort of control based on frequent intervention. I’m going to revisit inheritance, the cascade and scope here with respect to...