sierra-library / sierra

Sierra SCSS library
https://sierra-library.github.io/
GNU General Public License v2.0
858 stars 73 forks source link

Why use classes and not element names? #22

Closed bhardin closed 8 years ago

bhardin commented 8 years ago

I apologize if this is a fairly neophyte question. But it's hard to keep up with speed at which CSS stuff moves. What is the decision for only using class names for styling and not element names?

For instance, <h2>Heading</h2> will not be styled while <h2 class="text-big">Heading</h2> will be.

I attempted to use Sierra on jekyll and can't due to this constraint.

JoanClaret commented 8 years ago

From my point of view, you should not style directly on element names. If so, your code becomes less flexible. If you apply styles using classes, you'll be free to apply any style to any element.

Imagine you have an <h2 class="text-medium">whatever</h2>, and you need to style it as a very big text. But you don't want to change the SEO structure. Simply replace like this: <h2 class="text-big">whatever</h2>.

If you don't develop like that that, you'll be forced to replace the h2 for an h1, which is not always interesting.

Anyways, maybe there are some exceptions. There are alot of ways to develop, but we found this one very useful.

bhardin commented 8 years ago

Yeah. That makes sense. I didn't know the design pattern reasoning. I appreciate your explanation, but unfortunately, I will not be able to use this library with Jekyll since when the markdown is converted to HTML it doesn't add class structure around element tags. :(

JoanClaret commented 8 years ago

@bhardin More info (and better explained!): http://cssguidelin.es/#css-selectors