Classes with spaces (was Re: [thelist] CSS: Why does this work?)

David Dorward evolt at
Tue Apr 6 10:28:04 CDT 2004

On 6 Apr 2004, at 14:28, Rob Smith wrote:

> Good morning, afternoon, evening,
>   <style type="text/css">
>    * { font: 1em serif; }
>    .a { position: absolute; z-index: 2;  top: 10; left: 10; padding: 
> 10px;}

Invalid - non-zero lengths _require_ units.

>   <div class="test a">This is a test. </div>
>   works the same as...
>   <div class="a">This is a test.  </div>
>   Why does the div work when you enter either "test a" or just "a" in 
> the
> class field? As a random test, "cow a" works too.

The class attribute specifies a space separated list of classes, not a 
single class.
.class matches "An element that is a member of class". It doesn't mean 
"An element that is a member of class but no other classes".

David Dorward

More information about the thelist mailing list