|
|
|
|
|
by gioele
4306 days ago
|
|
Why should "rounded" and "large" be classes? Isn't <div class="button buy">...</div>
plus a bit of SASS .buy {
@include big;
@include rounded;
}
enough and more correct?If you embed "big" in the HTML, how do you go from mobile to desktop? Maybe that button should be "big" on desktop, but only slightly bigger than normal on mobile. If you specify its _role_ rather than its presentation, it becomes very easy to override the style in CSS with @media selectors. PS: BTW, <button class="buy">...</button>, no <div> needed. |
|
Using a conceptually high-level naming scheme won't scale very well as your team and site grows. Eventually someone will say, I need a large rounded button, I can use the .buy class for this contact form. Or perhaps your team is very disciplined but ends up with 10-15 different ways of specifying large rounded buttons.
You'll potentially end up where .buy makes sense in two different contexts which will then increase the complexity of your css:
button.buy {...} h1.buy {...}
Having .button .button-rounded .button-large helps you keep your css simple allows it to be remixed and reused in ways you haven't planned for yet.
Not to say semantic classes are wrong, I like them, but I have yet to see a system for it that doesn't break down after a certain size for a project/team.