Single directive generic class
CSS
.text-center { text-align: center }
HTML
<p class="text-center">center me</p>
That is our (not really) generic class and while we see this more and more over the web, there is no real explanation given why one should use it. Explanations like re-usable CSS classes don’t apply here. This class is as re-usable as the old <center>
tag. Also, we cannot change the body of the rule, as it would not make sense anymore. It’s absolutely not semantic either.
The good old style
-attribute
HTML
<p style="text-align:center">center me</p>
In the end, we have the same as above, but only in the place where we need it.
Why?
This might be a bad question, because the answer’s may be driven by taste. But personally I’d be interested in an answer that goes along with an explanation. Maybe something like “using the CSS class will ensure that it’s rendered faster” and if possible combined with hard proof.
Interesting Reads
The following are directly related to this question, because they are the reason why I started thinking about this topic:
<p>
. It might seem like overkill now, but in 6 months time when you decide you also want that text italicised and in a different font, your site is easier to update.