Skip to content

Commit c8461b1

Browse files
committed
[css3-cascade] Fix up handling of style attributes to match CSS1/CSS2 in the context of previous change.
1 parent 69ae236 commit c8461b1

2 files changed

Lines changed: 47 additions & 26 deletions

File tree

css3-cascade/Overview.html

Lines changed: 32 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -521,33 +521,40 @@ <h3 id=cascade><span class=secno>4.2. </span> Cascading Declarations</h3>
521521
element</dfn> and that element's descendants. For example, <a
522522
href="#HTML5" rel=biblioentry>[HTML5]<!--{{HTML5}}--></a> defines scoped
523523
<code>&lt;style&gt;</code> elements, whose style sheets are scoped to the
524-
element's parent. If a declaration is <a
525-
href="#scoped"><i>scoped</i></a>, which element it is scoped to affects
526-
the cascade. For the purpose of this step, declarations from style
527-
attributes <a href="#CSSSTYLEATTR"
528-
rel=biblioentry>[CSSSTYLEATTR]<!--{{!CSSSTYLEATTR}}--></a> are considered
529-
to be <a href="#scoped"><i>scoped</i></a> to the element with the
530-
attribute, and all unscoped declarations are considered to be <a
531-
href="#scoped"><i>scoped</i></a> to the root element.
524+
element's parent.
532525
<p> If the <a href="#scoping-element"><i>scoping elements</i></a> of two
533526
declarations have an ancestor/descendant relationship, then for normal
534527
rules the declaration whose <a href="#scoping-element"><i>scoping
535528
element</i></a> is the descendant wins, and for important rules the
536529
declaration whose <a href="#scoping-element"><i>scoping element</i></a>
537-
is the ancestor wins. If one declaration is from a style attribute on an
538-
element and the other is from a ruleset otherwise <a
539-
href="#scoped"><i>scoped</i></a> to that element, the declaration in the
540-
style attribute wins.
530+
is the ancestor wins.
531+
532+
<p> For the purpose of this step, all unscoped declarations are
533+
considered to be <a href="#scoped"><i>scoped</i></a> to the root
534+
element. Normal declarations from style attributes are considered to be
535+
<a href="#scoped"><i>scoped</i></a> to the element with the attribute,
536+
whereas important declarations from style attributes are considered to
537+
be <a href="#scoped"><i>scoped</i></a> to the root element. <a
538+
href="#CSSSTYLEATTR"
539+
rel=biblioentry>[CSSSTYLEATTR]<!--{{!CSSSTYLEATTR}}--></a>
540+
541+
<p class=note> This odd handling of <code>!important</code> style
542+
attribute declarations is to match the behavior defined in CSS Levels 1
543+
and 2, where style attributes simply have higher specificity than any
544+
other author rules. <a href="#CSS21"
545+
rel=biblioentry>[CSS21]<!--{{CSS21}}--></a>
541546

542547
<dt id=cascade-step-specificity>Specificity
543548

544549
<dd> The <a href="http://www.w3.org/TR/selectors/#specificity">Selectors
545550
module</a> <a href="#SELECT"
546551
rel=biblioentry>[SELECT]<!--{{!SELECT}}--></a> describes how to compute
547552
the specificity of a selector. For the purpose of this step, a ruleset
548-
without a selector (such as the contents of a style attribute) is
549-
considered to have a selector with specificity 0. The declaration
550-
belonging to a ruleset whose selector has the highest specificity wins.
553+
without a selector (such as the <a
554+
href="http://www.w3.org/TR/css-style-attr/#interpret">contents of a style
555+
attribute</a>) is considered to have a specificity higher than any
556+
selector. The declaration belonging to a ruleset whose selector has the
557+
highest specificity wins.
551558

552559
<dt id=cascade-step-order>Order of appearance.
553560

@@ -1160,6 +1167,16 @@ <h3 class=no-num id=other-references>Other references</h3>
11601167
<dt style="display: none"><!-- keeps the doc valid if the DL is empty -->
11611168
<!---->
11621169

1170+
<dt id=CSS21>[CSS21]
1171+
1172+
<dd>Bert Bos; et al. <a
1173+
href="http://www.w3.org/TR/2011/REC-CSS2-20110607/"><cite>Cascading Style
1174+
Sheets Level 2 Revision 1 (CSS 2.1) Specification.</cite></a> 7 June
1175+
2011. W3C Recommendation. URL: <a
1176+
href="http://www.w3.org/TR/2011/REC-CSS2-20110607/">http://www.w3.org/TR/2011/REC-CSS2-20110607/</a>
1177+
</dd>
1178+
<!---->
1179+
11631180
<dt id=CSS3PAGE>[CSS3PAGE]
11641181

11651182
<dd>Håkon Wium Lie; Melinda Grant. <a

css3-cascade/Overview.src.html

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -330,29 +330,33 @@ <h3 id='cascade'>
330330
so that it only affects its <dfn>scoping element</dfn> and that element's descendants.
331331
For example, [[HTML5]] defines scoped <code>&lt;style&gt;</code> elements,
332332
whose style sheets are scoped to the element's parent.
333-
If a declaration is <i>scoped</i>,
334-
which element it is scoped to affects the cascade.
335-
For the purpose of this step,
336-
declarations from style attributes [[!CSSSTYLEATTR]]
337-
are considered to be <i>scoped</i> to the element with the attribute,
338-
and all unscoped declarations are considered to be <i>scoped</i> to the root element.
339333

340334
<p>
341335
If the <i>scoping elements</i> of two declarations
342336
have an ancestor/descendant relationship,
343337
then for normal rules the declaration whose <i>scoping element</i> is the descendant wins,
344338
and for important rules the declaration whose <i>scoping element</i> is the ancestor wins.
345-
If one declaration is from a style attribute on an element
346-
and the other is from a ruleset otherwise <i>scoped</i> to that element,
347-
the declaration in the style attribute wins.
339+
340+
<p>
341+
For the purpose of this step,
342+
all unscoped declarations are considered to be <i>scoped</i> to the root element.
343+
Normal declarations from style attributes
344+
are considered to be <i>scoped</i> to the element with the attribute,
345+
whereas important declarations from style attributes
346+
are considered to be <i>scoped</i> to the root element.
347+
[[!CSSSTYLEATTR]]
348+
<p class="note">
349+
This odd handling of <code>!important</code> style attribute declarations
350+
is to match the behavior defined in CSS Levels 1 and 2,
351+
where style attributes simply have higher specificity than any other author rules. [[CSS21]]
348352

349353
<dt id='cascade-step-specificity'>Specificity
350354
<dd>
351355
The <a href="http://www.w3.org/TR/selectors/#specificity">Selectors module</a> [[!SELECT]] describes how to compute the specificity of a selector.
352356
For the purpose of this step,
353357
a ruleset without a selector
354-
(such as the contents of a style attribute)
355-
is considered to have a selector with specificity 0.
358+
(such as the <a href="http://www.w3.org/TR/css-style-attr/#interpret">contents of a style attribute</a>)
359+
is considered to have a specificity higher than any selector.
356360
The declaration belonging to a ruleset whose selector has the highest specificity wins.
357361

358362

0 commit comments

Comments
 (0)