My project uses at least 100 helper classes like the below:
.pa5 {padding:5px} .pa10 {padding:10px} /* ... */
.pt5 {padding-top:5px} .pt10 {padding-top:10px} /* ... */
.pr5 {padding-right:5px} .pr10 {padding-right:10px} /* ... */
/* ... */
It comes handy in some cases like <div class="pa10">...</div>
but I think we overused it or, even worse, misused it.
For example, the below <a>
tag contains 8 classes to define how it display (background, background hover, padding, border radius, diplay inline block, margin and float left). It looks like the way you use style="..."
to inline style it:
<a href="#" class="bg1 bg2H pa10 rounded5 dpib mb10 fl mr10"></a>
In other case, even when we had the class profileInfo
, we still use it with a lot of helper classes:
<div class="profileInfo bd2 clearfix pa5 tac ol1 por"></div>
I think this is a worse practice and could cause significant performance overhead on page rendering. Since I haven't worked a lot with CSS, I could not explain it clearly to make us change the way of using it. What do you think? Does your project have an explicit rule to limit the number of CSS classes for one element?