While developing an internal IE6-only webapp, a discussion started about the
'best' way to apply classes to data tables across multiple pages. The two
arguments were:
1. Apply a single class to each table. That class (possibly in combination
with other classes on child elements) controls every part of the table -
layout, colors, fonts, etc. Example: class="data"
PROS: Easier to standardize, less specificity confusion, everything is
self-contained
CONS: Each slightly different table variation needs an entirely new class,
different classes may have many rules in common
2. Apply multiple classes to each table. Possibly one for layout, one for
colors, one for effects, etc. Example: class="compact dark grid dropshadow"
PROS: Classes control one aspect of table and combine in many different
ways, class rules don't grow too big or overlap
CONS: Possible specificity collisions, style selections seems to move into
html rather than in css, confusing to know which classes to pick
So this is mostly a question of opinion - When do you suggest using one
class vs. multiple classes and why? Is there a general rule that can be
quantified, or does it depend on the situation?
Some discussion on the question would be great!
--
Matt Kruse
http://www.JavascriptToolbox.com
http://www.AjaxToolbox.com