W3C home > Mailing lists > Public > www-style@w3.org > January 2008

RE: Re[6]: css with attribues [software]

From: Alan Gresley <alan1@azzurum.com>
Date: Tue, 22 Jan 2008 08:29:38 -0700
To: Dmitry Turin <sql4-en@narod.ru>
cc: www-style@w3.org
Message-ID: <20080122082938.34b83c2f3c9bef00757a2c62c0fb7450.57c0458ef6.wbe@email.secureserver.net>

Dmitry Turin wrote:

> <html>
> <style type="text/css">
>   p[color="orange"] {color:green}
> </style>
> <body>
>   <p style="color:orange">Name</p>
> </body>
> </html>
> 
> There is nothing green in Opera.
> If i'm disunderstanding you, correct example above.


No that is not correct. If the html attribute is 'style' then the value for the attribute in an attribute selector must be 'style' and the full string appearing between the "" in the HTML must equal the attributes' value. You have "orange" in your example where this should be "color:orange". Also note that inline styles [1] are more specific [2] than attribute selectors so !important must be used in style declaration for it to work.

1. http://www.w3.org/TR/html401/present/styles.html#adef-style
2. http://www.w3.org/TR/CSS21/cascade.html#specificity


An example:

<html>
<style type="text/css">
  p {color:red}
  [style="color:orange"] {color:green !important}
</style>
<body>
  <p style="color:orange">Name</p>
</body>
</html>


If the html attribute is 'color' then the value for the attribute must be 'color' and it would be like this:

<html>
<style type="text/css">
  p {color:red}
  [color="orange"] {color:green}
</style>
<body>
  <p color="orange">Name</p>
</body>
</html>


Please notice in both examples that I don't even have a 'p' preceding the attribute selector. Your example has.

p[color="orange"]  equals  'type selector'['HTML attribute'="'attributes' value'"]


I am selecting the <p> element by it attribute and value and not by its' type [3]. I could also select all other elements that share the same HTML attribute and value.

3. http://www.w3.org/TR/CSS21/selector.html#type-selectors


Alan

http://css-class.com/
Received on Tuesday, 22 January 2008 15:30:16 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Monday, 27 April 2009 13:54:58 GMT