Skip to content

Commit d2fe96b

Browse files
committed
[css2] updated the cascade order and the example.
--HG-- extra : convert_revision : svn%3A73dc7c4b-06e6-40f3-b4f7-9ed1dbc14bfc/trunk%401220
1 parent 8616764 commit d2fe96b

1 file changed

Lines changed: 30 additions & 22 deletions

File tree

css2/cascade.src

Lines changed: 30 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
22
<html lang="en">
3-
<!-- $Id: cascade.src,v 2.13 1998-03-15 22:44:21 bbos Exp $ -->
3+
<!-- $Id: cascade.src,v 2.14 1998-03-16 14:57:09 howcome Exp $ -->
44
<HEAD>
55
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
66
<TITLE>Assigning property values, Cascading, and Inheritance</TITLE>
@@ -335,19 +335,18 @@ must apply the following algorithm:</p>
335335
declarations apply, terminate the algorithm.
336336

337337
<LI>
338-
Sort the declarations by weight.
339-
<span class="index-def" title="important">"!important"</span>
340-
declarations in the user's style sheet have more weight than
341-
all other declarations.
342-
<span class="index-def" title="important">"!important"</span>
343-
declarations in the author's style sheets have more weight than
344-
those in the UA's default style sheet.
338+
Sort the declarations by weight: declarations marked <span
339+
class="index-def" title="important">"!important"</span> carry
340+
more weight than unmarked (normal) declarations.
345341

346342
<LI>
347-
Sort by origin: the author's style sheets override the user's
348-
style sheets which override the default style sheet. An imported
349-
style sheet has the same origin as the style sheet from which it
350-
is imported.
343+
Sort by origin: normally, the author's style sheets override the
344+
user's style sheets which override the default style sheet. For
345+
declarations marked <span class="index-def"
346+
title="important">"!important"</span>, the order is switched between
347+
the user and the author, so that user declarations override
348+
author declarations. An imported style sheet has the same
349+
origin as the style sheet from which it is imported.
351350

352351
<LI>
353352
Sort by specificity of selector: more specific selectors will
@@ -366,8 +365,11 @@ must apply the following algorithm:</p>
366365
the above steps yields a rule that has a higher weight than the other
367366
rules that apply to the same element/property combination.
368367

368+
<!--
369369
<P>Note that "!important" may occur in author's and UA's style sheets,
370370
but only has an effect in the user's style sheets.
371+
[nope, Chris Wilson wanted it to count, HWL]
372+
-->
371373

372374
<P> Apart from the "!important" setting on individual declarations,
373375
this strategy gives author's style sheets higher weight than those of
@@ -399,21 +401,27 @@ class="propinst-background">'background'</span>) to be "!important" is
399401
equivalent to declaring all of its sub-properties to be "!important".
400402

401403
<div class="example"><P>
402-
The first rule of the user's style sheet in the following example
403-
contains two "!important" declarations, which override
404-
the corresponding color and background properties in the
405-
author's style sheet even though the author has also specified
406-
"!important". The second rule of the user's style sheet will
407-
override the author's 'font-style' specification.</p>
404+
The first rule in the user's style sheet in the following example
405+
contains an "!important" declaration, which override
406+
the corresponding declaration in the authors's styles sheet.
407+
The second declaration will also win due to being marked
408+
"!important". However, the third rule in the user's style sheet will
409+
lose to the second rule in the author's style sheet (which happens to
410+
set style on a shorthand property). The third user rule will lose to
411+
the second author rule. Also, the third author rule will lose to the
412+
second author rule. This shows that "!important" declarations have a
413+
function also within author style sheets.
408414

409415
<PRE>
410416
/* From the user's style sheet */
411-
H1 { color: black ! important; background: white ! important }
412-
P { font-size: 18pt; font-style: normal ! important}
417+
P { text-indent: 1em ! important }
418+
P { font-style: italic ! important }
419+
P { font-size: 18pt }
413420

414421
/* From the author's style sheet */
415-
H1 { color: yellow ! important; background: blue ! important }
416-
P { font-size: 12pt; font-style: italic }
422+
P { text-indent: 1.5em !important }
423+
P { font: 12pt sans-serif !important }
424+
P { font-size: 24pt }
417425
</PRE>
418426
</div>
419427

0 commit comments

Comments
 (0)