tags:

views:

38

answers:

2

How can I apply a CSS style block to several different classes? For instance, I have

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

...

.foo .bar ???    // This selector should apply to both classes
{
  font-size:50%;
  ...
}
+5  A: 
.foo, .bar
{
  font-size:50%;
  ...
}

Source: http://www.w3.org/TR/CSS2/selector.html#grouping

Kobi
+3  A: 

use a comma:

.foo, .bar {
....
}

The converse, applying multiple classes to a single element is possible too:

<html>
<head>
    <style type="text/css">
        .foo {
        }
        .bar {
        } 
    </style>
</head>
<body>
    <!-- 
        space separated list of classnames 
        to apply multiple css classes to a single element.
    -->
    <div class="foo bar">...</div>
</body>
</html>
Roland Bouman