[thelist] Multiple CSS Classes

James Aylard webmaster at equilon-mrc.com
Fri Apr 26 18:47:01 CDT 2002


sasha,

> Having 2 classes applied to the same element like that
> is technically incorrect syntax (if I'm not mistaken).

    Sorry -- you _are_ mistaken! :) Multiple classes may be applied to an
element by using a space-separated list as the value of the class attribute.
However, IE/Win32 -- up to and including IE 6 -- does not handle
multiple-class selectors properly, so using multiple classes on an element
is a bit risky. If used simply, they are fine, such as:

<style type="text/css">
  .foo {
    color: #ffff00 ;
  }
  .bar {
    background-color: #ff0000 ;
  }
</style>
...
<p class="foo bar">This will have yellow text with a red background.</p>

    But, relying on the html snippet above, IE won't handle this properly
since it does not properly interpret multiple-class selectors:

<style type="text/css">
  .foo.bar {
    font-weight: bold ;
  }
</style>

James Aylard




More information about the thelist mailing list