Skip to content

Commit 9179dea

Browse files
committed
[css3-cascade] Add section defining how shorthands work
1 parent 19eabc8 commit 9179dea

2 files changed

Lines changed: 173 additions & 46 deletions

File tree

css3-cascade/Overview.html

Lines changed: 114 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -131,63 +131,66 @@ <h2 class="no-num no-toc" id=table-of-contents> Table of contents</h2>
131131
<li><a href="#at-import"><span class=secno>2. </span> Importing style
132132
sheets: the ‘<code class=css>@import</code>’ rule</a>
133133

134-
<li><a href="#cascade-and-inheritance"><span class=secno>3. </span>
134+
<li><a href="#shorthand"><span class=secno>3. </span> Shorthand
135+
Properties</a>
136+
137+
<li><a href="#cascade-and-inheritance"><span class=secno>4. </span>
135138
Cascading and Inheritance</a>
136139
<ul class=toc>
137-
<li><a href="#filter-declarations"><span class=secno>3.1. </span>
140+
<li><a href="#filter-declarations"><span class=secno>4.1. </span>
138141
Filtering Declarations</a>
139142

140-
<li><a href="#cascade"><span class=secno>3.2. </span> Cascading
143+
<li><a href="#cascade"><span class=secno>4.2. </span> Cascading
141144
Declarations</a>
142145
<ul class=toc>
143-
<li><a href="#cascading-origins"><span class=secno>3.2.1. </span>
146+
<li><a href="#cascading-origins"><span class=secno>4.2.1. </span>
144147
Cascading Origins</a>
145148

146-
<li><a href="#important-rules"><span class=secno>3.2.2. </span>
149+
<li><a href="#important-rules"><span class=secno>4.2.2. </span>
147150
<code class=css>!important</code>’ rules</a>
148151

149-
<li><a href="#preshint"><span class=secno>3.2.3. </span> Precedence of
152+
<li><a href="#preshint"><span class=secno>4.2.3. </span> Precedence of
150153
Non-CSS Presentational Hints</a>
151154

152-
<li><a href="#cascaded-value"><span class=secno>3.2.4. </span> The
155+
<li><a href="#cascaded-value"><span class=secno>4.2.4. </span> The
153156
Cascaded Value</a>
154157
</ul>
155158

156-
<li><a href="#defaulting"><span class=secno>3.3. </span> Inheritance and
159+
<li><a href="#defaulting"><span class=secno>4.3. </span> Inheritance and
157160
Defaulting</a>
158161
<ul class=toc>
159-
<li><a href="#initial"><span class=secno>3.3.1. </span> Initial value:
162+
<li><a href="#initial"><span class=secno>4.3.1. </span> Initial value:
160163
the ‘<code class=css>initial</code>’ keyword </a>
161164

162-
<li><a href="#inheritance"><span class=secno>3.3.2. </span>
165+
<li><a href="#inheritance"><span class=secno>4.3.2. </span>
163166
Inheritance: the ‘<code class=css>inherit</code>’ keyword </a>
164167

165-
<li><a href="#default-keyword"><span class=secno>3.3.3. </span>
168+
<li><a href="#default-keyword"><span class=secno>4.3.3. </span>
166169
Rolling back the cascade: the ‘<code class=css>default</code>
167170
keyword</a>
168171
</ul>
169172
</ul>
170173

171-
<li><a href="#value-stages"><span class=secno>4. </span> Stages of Value
174+
<li><a href="#value-stages"><span class=secno>5. </span> Stages of Value
172175
Computation</a>
173176
<ul class=toc>
174-
<li><a href="#specified"><span class=secno>4.1. </span> Finding the
177+
<li><a href="#specified"><span class=secno>5.1. </span> Finding the
175178
specified value</a>
176179

177-
<li><a href="#computed"><span class=secno>4.2. </span> Finding the
180+
<li><a href="#computed"><span class=secno>5.2. </span> Finding the
178181
computed value</a>
179182

180-
<li><a href="#used"><span class=secno>4.3. </span> Finding the used
183+
<li><a href="#used"><span class=secno>5.3. </span> Finding the used
181184
value</a>
182185

183-
<li><a href="#actual"><span class=secno>4.4. </span> Finding the actual
186+
<li><a href="#actual"><span class=secno>5.4. </span> Finding the actual
184187
value</a>
185188

186-
<li><a href="#stages-examples"><span class=secno>4.5. </span>
189+
<li><a href="#stages-examples"><span class=secno>5.5. </span>
187190
Examples</a>
188191
</ul>
189192

190-
<li><a href="#conformance"><span class=secno>5. </span>Conformance</a>
193+
<li><a href="#conformance"><span class=secno>6. </span>Conformance</a>
191194

192195
<li class=no-num><a href="#acknowledgments">Acknowledgments</a>
193196

@@ -274,13 +277,75 @@ <h2 id=at-import><span class=secno>2. </span> Importing style sheets: the
274277
Specifying ‘<code class=css>all</code>’ for the medium has the same
275278
effect.
276279

277-
<h2 id=cascade-and-inheritance><span class=secno>3. </span> Cascading and
280+
<h2 id=shorthand><span class=secno>3. </span> Shorthand Properties</h2>
281+
282+
<p> Some properties are <dfn id=shorthand-properties>shorthand
283+
properties</dfn>, meaning that they allow authors to specify the values of
284+
several properties with a single property. A shorthand property sets all
285+
of its longhand sub-properties, exactly as if expanded in place.
286+
287+
<div class=example>
288+
<p> For example, the CSS 2.1 ‘<code class=property>font</code>
289+
property is a shorthand property for setting ‘<code
290+
class=property>font-style</code>’, ‘<code
291+
class=property>font-variant</code>’, ‘<code
292+
class=property>font-weight</code>’, ‘<code
293+
class=property>font-size</code>’, ‘<code
294+
class=property>line-height</code>’, and ‘<code
295+
class=property>font-family</code>’ all at once. The multiple style
296+
rules of this example:
297+
298+
<pre>
299+
h1 {
300+
font-weight: bold;
301+
font-size: 12pt;
302+
line-height: 14pt;
303+
font-family: Helvetica;
304+
font-variant: normal;
305+
font-style: normal;
306+
}</pre>
307+
308+
<p>can therefore be rewritten as
309+
310+
<pre>h1 { font: bold 12pt/14pt Helvetica }</pre>
311+
</div>
312+
313+
<p> When values are omitted from a shorthand form, unless otherwise
314+
defined, each "missing" sub-property is assigned its <a
315+
href="#initial-value"><i>initial value</i></a>.
316+
317+
<p class=note> This means that a shorthand property declaration always sets
318+
<em title="">all</em> of its subproperties, even those that are not
319+
explicitly set. Carelessly used, this might result in inadvertently
320+
resetting some sub-properties. Carefully used, a shorthand can guarantee a
321+
"blank slate" by resetting sub-properties inadvertently cascaded from
322+
other sources. For example, writing ‘<code class=css>background:
323+
green</code>’ rather than ‘<code class=css>background-color:
324+
green</code>’ ensures that the background color overrides any earlier
325+
declarations that might have set the background to an image.
326+
327+
<p> In some cases, a shorthand might have different syntax or special
328+
keywords that don't directly correspond to values of its sub-properties.
329+
(In such cases, the shorthand will explicitly define the expansion of its
330+
values.)
331+
332+
<p> If a shorthand is specified as one of the <a
333+
href="http://www.w3.org/TR/css3-values/">CSS-wide keywords</a>, it sets
334+
all of its sub-properties to that keyword. (Note that these keywords
335+
cannot be combined with other values in a single declaration, not even in
336+
a shorthand.)
337+
338+
<p> Declaring a shorthand property to be ‘<code
339+
class=css>!important</code>’ is equivalent to declaring all of its
340+
sub-properties to be "!important".
341+
342+
<h2 id=cascade-and-inheritance><span class=secno>4. </span> Cascading and
278343
Inheritance</h2>
279344

280345
<p> The cascading and inheritance process takes a set of declarations as
281346
input, and outputs a specified value for each property on each element.
282347

283-
<h3 id=filter-declarations><span class=secno>3.1. </span> Filtering
348+
<h3 id=filter-declarations><span class=secno>4.1. </span> Filtering
284349
Declarations</h3>
285350

286351
<p> In order to find the specified values, implementations must first
@@ -302,7 +367,7 @@ <h3 id=filter-declarations><span class=secno>3.1. </span> Filtering
302367
unordered list of values. The next section, the cascade process, orders
303368
these lists.
304369

305-
<h3 id=cascade><span class=secno>3.2. </span> Cascading Declarations</h3>
370+
<h3 id=cascade><span class=secno>4.2. </span> Cascading Declarations</h3>
306371

307372
<p> The cascade algorithm takes an unordered list of declarations for a
308373
given property on an element and sorts it by precedence as determined
@@ -367,7 +432,7 @@ <h3 id=cascade><span class=secno>3.2. </span> Cascading Declarations</h3>
367432
(potentially empty) sorted list of declarations for each property on each
368433
element.
369434

370-
<h4 id=cascading-origins><span class=secno>3.2.1. </span> Cascading Origins</h4>
435+
<h4 id=cascading-origins><span class=secno>4.2.1. </span> Cascading Origins</h4>
371436

372437
<p> Each style rule has an origin, which determines where it enters the
373438
cascade. CSS defines three core origins:
@@ -421,7 +486,7 @@ <h4 id=cascading-origins><span class=secno>3.2.1. </span> Cascading Origins</h4>
421486
generate "virtual" rules representing their effects when running.
422487
</dl>
423488

424-
<h4 id=important-rules><span class=secno>3.2.2. </span><code
489+
<h4 id=important-rules><span class=secno>4.2.2. </span><code
425490
class=css>!important</code>’ rules</h4>
426491

427492
<p> CSS attempts to create a balance of power between author and user style
@@ -469,7 +534,7 @@ <h4 id=important-rules><span class=secno>3.2.2. </span> ‘<code
469534
p { font-size: 24pt }</pre>
470535
</div>
471536

472-
<h4 id=preshint><span class=secno>3.2.3. </span> Precedence of Non-CSS
537+
<h4 id=preshint><span class=secno>4.2.3. </span> Precedence of Non-CSS
473538
Presentational Hints</h4>
474539

475540
<p> The UA may choose to honor presentational hints in a source document's
@@ -490,7 +555,7 @@ <h4 id=preshint><span class=secno>3.2.3. </span> Precedence of Non-CSS
490555
the appropriate level for presentational hints with these considerations
491556
in mind.
492557

493-
<h4 id=cascaded-value><span class=secno>3.2.4. </span> The Cascaded Value</h4>
558+
<h4 id=cascaded-value><span class=secno>4.2.4. </span> The Cascaded Value</h4>
494559

495560
<p> The <dfn id=cascaded-value0>cascaded value</dfn> represents the result
496561
of the cascade. It is the value of the highest declaration in the <a
@@ -503,7 +568,7 @@ <h4 id=cascaded-value><span class=secno>3.2.4. </span> The Cascaded Value</h4>
503568
its property definition table) or the ‘<code class=css>initial</code>
504569
keyword otherwise.
505570

506-
<h3 id=defaulting><span class=secno>3.3. </span> Inheritance and Defaulting</h3>
571+
<h3 id=defaulting><span class=secno>4.3. </span> Inheritance and Defaulting</h3>
507572

508573
<p> In most cases, the <a href="#specified-value"><i>specified
509574
value</i></a> is the <a href="#cascaded-value0"><i>cascaded value</i></a>.
@@ -512,7 +577,7 @@ <h3 id=defaulting><span class=secno>3.3. </span> Inheritance and Defaulting</h3>
512577
values are handled specially when they are the <a
513578
href="#cascaded-value0"><i>cascaded value</i></a> of a property.
514579

515-
<h4 id=initial><span class=secno>3.3.1. </span> Initial value: the ‘<code
580+
<h4 id=initial><span class=secno>4.3.1. </span> Initial value: the ‘<code
516581
class=css>initial</code>’ keyword</h4>
517582

518583
<p> Each property has an <dfn id=initial-value>initial value</dfn>, defined
@@ -522,7 +587,7 @@ <h4 id=initial><span class=secno>3.3.1. </span> Initial value: the ‘<code
522587
href="#initial-value"><i>initial value</i></a> becomes its <a
523588
href="#specified-value"><i>specified value</i></a>.
524589

525-
<h4 id=inheritance><span class=secno>3.3.2. </span> Inheritance: the
590+
<h4 id=inheritance><span class=secno>4.3.2. </span> Inheritance: the
526591
<code class=css>inherit</code>’ keyword</h4>
527592

528593
<p> Some properties are <dfn id=inherited-properties
@@ -553,7 +618,7 @@ <h4 id=inheritance><span class=secno>3.3.2. </span> Inheritance: the
553618
href="#inherited-value"><i>inherited value</i></a> becomes the property's
554619
<i>specified</i> and <a href="#computed-value"><i>computed values</i></a>.
555620

556-
<h4 id=default-keyword><span class=secno>3.3.3. </span> Rolling back the
621+
<h4 id=default-keyword><span class=secno>4.3.3. </span> Rolling back the
557622
cascade: the ‘<code class=css>default</code>’ keyword</h4>
558623

559624
<p> CSS Cascading and Inheritance Level 3 introduces the ‘<code
@@ -569,7 +634,7 @@ <h4 id=default-keyword><span class=secno>3.3.3. </span> Rolling back the
569634
class=css>default</code>’ or until the <a
570635
href="#output-of-the-cascade"><i>output of the cascade</i></a> is empty.
571636

572-
<h2 id=value-stages><span class=secno>4. </span> Stages of Value
637+
<h2 id=value-stages><span class=secno>5. </span> Stages of Value
573638
Computation</h2>
574639

575640
<p> Once a user agent has parsed a document and constructed a document
@@ -595,7 +660,7 @@ <h2 id=value-stages><span class=secno>4. </span> Stages of Value
595660
local environment.
596661
</ul>
597662

598-
<h3 id=specified><span class=secno>4.1. </span> Finding the specified value</h3>
663+
<h3 id=specified><span class=secno>5.1. </span> Finding the specified value</h3>
599664

600665
<p> The <dfn id=specified-value>specified value</dfn> is the output of the
601666
<a href="#cascade-and-inheritance">cascading and inheritance process</a>.
@@ -604,7 +669,7 @@ <h3 id=specified><span class=secno>4.1. </span> Finding the specified value</h3>
604669
href="#specified-value"><i>specified value</i></a> exists for every
605670
property on every element.
606671

607-
<h3 id=computed><span class=secno>4.2. </span> Finding the computed value</h3>
672+
<h3 id=computed><span class=secno>5.2. </span> Finding the computed value</h3>
608673

609674
<p> A <a href="#specified-value"><i>specified value</i></a> can be either
610675
absolute (i.e., not relative to another value, as in ‘<code
@@ -641,7 +706,7 @@ <h3 id=computed><span class=secno>4.2. </span> Finding the computed value</h3>
641706
href="#computed-value"><i>computed value</i></a> of a property for an
642707
element to depend on whether the property applies to that element.
643708

644-
<h3 id=used><span class=secno>4.3. </span> Finding the used value</h3>
709+
<h3 id=used><span class=secno>5.3. </span> Finding the used value</h3>
645710

646711
<p> <a href="#computed-value"><i>Computed values</i></a> are processed as
647712
far as possible without formatting the document. Some values, however, can
@@ -653,7 +718,7 @@ <h3 id=used><span class=secno>4.3. </span> Finding the used value</h3>
653718
href="#computed-value"><i>computed value</i></a> and resolving any
654719
remaining dependencies into an absolute value.
655720

656-
<h3 id=actual><span class=secno>4.4. </span> Finding the actual value</h3>
721+
<h3 id=actual><span class=secno>5.4. </span> Finding the actual value</h3>
657722

658723
<p> A <a href="#used-value"><i>used value</i></a> is in principle ready to
659724
be used, but a user agent may not be able to make use of the value in a
@@ -674,7 +739,7 @@ <h3 id=actual><span class=secno>4.4. </span> Finding the actual value</h3>
674739
reflect how many orphan lines there is in a certain element. See examples
675740
(j) and (k) in the <a href="#stages-examples">table below</a>.
676741

677-
<h3 id=stages-examples><span class=secno>4.5. </span> Examples</h3>
742+
<h3 id=stages-examples><span class=secno>5.5. </span> Examples</h3>
678743

679744
<table class=data>
680745
<thead>
@@ -868,7 +933,7 @@ <h3 id=stages-examples><span class=secno>4.5. </span> Examples</h3>
868933
<td><code class=css>3</code>
869934
</table>
870935

871-
<h2 id=conformance><span class=secno>5. </span>Conformance</h2>
936+
<h2 id=conformance><span class=secno>6. </span>Conformance</h2>
872937

873938
<p>[TBD]
874939

@@ -981,13 +1046,13 @@ <h2 class=no-num id=index>Index</h2>
9811046

9821047
<ul class=indexlist>
9831048
<li>actual value, <a href="#actual-value"
984-
title="actual value"><strong>4.4.</strong></a>
1049+
title="actual value"><strong>5.4.</strong></a>
9851050

9861051
<li>cascaded value, <a href="#cascaded-value0"
987-
title="cascaded value"><strong>3.2.4.</strong></a>
1052+
title="cascaded value"><strong>4.2.4.</strong></a>
9881053

9891054
<li>computed value, <a href="#computed-value"
990-
title="computed value"><strong>4.2.</strong></a>
1055+
title="computed value"><strong>5.2.</strong></a>
9911056

9921057
<li>conditional import, <a href="#conditional-imports"
9931058
title="conditional import"><strong>2.</strong></a>
@@ -996,28 +1061,31 @@ <h2 class=no-num id=index>Index</h2>
9961061
href="#atimport" title="''@import''"><strong>2.</strong></a>
9971062

9981063
<li>inherited properties, <a href="#inherited-properties"
999-
title="inherited properties"><strong>3.3.2.</strong></a>
1064+
title="inherited properties"><strong>4.3.2.</strong></a>
10001065

10011066
<li>inherited property, <a href="#inherited-properties"
1002-
title="inherited property"><strong>3.3.2.</strong></a>
1067+
title="inherited property"><strong>4.3.2.</strong></a>
10031068

10041069
<li>inherited value, <a href="#inherited-value"
1005-
title="inherited value"><strong>3.3.2.</strong></a>
1070+
title="inherited value"><strong>4.3.2.</strong></a>
10061071

10071072
<li>initial value, <a href="#initial-value"
1008-
title="initial value"><strong>3.3.1.</strong></a>
1073+
title="initial value"><strong>4.3.1.</strong></a>
10091074

10101075
<li>media-dependent import, <a href="#conditional-imports"
10111076
title="media-dependent import"><strong>2.</strong></a>
10121077

10131078
<li>output of the cascade, <a href="#output-of-the-cascade"
1014-
title="output of the cascade"><strong>3.2.</strong></a>
1079+
title="output of the cascade"><strong>4.2.</strong></a>
1080+
1081+
<li>shorthand properties, <a href="#shorthand-properties"
1082+
title="shorthand properties"><strong>3.</strong></a>
10151083

10161084
<li>specified value, <a href="#specified-value"
1017-
title="specified value"><strong>4.1.</strong></a>
1085+
title="specified value"><strong>5.1.</strong></a>
10181086

10191087
<li>used value, <a href="#used-value"
1020-
title="used value"><strong>4.3.</strong></a>
1088+
title="used value"><strong>5.3.</strong></a>
10211089
</ul>
10221090
<!--end-index-->
10231091

0 commit comments

Comments
 (0)