|
Posted by Ben C on 01/20/07 09:22
On 2007-01-20, Roy A. <royarneskar@gmail.com> wrote:
>
> Ben C skrev:
>> On 2007-01-18, dfloss <dfloss@imap.com> wrote:
>> > given this css:
>> >
>> > .no_left_border {border-left: 0px solid}
>> > table td {border-left: 1px solid}
>> >
>> ><td class="no_left_border"> <-- doesn't work -->
>> ><td style="border-left: 0px solid"> <-- works -->
>> >
>> > Can someone explain the behind the scenes reasons?
>>
>> table td is more "specific" than .no_left_border, so wins.
This was wrong: .no_left_border is more specific than table td.
>> But the style
>> attribute is more specific still.
>>
>> See http://www.w3.org/TR/CSS21/cascade.html, particularly 6.4.3
>> "Calculating a selector's specificity".
>
> I notice that the pseudo-classes :link, :visited, :active, :focus,
>:hover have the same weight.
They all affect specificity equally, yes.
> According to these rules, putting these classes in a certain order in
> the stylesheet doesn't make sense. By using an element name before the
> pseudo-class, e.g. a:active, would ensure that this style take
> precedence. But, is there any default cascading order for these
> classes? I suspect it is vendor specific.
It's all specified, see 6.4.1. You sort by origin, then by specificity,
and finally by the order in which they appeared. There should be always
one and only one right answer for what styles an element should get from
the cascade.
Navigation:
[Reply to this message]
|