8000 csswg-drafts/css2/diffs-rec/cascade.html at c90a9ce1e72c34119e285f24d32236555435e24a · w3c/csswg-drafts · GitHub
Skip to content

Latest commit

 

History

History
545 lines (434 loc) · 29.5 KB

File metadata and controls

545 lines (434 loc) · 29.5 KB
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN">
<html lang="en">
<HEAD>
<TITLE>Assigning property values, Cascading, and Inheritance</TITLE>
<link rel="stylesheet" href="style/default.css" type="text/css">
<link rel="stylesheet" href="http://www.w3.org/StyleSheets/TR/W3C-ED.css" type="text/css">
<link rel="prev" href="selector.html">
<link rel="next" href="media.html">
<link rel="contents" href="cover.html#minitoc">
<link rel="CSS-properties" href="propidx.html" title="properties">
<link rel="index" href="indexlist.html" title="index">
<link rel="first" href="cover.html">
</HEAD>
<BODY>
<div class="navbar">
<p><a href="selector.html">previous</a> &nbsp;
<a href="media.html">next</a> &nbsp;
<a href="cover.html#minitoc">contents</a> &nbsp;
<a href="propidx.html">properties</a> &nbsp;
<a href="indexlist.html">index</a> &nbsp;
</div>
<hr class="navbar">
<h1><a name="q0">6 Assigning property values, Cascading, and Inheritance</a></h1>
<div class="subtoc">
<p><strong>Contents</strong>
<ul class="toc">
<li class="tocline2"><a href="cascade.html#value-stages" class="tocxref">6.1 Specified, computed, and actual values</a>
<ul class="toc">
<li class="tocline3"><a href="cascade.html#specified-value" class="tocxref">6.1.1 <span class="index-def" title="specified value"> Specified values</span></a>
<li class="tocline3"><a href="cascade.html#computed-value" class="tocxref">6.1.2 <span class="index-def" title="computed value"> Computed values</span></a>
<li class="tocline3"><a href="cascade.html#used-value" class="tocxref">6.1.3 <span class="index-def" title="used value"> <ins>Used values</ins></span></a>
<li class="tocline3"><a href="cascade.html#actual-value" class="tocxref"><ins>6.1.4</ins> <span class="index-def" title="actual value"> Actual values</span></a>
</ul>
<li class="tocline2"><a href="cascade.html#inheritance" class="tocxref">6.2 Inheritance</a>
<ul class="toc">
<li class="tocline3"><a href="cascade.html#value-def-inherit" class="tocxref">6.2.1 The <span class="index-def" title="inherit, definition of">'inherit'</span> value</a>
</ul>
<li class="tocline2"><a href="cascade.html#at-import" class="tocxref">6.3 The @import rule</a>
<li class="tocline2"><a href="cascade.html#cascade" class="tocxref">6.4 The cascade</a>
<ul class="toc">
<li class="tocline3"><a href="cascade.html#cascading-order" class="tocxref">6.4.1 Cascading order</a>
<li class="tocline3"><a href="cascade.html#important-rules" class="tocxref">6.4.2 !important rules</a>
<li class="tocline3"><a href="cascade.html#specificity" class="tocxref">6.4.3 Calculating a selector's specificity</a>
<li class="tocline3"><a href="cascade.html#preshint" class="tocxref">6.4.4 Precedence of non-CSS presentational hints</a>
</ul>
</ul>
</div>
<h2>6.1 <a name="value-stages">Specified, computed, and actual values</a></h2>
<p>Once a user agent has parsed a document and constructed a <a
href="conform.html#doctree">document tree</a>, it must assign, for
every element in the tree, a value to every property that applies to the
target <a href="media.html">media type</a>.
<p>The final value of a property is the result of a <del>three-step</del><ins>four-step</ins>
calculation: the value is determined through specification (the
"specified value"), then resolved into <ins>a value that is used for
inheritance (the "computed value"), then converted into</ins> an absolute
value if necessary (the <del>"computed</del><ins>"used</ins> value"), and finally transformed
according to the limitations of the local environment (the "actual
value").
<h3>6.1.1 <span class="index-def" title="specified value">
<a name="specified-value">Specified values</a></span></h3>
<p>User agents must first assign a specified value to <del>a</del><ins>each</ins> property based
on the following mechanisms (in order of precedence):</p>
<ol>
<li>If the <a href="#cascade">cascade</a> results in a value, use it.
<li>Otherwise, if the property is <a href="#inheritance">inherited</a> <ins>and the element is not the root of the</ins> <a><ins>document tree</ins></a>, use the <ins>computed</ins> value of the parent <del>element, generally the computed value.</del><ins>element.</ins>
<li>Otherwise use the property's <a name="x1"><span class="index-def" title="initial value">initial value</span></a>. The initial value of each property is indicated in the property's definition.
</ol>
<h3> <del>Since it has no parent, the root of the document tree cannot use values from the parent element; in this case, the initial value is used if necessary.</del>6.1.2 <span class="index-def" title="computed value">
<a name="computed-value">Computed values</a></span></h3>
<p>Specified values <del>may be absolute (i.e., they</del>are <del>not specified relative</del><ins>resolved</ins> to <del>another value, as in 'red' or '2mm') or relative (i.e., they</del><ins>computed values during the cascade;
for example URIs</ins> are <del>specified relative to another value, as in 'auto', '2em',</del><ins>made absolute</ins> and <del>'12%'). For</del><ins>'em' and 'ex'
units are computed to pixel or</ins> absolute <del>values, no computation is needed</del><ins>lengths. Computing a value
never requires the user agent</ins> to <del>find</del><ins>render</ins> the <del>computed value. Relative values, on</del><ins>document.</ins>
<p>The <del>other hand, must be transformed into</del>computed <del>values: percentages must be multiplied by a reference value (each property defines which</del>value <ins>of URIs</ins> that <del>is), values with relative units (em, ex, px) must be made</del><ins>the UA cannot resolve to</ins> absolute
<del>by multiplying with</del><ins>URIs is the specified value.</ins>
<p>The <del>appropriate font or pixel size, 'auto' values must be</del>computed <ins>value of a
property is determined as specified</ins> by the <del>formulas given with each property, certain keywords ('smaller', 'bolder', 'inherit') must be replaced according to their definitions. In most cases, elements inherit</del>Computed <del>values. However, there are some properties whose specified</del>Value <del>may be inherited (e.g.,</del><ins>line in</ins> the
<del>number value for</del><ins>definition of</ins> the
<del>'line-height' property). In</del><ins>property. See</ins> the <del>cases where child elements do not inherit</del><ins>section on</ins> <a href="#inheritance"><ins>inheritance</ins></a>
<ins>for</ins> the <ins>definition of</ins> computed <del>value, this</del><ins>values when the specified value</ins> is
<del>described in</del><ins>'inherit'.</ins>
<p>The <del>property definition. 6.1.3 Actual values A</del>computed value <del>is in principle ready to be used, but a user agent may</del><ins>exists even when the property does</ins> not <del>be able to make use of</del><ins>apply, as
defined by the</ins> <a href="about.html#applies-to"><ins>'Applies To'</ins></a> <ins>line.
However, some
properties may define</ins> the <ins>computed</ins> value <del>in</del><ins>of</ins> a <del>given environment.</del><ins>property</ins> for <del>example, a user agent may only be able</del><ins>an element</ins>
to <del>render borders with integer pixel widths and may therefore</del><ins>depend on whether the property applies to that element.</ins>
<h3><ins>6.1.3</ins> <span class="index-def" title="used value">
<a name="used-value"><ins>Used values</ins></a></span></h3>
<p><ins>Computed values are processed as far as possible without formatting
the document. Some values, however, can only be determined when the
document is being laid out. For example, if the width of an element is
set to be a certain percentage of its containing block, the width
cannot be determined until the width of the containing block has been
determined. The</ins> <dfn id="usedValue"><ins>used value</ins></dfn> <ins>is the result of
taking the computed value and resolving any remaining dependencies
into an absolute value.</ins>
<h3><ins>6.1.4</ins> <span class="index-def" title="actual value">
<a name="actual-value"><ins>Actual values</ins></a></span></h3>
<p><ins>A used value is in principle the value used for rendering, but a
user agent may not be able to make use of the value in a given
environment. For example, a user agent may only be able to render
borders with integer pixel widths and may therefore</ins> have to
approximate the computed <del>width.</del><ins>width, or the user agent may be forced to
use only black and white shades instead of full color.</ins> The actual
value is the <del>computed</del><ins>used</ins> value after any approximations have been applied.
<h2>6.2 <a name="inheritance">Inheritance</a></h2>
<p>Some values are inherited by the children of an element in the <a
href="conform.html#doctree">document tree</a><ins>, as described</ins> <a
href="#specified-value"><ins>above</ins></a>. Each property <a
href="about.html#property-defs">defines</a> whether it is inherited or
not.
<div class="html-example"><P>
Suppose there is an H1 element with an emphasizing element (EM)
inside:</p>
<pre>
&lt;H1&gt;The headline &lt;EM&gt;is&lt;/EM&gt; important!&lt;/H1&gt;
</pre>
<p>If no color has been assigned to the EM element, the emphasized
"is" will inherit the color of the parent element, so if H1 has the
color blue, the EM element will likewise be in blue.
</div>
<p> <del>To set a "default" style property for a document, authors may set the property on the root of the document tree. In HTML, for example, the HTML or BODY</del><ins>When inheritance occurs,</ins> elements <del>can serve this function. Note that this will work even if the author omits the BODY tag in the HTML source since the HTML parser will infer the missing tag. Example(s): For example, since</del><ins>inherit computed values.</ins> The
<del>'color' property is inherited, all descendants of</del><ins>computed value from</ins> the <del>BODY</del><ins>parent</ins> element <del>will inherit</del><ins>becomes both</ins> the <del>color 'black': BODY { color: black; }</del>specified
<del>percentage values are not inherited;</del><ins>value and the</ins> computed <del>values are.</del><ins>value on the child.</ins>
<div class="example"><P style="display:none">Example(s):</P><P>
For example, given the following style sheet:</P>
<pre>
body { font-size: 10pt }
h1 { font-size: <del>120%</del><ins>130%</ins> }
</pre>
<p>and this document fragment:
<pre class="html-example">
&lt;BODY&gt;
&lt;H1&gt;A &lt;EM&gt;large&lt;/EM&gt; heading&lt;/H1&gt;
&lt;/BODY&gt;
</pre>
<p>the <span class="prop-inst-font-size">'font-size'</span> property
for the H1 element will have the computed value <del>'12pt' (120%</del><ins>'13pt' (130%</ins> times
10pt, the parent's value). Since the computed value of <a href="fonts.html#propdef-font-size" class="noxref"><span
class="propinst-font-size">'font-size'</span></a> is inherited, the EM
element will have the computed value <del>'12pt'</del><ins>'13pt'</ins> as well. If the
user agent does not have the <del>12pt</del><ins>13pt</ins> font available, the
actual value of <a href="fonts.html#propdef-font-size" class="noxref"><span class="propinst-font-size">'font-size'</span></a>
for both H1 and EM might be, for example, <del>'11pt'.</del><ins>'12pt'.</ins>
</div>
<p class=note><ins>Note that inheritance follows the document tree and is
not intercepted by</ins> <span class=index-inst><a name="x5"
href="visuren.html#box-gen"><ins>anonymous boxes.</ins></a></span>
<h3>6.2.1 The <span class="index-def" title="inherit, definition
of"><a name="value-def-inherit">'inherit'</a></span>
value</h3>
<P>Each property may also have a <del>specified</del><ins>cascaded</ins> value of 'inherit', which
means that, for a given element, the property takes the same <del>computed</del><ins>specified</ins>
value as the property for the element's parent. The <del>inherited value, which is normally only used as a fallback value,</del><ins>'inherit' value</ins>
can be <del>strengthened by setting 'inherit' explicitly. Example(s): In</del><ins>used to enforce inheritance of values, and it can also be used on
properties that are not normally inherited.</ins>
<p><ins>If the 'inherit' value is set on the root element, the property is
assigned its initial value.</ins>
<div class="example"><P style="display:none"><ins>Example(s):</ins></P><P><ins>In</ins> the example below, the <a href="colors.html#propdef-color" class="noxref"><span
class="propinst-color">'color'</span></a> and <a href="colors.html#propdef-background" class="noxref"><span
class="propinst-background">'background'</span></a> properties are set on
the BODY element. On all other elements, the 'color' value will be
inherited and the background will be transparent. If these rules are
part of the user's style sheet, black text on a white background will
be enforced throughout the document.
<PRE>
body {
color: black !important;
background: white !important;
}
* {
color: inherit !important;
background: <del>transparent;</del><ins>transparent !important;</ins>
}
</PRE>
</div>
<H2>6.3 <a name="at-import">The @import rule</a></h2>
<P>The <a name="x7"><span class="index-def"
title="@import"><dfn>'@import'</dfn></span></a> rule allows users to
import style rules from other style sheets. <ins>In CSS&nbsp;2.1,</ins> any
@import rules must precede all <del>rule sets in a style sheet.</del><ins>other rules (except the @charset rule,
if present). See the</ins> <a href="syndata.html#at-rules"><ins>section on
parsing</ins></a> <ins>for when user agents must ignore @import rules.</ins> The
'@import' keyword must be followed by the URI of the style sheet to
include. A string is also allowed; it will be interpreted as if it had
url(...) around it.
<div class="example"><P style="display:none">Example(s):</P><P>
The following lines are equivalent in meaning and illustrate both
'@import' syntaxes (one with "url()" and one with a bare string):</p>
<PRE>
@import "mystyle.css";
@import url("mystyle.css");
</PRE>
</div>
<p>So that user agents can avoid retrieving resources for unsupported
<a href="media.html">media types</a>, authors may specify
media-dependent <a name="x8"><span class="index-inst"
title="@import">@import</span></a> rules. These <a name="x9"><span class="index-def"
title="conditional import|media-dependent import">conditional
imports</span></a> specify comma-separated media types after the URI.
<div class="example"><P style="display:none">Example(s):</P>
<p>The following rules <del>have the same effect as if the imported style sheet were wrapped in an @media rule for the same media, but it may save the UA a fruitless download.</del><ins>illustrate how @import rules can be made media-dependent:</ins></p>
<pre>
@import url("fineprint.css") print;
@import url("bluish.css") projection, tv;
</pre>
</div>
<p>In the absence of any media types, the import is
unconditional. Specifying 'all' for the medium has the same effect.
<ins>The import only takes effect if the target medium matches the media
list.</ins>
<p><ins>A target medium matches a media list if one of the items in the
media list is the target medium or 'all'.</ins>
<p class=note><ins>Note that Media Queries</ins> <a href="refs.html#ref-MEDIAQ" rel="biblioentry" class="noxref"><span class="informref"><ins>[MEDIAQ]</ins></span></a> <ins>extends the syntax of
media lists and the definition of matching.</ins>
<p><ins>When the same style sheet is imported or linked to a document in
multiple places, user agents must process (or act as though they do)
each link as though the link were to a separate style sheet.</ins>
<H2>6.4 <a name="cascade">The cascade</a></h2>
<P>Style sheets may have three different origins: author, user, and
user agent.</p>
<ul>
<li><strong>Author</strong>. The author specifies style sheets
for a source document according to the conventions of the document
language. For instance, in HTML, style sheets may be included in the
document or linked externally.
<li><strong>User</strong>: The user may be able to specify style
information for a particular document. For example, the user may
specify a file that contains a style sheet or the user agent may
provide an interface that generates a user style sheet (or <del>behave</del><ins>behaves</ins> as
if it did).
<li><strong>User agent</strong>: <a
href="conform.html#conformance">Conforming user agents</a> must apply
a <span class="index-def" title="default style sheet"><a
name="default-style-sheet"><dfn>default style sheet</dfn></a></span>
(or behave as if they <del>did) prior to all other style sheets for a document.</del><ins>did).</ins> A user agent's default style sheet should
present the
elements of the document language in ways that satisfy general
presentation expectations for the document language (e.g., for visual
browsers, the EM element in HTML is presented using an italic
font). See <a href="sample.html"> <del>"A</del><ins>A</ins> sample style sheet for HTML
</a> <del>4.0"</del>for a recommended default style sheet for HTML <del>4.0</del>documents.
<p class="note">Note that the <del>default style sheet</del><ins>user</ins> may <del>change if</del><ins>modify</ins> system settings <del>are modified by the user</del>(e.g.,
system <del>colors).</del><ins>colors) that affect the default style sheet.</ins> However, <del>due to limitations in a</del><ins>some</ins> user
<del>agent's internal implementation,</del><ins>agent implementations make</ins> it <del>may be</del>impossible to change the values in the
default style sheet.
</ul>
<P>Style sheets from these three origins will overlap in scope, and
they interact according to the cascade.
<P>The CSS <a name="x12"><span class="index-def" title="cascade">cascade</span></a>
assigns a weight to each style rule. When several rules apply, the one
with the 992E greatest weight takes precedence.
<P>By default, rules in author style sheets have more weight than
rules in user style sheets. Precedence is reversed, however, for
"!important" rules. All <del>rules</del>user and author rules have more weight
than rules in the UA's default style sheet.
<H3> <del>Imported style sheets also cascade and their weight depends on their import order. Rules specified in a given style sheet override rules imported from other style sheets. Imported style sheets can themselves import and override other style sheets, recursively, and the same precedence rules apply.</del>6.4.1 <a name="cascading-order">Cascading order</a></H3>
<P>To find the value for an element/property combination, user agents
must apply the following sorting order:</p>
<OL>
<LI>
Find all declarations that apply to the element and property in
question, for the target <a href="media.html">media type</a>.
Declarations apply if the associated selector <A
HREF="selector.html">matches</A> the element in <del>question.</del><ins>question and</ins> the
<del>primary sort of</del><ins>target medium matches</ins> the <del>declarations is by weight</del><ins>media list on all @media rules
containing the declaration</ins> and <del>origin: for normal declarations, author style sheets override user style sheets</del><ins>on all links on the path through</ins>
which <del>override</del>the <del>default</del>style <del>sheet. For "!important" declarations,</del><ins>sheet was reached.</ins>
<LI><ins>Sort according to importance (normal or important)
and origin (author, user, or</ins> user <del>style sheets override</del><ins>agent). In ascending order of
precedence:</ins>
<ol>
<li><ins>user agent declarations</ins>
<li><ins>user normal declarations</ins>
<li>author <del>style sheets which override the default style sheet. "!important" declaration override</del>normal <del>declarations. An imported style sheet has</del><ins>declarations</ins>
<li><ins>author important declarations</ins>
<li><ins>user important declarations</ins>
</ol>
<LI>
<ins>Sort rules with</ins> the same <ins>importance and</ins> origin <del>as the style sheet that imported it. The secondary sort is</del>by <a href="#specificity">specificity</a>
of selector: more specific
selectors will override more general ones. Pseudo-elements and
pseudo-classes are counted as normal elements and classes,
respectively.
<LI>Finally, sort by order specified: if two <del>rules</del><ins>declarations</ins> have the
same weight, origin and specificity, the latter specified wins.
<del>Rules</del><ins>Declarations</ins> in imported style sheets are considered to be before any
<del>rules</del><ins>declarations</ins> in the style sheet itself.
</OL>
<P>Apart from the "!important" setting on individual declarations,
this strategy gives author's style sheets higher weight than those of
the reader. <del>It is therefore important that the</del>User <del>agent</del><ins>agents must</ins> give the user the ability to turn off the
influence of <del>a certain</del><ins>specific author</ins> style <del>sheet,</del><ins>sheets,</ins> e.g., through a pull-down
menu. <ins>Conformance to UAAG 1.0 checkpoint 4.14 satisfies this condition</ins> <a href="refs.html#ref-UAAG10" rel="biblioentry" class="noxref"><span class="normref"><ins>[UAAG10]</ins></span></a><ins>.</ins>
<H3>6.4.2 <a name="important-rules">!important rules</a></H3>
<P>CSS attempts to create a balance of power between author
and user style sheets. By default, rules in an author's style
sheet override those in a user's style sheet (see cascade
rule 3).
<P>However, for balance, an "!important" declaration (the <del>keywords</del><ins>delimiter token</ins>
"!" and <ins>keyword</ins> "important" follow the declaration) takes precedence over
a normal declaration. Both author and user style sheets may contain
"!important" declarations, and user "!important" rules override author
"!important" rules. This CSS feature improves accessibility
of documents by giving users with special requirements (large
fonts, color combinations, etc.) control over presentation.
<P> <del>Note. This is a semantic change since CSS1. In CSS1, author "!important" rules took precedence over user "!important" rules.</del>Declaring a <a name="x13"><span class="index-inst" title="shorthand
property">shorthand property</span></a> (e.g., <a href="colors.html#propdef-background" class="noxref"><span
class="propinst-background">'background'</span></a>) to be "!important" is
equivalent to declaring all of its sub-properties to be "!important".
<div class="example"><P style="display:none">Example(s):</P>
<P>The first rule in the user's style sheet in the following example
contains an "!important" declaration, which overrides the corresponding
declaration in the author's <del>styles</del><ins>style</ins> sheet. The second declaration
will also win due to being marked "!important". However, the third
rule in the user's style sheet is not "!important" and will therefore
lose to the second rule in the author's style sheet (which happens to
set style on a shorthand property). Also, the third author rule will
lose to the second author rule since the second rule is
"!important". This shows that "!important" declarations have a
function also within author style sheets.
<PRE>
/* From the user's style sheet */
p { text-indent: 1em ! important }
p { font-style: italic ! important }
p { font-size: 18pt }
/* From the author's style sheet */
p { text-indent: 1.5em !important }
p { font: <ins>normal</ins> 12pt sans-serif !important }
p { font-size: 24pt }
</PRE>
</div>
<H3>6.4.3 <a name="specificity">Calculating a selector's specificity</a></H3>
<P>A selector's specificity is calculated as follows:</p>
<ul>
<li>count <ins>1 if the declaration is from is a 'style' attribute rather
than a rule with a
selector, 0 otherwise (= a) (In HTML, values of an element's "style"
attribute are style sheet rules. These rules have no selectors, so
a=1, b=0, c=0, and d=0.)</ins>
<li><ins>count</ins> the number of ID attributes in the selector (= <del>a)</del><ins>b)</ins>
<li>count the number of other attributes and pseudo-classes
in the selector (= <del>b)</del><ins>c)</ins>
<li>count the number of element names <ins>and pseudo-elements</ins> in the selector (= <del>c) ignore pseudo-elements.</del><ins>d)</ins>
</ul>
<p><ins>The specificity is based only on the form of the selector. In
particular, a selector of the form "[id=p33]" is counted as an
attribute selector (a=0, b=0, c=1, d=0), even if the id attribute is
defined as an "ID" in the source document's DTD.</ins>
<P>Concatenating the <del>three</del><ins>four</ins> numbers <del>a-b-c</del><ins>a-b-c-d</ins> (in a number system with a large
base) gives the specificity.
<div class="example"><P style="display:none">Example(s):</P><P>
Some examples:
<PRE>
* {} /* a=0 b=0 c=0 <ins>d=0</ins> -&gt; specificity = <del>0</del><ins>0,0,0,0</ins> */
li {} /* a=0 b=0 <del>c=1</del><ins>c=0 d=1</ins> -&gt; specificity = <del>1</del><ins>0,0,0,1 */
li:first-line {} /* a=0 b=0 c=0 d=2 -&gt; specificity = 0,0,0,2</ins> */
ul li {} /* a=0 b=0 <del>c=2</del><ins>c=0 d=2</ins> -&gt; specificity = 7292 <del>2</del><ins>0,0,0,2</ins> */
ul ol+li {} /* a=0 b=0 <del>c=3</del><ins>c=0 d=3</ins> -&gt; specificity = <del>3</del><ins>0,0,0,3</ins> */
h1 + *[rel=up]{} /* a=0 <del>b=1</del><ins>b=0</ins> c=1 <ins>d=1</ins> -&gt; specificity = <del>11</del><ins>0,0,1,1</ins> */
ul ol li.red {} /* a=0 <del>b=1 c=3</del><ins>b=0 c=1 d=3</ins> -&gt; specificity = <del>13</del><ins>0,0,1,3</ins> */
li.red.level {} /* a=0 <del>b=2 c=1</del><ins>b=0 c=2 d=1</ins> -&gt; specificity = <del>21</del><ins>0,0,2,1</ins> */
#x34y {} /* <ins>a=0 b=1 c=0 d=0 -&gt; specificity = 0,1,0,0 */
style="" /*</ins> a=1 b=0 c=0 <ins>d=0</ins> -&gt; specificity = <del>100</del><ins>1,0,0,0</ins> */
</PRE>
</div>
<div class="html-example">
<pre>
<del>In HTML, values of an element's "style" attribute are style sheet rules. These rules have no selectors, but for the purpose of step 3 of the cascade algorithm, they are considered to have an ID selector (specificity: a=1, b=0, c=0). For the purpose of step 4, they are considered to be after all other rules.</del>&lt;HEAD&gt;
&lt;STYLE type="text/css"&gt;
#x97z { color: <del>blue</del><ins>red</ins> }
&lt;/STYLE&gt;
&lt;/HEAD&gt;
&lt;BODY&gt;
&lt;P ID=x97z style="color: <del>red"&gt;</del><ins>green"&gt;</ins>
&lt;/BODY&gt;
</pre>
<P>In the above example, the color of the P element would be
<del>red. Although the specificity is the same for both declarations,</del><ins>green.</ins> The declaration in the "style" attribute will override the one in
the STYLE element because of cascading rule <del>4.</del><ins>3, since it has a higher
specificity.</ins>
</div>
<H3>6.4.4 <a name="preshint">Precedence of non-CSS presentational hints</a></H3>
<P>The UA may choose to honor presentational <del>hints from other sources than style sheets, for example the FONT element or the "align" attribute</del><ins>attributes</ins> in <del>HTML.</del><ins>an HTML source
document.</ins> If so, <del>the non-CSS presentational hints must be</del><ins>these attributes are</ins> translated to the corresponding
CSS rules with specificity equal to <del>zero. The rules</del><ins>0, and</ins> are <del>assumed to be</del><ins>treated as if they were
inserted</ins> at the start of the author style <del>sheet and</del><ins>sheet. They</ins> may <ins>therefore</ins> be
overridden by subsequent style sheet rules. <del>Note.</del>In a transition phase,
this policy will make it easier for stylistic attributes to coexist
with style sheets.
<P> <del>Note.</del><ins>For HTML, any attribute that is not</ins> in <del>CSS1,</del>the <del>non-CSS</del><ins>following list should be
considered presentational: abbr, accept-charset, accept, accesskey,
action, alt, archive, axis, charset, checked, cite, class, classid,
code, codebase, codetype, colspan, coords, data, datetime, declare,
defer, dir, disabled, enctype, for, headers, href, hreflang,
http-equiv, id, ismap, label, lang, language, longdesc, maxlength,
media, method, multiple, name, nohref, object, onblur, onchange,
onclick, ondblclick, onfocus, onkeydown, onkeypress, onkeyup, onload,
onload, onmousedown, onmousemove, onmouseout, onmouseover, onmouseup,
onreset, onselect, onsubmit, onunload, onunload, profile, prompt,
readonly, rel, rev, rowspan, scheme, scope, selected, shape, span,
src, standby, start, style, summary, title, type (except on LI, OL and
UL elements), usemap, value, valuetype, version.</ins>
<P><ins>For other languages, all document language-based styling must be
translated to the corresponding CSS and either enter the cascade at
the user agent level or, as with HTML</ins> presentational <del>hints were given</del><ins>hints, be treated
as author level rules with</ins> a specificity <del>equal to 1, not 0.</del><ins>of zero placed at</ins> the <del>change is due to</del><ins>start
of the author style sheet.</ins>
<div class="example"><P style="display:none"><ins>Example(s):</ins></P>
<p><ins>The following user style sheet would override</ins> the <del>introduction</del><ins>font weight</ins> of
<ins>'b' elements in all documents, and</ins> the <del>universal selector, which has a specificity</del><ins>color of 'font'
elements with color attributes in XML documents. It would not affect
the color of any 'font' elements with color attributes in HTML
documents:</ins>
<pre>
<ins>b { font-weight: normal; }
font[color] { color: orange; }</ins>
</pre>
<P><ins>The following, however, would override the color</ins> of <del>0.</del><ins>font elements in all documents:</ins>
<pre>
<ins>font[color] { color: orange ! important; }</ins>
</pre>
</div>
<hr class="navbar">
<div class="navbar">
<p><a href="selector.html">previous</a> &nbsp;
<a href="media.html">next</a> &nbsp;
<a href="cover.html#minitoc">contents</a> &nbsp;
<a href="propidx.html">properties</a> &nbsp;
<a href="indexlist.html">index</a> &nbsp;
</div>
</BODY>
</html>