Is there a downfall to applying multiple classes to an element, like the one
> above? How does it affect UAs?

Just thought I'd offer an alternate viewpoint to the "argh! no!" responses
so far.
Like most web dev questions there's a contextual aspect to the question.
There's a time and a place to use multiple classes.
Multiple classes are hugely useful if you have a really large site (or
collection of sites) with design variations over a standard structure (i.e.
standardised markup). You can use multiple classes to build up layers of
style and save a lot of repetition.
.default { /* set up widths, sizing, etc */}
.variant1 { color: #000; background: #fff; }
.variant2 { color: #fff; background: #000; }
(obviously in a real build you'd do this with meaningful classnames)
Then you can have:
<div class="default variant1">
<div class="default variant2">
...and you've saved the hack work of setting up the basics twice. When you
have hundreds of different pages it's pretty powerful. The downside of the
approach is that you really do have to have standardised markup - not just
"similar" or "usually the same" but things actually have to follow a

For a smaller site with the current browser market it's probably overkill,
and for the scenario in the original question I think contextual selectors
are the way to go.

But we should keep in mind that the end of IE6 is in sight, at which point
combined selectors will work as they're supposed to. That will make multiple
classes more broadly useful - including being useful on small sites - as
there's the potential to do more style work with less elements.

So basically... don't be hating multiple classes, they have their place ;)



--- <>
--- The future has arrived; it's just not
--- evenly distributed. - William Gibson

List Guidelines:

Reply via email to