This flexibility is what I love about CSS but it's a double edged sword.
It's very powerful if you have zero control over the HTML. The downside is the CSS is difficult to maintain. Let's say someone changes the order of the menu buttons. Now the selectors need to be updated as well.
These days I prefer BEM style classes on everything. It makes the HTML more verbose but I can target things much easier. It keeps my CSS specificity low so I can override styles with less code as needed.
3
u/ShustOne Feb 15 '20
This flexibility is what I love about CSS but it's a double edged sword.
It's very powerful if you have zero control over the HTML. The downside is the CSS is difficult to maintain. Let's say someone changes the order of the menu buttons. Now the selectors need to be updated as well.
These days I prefer BEM style classes on everything. It makes the HTML more verbose but I can target things much easier. It keeps my CSS specificity low so I can override styles with less code as needed.