[thelist] stupid CSS question

MRC webmaster at equilon-mrc.com
Tue Nov 27 17:30:02 CST 2001


Ben,

> You can do
> .foo {}

    True...

> or
> P.foo {}

    ... also true...

> and get results.  But not
> .bar.foo {}
> on account of the fact that you can't assign two CLASSes to the same
> element.

    ... but this isn't true. You can, in fact, assign more than one class to
an individual element per the CSS 2 recommendation. In the above example,
.bar.foo, would assign properties to any element which includes both the
class bar and the class foo. You assign multiple class values to an element
by using a space-separated list, like so:

<p class="bar foo">...</p>

    Unfortunately, that being said, only Mozilla/Netscape 6 seems to handle
this correctly. Microsoft implemented multiple classes per element in IE 5,
but IE (up to and including IE 6) does not understand the multiple-class
selector (i.e., .bar.foo), rendering it improperly. It ignores the first
class and applies the properties to any element of the second class (e.g.,
any element with class "foo", in this case). While this doesn't negate the
value of being able to assign multiple classes to an element, it does
diminish it.

James Aylard





More information about the thelist mailing list