11<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
22<html lang="en">
3- <!-- $Id: cascade.src,v 2.39 2002-09 -17 11:43:36 bbos Exp $ -->
3+ <!-- $Id: cascade.src,v 2.40 2002-11 -17 19:35:34 bbos 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>
77</HEAD>
88<BODY>
9- <H1>Assigning property values, Cascading, and Inheritance</H1>
109
11- <H2>Specified, computed, and actual values</h2>
12- <P>Once a user agent has parsed a document and constructed a <a
10+ <h1>Assigning property values, Cascading, and Inheritance</h1>
11+
12+ <h2>Specified, computed, and actual values</h2>
13+
14+ <p>Once a user agent has parsed a document and constructed a <a
1315href="conform.html#doctree">document tree</a>, it must assign, for
1416every element in the tree, a value to every property that applies to the
1517target <a href="media.html">media type</a>.
1618
17- <P >The final value of a property is the result of a three-step
19+ <p >The final value of a property is the result of a three-step
1820calculation: the value is determined through specification (the
1921"specified value"), then resolved into an absolute value if necessary
2022(the "computed value"), and finally transformed according to
@@ -24,24 +26,24 @@ the limitations of the local environment (the "actual value").
2426<span class="index-def" title="specified value">
2527<a name="specified-value">Specified values</a></span></h3>
2628
27- <P >User agents must first assign a specified value to a property based
29+ <p >User agents must first assign a specified value to a property based
2830on the following mechanisms (in order of precedence):</p>
2931
3032<ol>
3133<li>If the <a href="#cascade">cascade</a> results in a value,
32- use it.
34+ use it, unless the resulting value is 'inherit' .
3335
34- <li>Otherwise, if the property is <a
35- href="#inheritance">inherited</a>, use the value of the parent
36- element, generally the computed value .
36+ <li>If the property is <a href="#inheritance">inherited by default</a>
37+ or if the cascade resulted in the value 'inherit', use the computed
38+ value of the parent element .
3739
3840<li>Otherwise use the property's <span class="index-def"
3941title="initial value">initial value</span>. The <a
4042name="initial-value">initial value</a> of each property is indicated
4143in the property's definition.
4244</ol>
4345
44- <P >Since it has no parent, the root of the <a
46+ <p >Since it has no parent, the root of the <a
4547href="conform.html#doctree">document tree</a> cannot use values from
4648the parent element; in this case, the initial value is used if
4749necessary.
@@ -52,7 +54,7 @@ necessary.
5254</span>
5355</h3>
5456
55- <P >Specified values may be absolute (i.e., they are not specified
57+ <p >Specified values may be absolute (i.e., they are not specified
5658relative to another value, as in 'red' or '2mm') or relative (i.e.,
5759they are specified relative to another value, as in 'auto', '2em', and
5860'12%'). For absolute values, no computation is needed to find the
@@ -66,12 +68,6 @@ appropriate font or pixel size, 'auto' values must be computed by the
6668formulas given with each property, certain keywords ('smaller',
6769'bolder', 'inherit') must be replaced according to their definitions.
6870
69- <P>In most cases, elements inherit computed values. However, there are
70- some properties whose specified value may be inherited (e.g., the
71- number value for the <span
72- class="propinst-line-height">'line-height'</span> property).
73- In the cases where child elements do not inherit the computed value,
74- this is described in the property definition.
7571
7672<h3><span class="index-def" title="actual value">
7773<a name="actual-value">Actual values</a></span></h3>
@@ -83,9 +79,9 @@ pixel widths and may therefore have to approximate the computed
8379width. The actual value is the computed value after any approximations
8480have been applied.
8581
86- <H2 ><a name="inheritance">Inheritance</a></h2>
82+ <h2 ><a name="inheritance">Inheritance</a></h2>
8783
88- <P >Some values are inherited by the children of an element in
84+ <p >Some values are inherited by the children of an element in
8985the <a href="conform.html#doctree">document tree</a>. Each property <a
9086href="about.html#property-defs">defines</a> whether it is inherited or
9187not.
9490Suppose there is an H1 element with an emphasizing element (EM)
9591inside:</p>
9692
97- <PRE >
93+ <pre >
9894<H1>The headline <EM>is</EM> important!</H1>
99- </PRE >
95+ </pre >
10096
101- <P >If no color has been assigned to the EM element, the emphasized
97+ <p >If no color has been assigned to the EM element, the emphasized
10298"is" will inherit the color of the parent element, so if H1 has the
10399color blue, the EM element will likewise be in blue.
104100</div>
105101
106- <P> To set a "default" style property for a document, authors may set
107- the property on the root of the document tree. In HTML, for example,
108- the "html" or "body" elements can serve this function.
109-
110- <div class="example"><P>
111- For example, since the <span class="propinst-color">'color'</span>
112- property is inherited, all descendants of the "body" element will
113- inherit the color 'black':
114-
115- <PRE>
116- body { color: black; }
117- </PRE>
118- </div>
119-
120- <P>Specified percentage values are not inherited; computed values are.
102+ <p>When inheritance occurs, elements inherit computed values. Note
103+ that the result of this inheritance yields the specified value, so
104+ the definitions of computed values for properties do not describe
105+ the computatation of the computed value from a specified 'inherit'
106+ value since 'inherit' cannot be a specified value.
121107
122108<div class="example"><P>
123109For example, given the following style sheet:</P>
@@ -150,11 +136,10 @@ of"><a name="value-def-inherit">'inherit'</a></span>
150136value</h3>
151137
152138<P>Each property may also have a specified value of 'inherit', which
153- means that, for a given element, the property takes the same <a
154- href="#computed-value">computed value</a> as the property for the
155- element's parent. The inherited value, which is normally only used as
156- a fallback value, can be strengthened by setting 'inherit' explicitly.
157- It can also be used on properties that are not normally inherited.
139+ means that, for a given element, the property takes the same computed
140+ value as the property for the element's parent. The 'inherit' value
141+ can be used to stengthen inherited values, and it can also be used on
142+ properties that are not normally inherited.
158143
159144<div class="example"><P>In the example below, the <span
160145class="propinst-color">'color'</span> and <span
@@ -235,7 +220,7 @@ document or linked externally.
235220<li><strong>User</strong>: The user may be able to specify style
236221information for a particular document. For example, the user may
237222specify a file that contains a style sheet or the user agent may
238- provide an interface that generates a user style sheet (or behave as
223+ provide an interface that generates a user style sheet (or behaves as
239224if it did).
240225
241226<li><strong>User agent</strong>: <a
@@ -412,7 +397,8 @@ Some examples:
412397</div>
413398
414399<div class="html-example"><P>
415- <PRE>
400+
401+ <pre>
416402<HEAD>
417403<STYLE type="text/css">
418404 #x97z { color: red }
@@ -421,7 +407,7 @@ Some examples:
421407<BODY>
422408<P ID=x97z style="color: green">
423409</BODY>
424- </PRE >
410+ </pre >
425411
426412<P>In the above example, the color of the P element would be
427413green. The declaration in the "style" attribute will override the one in
@@ -436,39 +422,54 @@ defined as an "ID" in the source document's DTD.
436422
437423<H3>Precedence of non-CSS presentational hints</H3>
438424
439- <p>If the user agent chooses to honor presentational hints from other
440- sources than style sheets, these hints must be given the same weight
441- as the user agent's default style sheet.
425+ <P>The UA may choose to honor presentational attributes in the source
426+ document. If so, these attributes are translated to the corresponding
427+ CSS rules with specificity equal to 0, and are treated as if they were
428+ inserted at the start of the author style sheet. They may therefore be
429+ overridden by subsequent style sheet rules. In a transition phase,
430+ this policy will make it easier for stylistic attributes to coexist
431+ with style sheets.
432+
433+ <P>For HTML, any attribute that is not in the following list should be
434+ considered presentational: abbr, accept-charset, accept, accesskey,
435+ action, alt, archive, axis, charset, checked, cite, class, classid,
436+ code, codebase, codetype, colspan, coords, data, datetime, declare,
437+ defer, dir, disabled, enctype, for, headers, href, hreflang,
438+ http-equiv, id, ismap, label, lang, language, longdesc, maxlength,
439+ media, method, multiple, name, nohref, object, onblur, onchange,
440+ onclick, ondblclick, onfocus, onkeydown, onkeypress, onkeyup, onload,
441+ onload, onmousedown, onmousemove, onmouseout, onmouseover, onmouseup,
442+ onreset, onselect, onsubmit, onunload, onunload, profile, prompt,
443+ readonly, rel, rev, rowspan, scheme, scope, selected, shape, span,
444+ src, standby, start, style, summary, title, type, usemap, value,
445+ valuetype, version.
446+
447+ <P>For XHTML and other languages written in XML, no attribute should
448+ be considered presentational. The styling of elements and
449+ non-presentational attributes should be handled in the user agent
450+ stylesheet.
442451
443- <div class="note">
444- <P><em><strong>Note.</strong>
445- Non-CSS presentational hints had a higher weight in CSS2.</em>
446- </div>
452+ <div class="example">
447453
448- <!-- HWL 20020423: replaced description of presentational hints -->
449- <!--
450- <P>The UA may choose to honor presentational hints from other sources
451- than style sheets, for example the FONT element or the ALIGN
452- attribute in HTML. If so, the non-CSS presentational hints must be
453- translated to the corresponding CSS rules with specificity equal to
454- zero. The rules are assumed to be at the start of the author style sheet
455- and may be overridden by subsequent style sheet rules.
456-
457- <div class="note">
458- <P><em><strong>Note.</strong>
459- In a transition phase, this policy will make it easier for
460- stylistic attributes to coexist with style sheets.
461- </em>
462- </div>
454+ <p>The following user stylesheet would override the font weight of
455+ 'b' elements in all documents, and the color of 'font'
456+ elements with color attributes in XML documents. It would not affect
457+ the color of any 'font' elements with color attributes in HTML
458+ documents:
463459
464- <div class="note">
465- <P><em><strong>Note.</strong>
466- In CSS1, the non-CSS presentational hints were given a specificity
467- equal to 1, not 0. The change is due to the introduction of the
468- universal selector, which has a specificity of 0.
469- </em>
460+ <pre>
461+ b { font-weight: normal; }
462+ font[color] { color: orange; }
463+ </pre>
464+
465+ <P>The following, however, would override the color of font elements in all documents:
466+
467+ <pre>
468+ font[color] { color: orange ! important; }
469+ </pre>
470470</div>
471- -->
471+
472+
472473
473474</BODY>
474475</html>
0 commit comments