Le 2 oct. 2013 à 08:56, Rick Gordon <[email protected]> a écrit :
In answer to my previous message:
> But if that's the case, this variant would not show red text for both:
>
> …
> <style type="text/css">
> body { color:blue; }
> .c2 {background-color:green; color:red;}
> .c1 {background-color:yellow; color:red;}
> </style>
> </head>
> <body>
> <div id="i1" class="c1, c2">C1 then C2</div>
> <div id="i2" class="c2, c1">C2 then C1</div>
> </body>
> ….
Why would it not show the colour as red? For the first div, the class 'c2' is
applied (and the class 'c1,' is ignored); for the second div the class 'c2,' is
ignored, the class 'c1' is applied.
The point is: in both div, the browser sees a classname that is a string
composed of 3 characters: 'c' '1' (or '2') and ','. The comma is part of the
string. That 3 character classname is not used in the stylesheet.
Now, you could specify somewhere in your stylesheet:
.c1, { background: red; color: white; }
This won't have any effect, as the string '.c1,' is invalid in css (see
css2.1:4.1.3 mentioned in my previous post).
However, you could escape that special character (the ','). Then the classname
would become a valid identifier / selector.
.c1\, { colour:black; background: cyan; }
Philippe
--
Philippe Wittenbergh
http://l-c-n.com
______________________________________________________________________
css-discuss [[email protected]]
http://www.css-discuss.org/mailman/listinfo/css-d
List wiki/FAQ -- http://css-discuss.incutio.com/
List policies -- http://css-discuss.org/policies.html
Supported by evolt.org -- http://www.evolt.org/help_support_evolt/