DEV Community

Discussion on: 7 CSS Tips To Save Your Sanity

Collapse
 
lkw23002894 profile image
LKW

I appreciate it's tempting to have faith in popular frameworks. Particularly when they appear to work at first.

If we need to explicitly classify buttons as buttons in our HTML in order to give them style, we're not only doing something unnecessary, we're also allowing something potentially dangerous. Having a button class means anything could be styled like a button, even things that are not. You lose so much value when this deception is possible, and at scale, things that are possible, will actually happen eventually.

Choose appropriate HMTL and don't classify things too early.

Thread Thread
 
okeeffed profile image
Dennis O'Keeffe • Edited

If we need to classify buttons as buttons in HTML

Ahhh if you are referring to the examples given for the BEM and Outside In sections? They’re just trivial examples taken directly from their “Hello, World!” examples on their website to illustrate their approach.

But if by that you actually mean declaring HTML button tags, then that would just be semantically correct HTML5.

Thread Thread
 
lkw23002894 profile image
LKW • Edited

Indeed. Outside-In is reasonable, at least it doesn't interfere with anything that is of no concern.

I was talking specifically classification, i.e. the class attribute. This is what we were given to work around limitations of HTML, when we need to expand on the basic HTML taxonomy. For example we identify that our design has more than one kind of something, we have to assign new names and explain the difference, this is the classification process. Then at scale, users know what classes there are and more importantly, why there are more than one, and understand the rules when to use which class.

So it's BEM that's crazy. We don't want crazy if we care about our sanity. Why would we want to classify all our buttons as 'button'? That has no meaning and it's just extra work. We don't need to classify elements according to their state any more, either, that's certainly something from decades ago. We have attribute selectors for that, aria attributes are really good for that, too.