-
Notifications
You must be signed in to change notification settings - Fork 791
Expand file tree
/
Copy pathOverview.html
More file actions
1201 lines (993 loc) · 88.2 KB
/
Overview.html
File metadata and controls
1201 lines (993 loc) · 88.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
15
8000
7
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!DOCTYPE html><html lang=en><head>
<meta content="text/html; charset=utf-8" http-equiv=Content-Type>
<title>CSS Cascading and Inheritance Level 3</title>
<link href=../default.css rel=stylesheet type=text/css>
<link href=../csslogo.ico rel="shortcut icon" type=image/x-icon>
<link href=https://www.w3.org/StyleSheets/TR/W3C-CR rel=stylesheet type=text/css>
</head>
<body class=h-entry>
<div class=head>
<p data-fill-with=logo><a class=logo href=http://www.w3.org/>
<img alt=W3C height=48 src=https://www.w3.org/Icons/w3c_home width=72>
</a>
</p>
<h1 class="p-name no-ref" id=title>CSS Cascading and Inheritance Level 3</h1>
<h2 class="no-num no-toc no-ref heading settled heading" id=subtitle><span class=content>W3C Candidate Recommendation,
<span class=dt-updated><span class=value-title title=20131003>3 October 2013</span></span></span></h2>
<div data-fill-with=spec-metadata><dl><dt>This version:<dd><a class=u-url href=http://www.w3.org/TR/2013/CR-css-cascade-3-20131003/>http://www.w3.org/TR/2013/CR-css-cascade-3-20131003/</a><dt>Latest version:<dd><a href=http://www.w3.org/TR/css-cascade-3/>http://www.w3.org/TR/css-cascade-3/</a><dt>Editor’s Draft:<dd><a href=http://dev.w3.org/csswg/css-cascade/>http://dev.w3.org/csswg/css-cascade/</a><dt>Previous Versions:<dd><a href=http://www.w3.org/TR/2013/WD-css-cascade-3-20130730/ rel=previous>http://www.w3.org/TR/2013/WD-css-cascade-3-20130730/</a><dd><a href=http://www.w3.org/TR/2013/WD-css3-cascade-20130103/ rel=previous>http://www.w3.org/TR/2013/WD-css3-cascade-20130103/</a><dd><a href=http://www.w3.org/TR/2005/WD-css3-cascade-20051215/ rel=previous>http://www.w3.org/TR/2005/WD-css3-cascade-20051215/</a>
<dt>Feedback:</dt>
<dd><a href="mailto:www-style@w3.org?subject=%5Bcss-cascade%5D%20feedback">www-style@w3.org</a>
with subject line
“<kbd>[css-cascade] <var>… message topic …</var></kbd>”(<a href=http://lists.w3.org/Archives/Public/www-style/ rel=discussion>archives</a>)<dt>Test Suite:<dd>None Yet<dt>Editors:
<dd class="p-author h-card vcard"><a class="p-name fn u-email email" href=mailto:howcome@opera.com>Håkon Wium Lie</a> (<span class="p-org org">Opera Software</span>)<dd class="p-author h-card vcard"><a class="p-name fn u-url url" href=http://fantasai.inkedblade.net/contact>fantasai</a> (<span class="p-org org">Mozilla</span>)<dd class="p-author h-card vcard"><a class="p-name fn u-url url" href=http://xanthir.com/contact/>Tab Atkins Jr.</a> (<span class="p-org org">Google</span>)</dl></div>
<div data-fill-with=warning></div>
<p class=copyright data-fill-with=copyright><a href=http://www.w3.org/Consortium/Legal/ipr-notice#Copyright>Copyright</a> © 2014 <a href=http://www.w3.org/><abbr title="World Wide Web Consortium">W3C</abbr></a><sup>®</sup> (<a href=http://www.csail.mit.edu/><abbr title="Massachusetts Institute of Technology">MIT</abbr></a>, <a href=http://www.ercim.eu/><abbr title="European Research Consortium for Informatics and Mathematics">ERCIM</abbr></a>, <a href=http://www.keio.ac.jp/>Keio</a>, <a href=http://ev.buaa.edu.cn/>Beihang</a>), All Rights Reserved. W3C <a href=http://www.w3.org/Consortium/Legal/ipr-notice#Legal_Disclaimer>liability</a>, <a href=http://www.w3.org/Consortium/Legal/ipr-notice#W3C_Trademarks>trademark</a> and <a href=http://www.w3.org/Consortium/Legal/copyright-documents>document use</a> rules apply.
</p>
<hr title="Separator for header">
</div>
<h2 class="no-num no-toc no-ref heading settled heading" id=abstract><span class=content>Abstract</span></h2>
<p class=p-summary data-fill-with=abstract>This CSS module describes how to collate style rules and assign values to all properties on all elements. By way of cascading and inheritance, values are propagated for all properties on all elements.
<a href=http://www.w3.org/TR/CSS/>CSS</a> is a language for describing the rendering of structured documents
(such as HTML and XML)
on screen, on paper, in speech, etc.</p>
<h2 class="no-num no-toc no-ref heading settled heading" id=status><span class=content>Status of this document</span></h2>
<div data-fill-with=status><p>
<em>This section describes the status of this document at the time of its publication.
Other documents may supersede this document.
A list of current W3C publications and the latest revision of this technical report
can be found in the <a href=http://www.w3.org/TR/>W3C technical reports index at http://www.w3.org/TR/.</a></em>
<p>
Publication as a Working Draft does not imply endorsement by the W3C Membership.
This is a draft document and may be updated, replaced or obsoleted
by other documents at any time.
It is inappropriate to cite this document as other than work in progress.
<p>
The (<a href=http://lists.w3.org/Archives/Public/www-style/>archived</a>)
public mailing list <a href="mailto:www-style@w3.org?Subject=%5Bcss-cascade%5D%20PUT%20SUBJECT%20HERE">www-style@w3.org</a>
(see <a href=http://www.w3.org/Mail/Request>instructions</a>)
is preferred for discussion of this specification.
When sending e-mail,
please put the text “css-cascade” in the subject,
preferably like this:
“[css-cascade] <em>…summary of comment…</em>”
<p>
This document was produced by the <a href=/Style/CSS/members>CSS Working Group</a>
(part of the <a href=/Style/>Style Activity</a>).
<p>
This document was produced by a group operating under
the <a href=/Consortium/Patent-Policy-20040205/>5 February 2004 W3C Patent Policy</a>.
W3C maintains a <a href=/2004/01/pp-impl/32061/status rel=disclosure>public list of any patent disclosures</a>
made in connection with the deliverables of the group;
that page also includes instructions for disclosing a patent.
An individual who has actual knowledge of a patent which the individual believes contains <a href=/Consortium/Patent-Policy-20040205/#def-essential>Essential Claim(s)</a>
must disclose the information in accordance with <a href=/Consortium/Patent-Policy-20040205/#sec-Disclosure>section 6 of the W3C Patent Policy</a>.
<p>
For changes since the last draft,
see the <a href=#changes>Changes</a> section.</div>
<div data-fill-with=at-risk></div>
<h2 class="no-num no-toc no-ref heading settled heading" id=contents><span class=content>Table of Contents</span></h2>
<div data-fill-with=table-of-contents><ul class=toc>
<li><a href=#intro><span class=secno>1</span> Introduction</a>
<li><a href=#at-import><span class=secno>2</span> Importing Style Sheets: the <span class=css data-link-type=maybe title=@import>@import</span> rule</a>
<ul class=toc>
<li><a href=#content-type><span class=secno>2.1</span> Content-Type of CSS Style Sheets</a></ul>
<li><a href=#shorthand><span class=secno>3</span> Shorthand Properties</a>
<ul class=toc>
<li><a href=#all-shorthand><span class=secno>3.1</span> Resetting All Properties: the <span class=css data-link-type=maybe title=all>all</span> property</a></ul>
<li><a href=#value-stages><span class=secno>4</span> Value Processing</a>
<ul class=toc>
<li><a href=#declared><span class=secno>4.1</span> Declared Values</a>
<li><a href=#cascaded><span class=secno>4.2</span> Cascaded Values</a>
<li><a href=#specified><span class=secno>4.3</span> Specified Values</a>
<li><a href=#computed><span class=secno>4.4</span> Computed Values</a>
<li><a href=#used><span class=secno>4.5</span> Used Values</a>
<li><a href=#actual><span class=secno>4.6</span> Actual Values</a>
<li><a href=#stages-examples><span class=secno>4.7</span> Examples</a></ul>
<li><a href=#filtering><span class=secno>5</span> Filtering</a>
<li><a href=#cascading><span class=secno>6</span> Cascading</a>
<ul class=toc>
<li><a href=#cascading-origins><span class=secno>6.1</span> Cascading Origins</a>
<li><a href=#importance><span class=secno>6.2</span> Important Declarations: the <span class=css data-link-type=maybe title=!important>!important</span> annotation</a>
<li><a href=#preshint><span class=secno>6.3</span> Precedence of Non-CSS Presentational Hints</a></ul>
<li><a href=#defaulting><span class=secno>7</span> Defaulting</a>
<ul class=toc>
<li><a href=#initial-values><span class=secno>7.1</span> Initial Values</a>
<li><a href=#inheriting><span class=secno>7.2</span> Inheritance</a>
<li><a href=#defaulting-keywords><span class=secno>7.3</span> Explicit Defaulting</a>
<ul class=toc>
<li><a href=#initial><span class=secno>7.3.1</span> Resetting a Property: the <span class=css data-link-type=maybe title=initial>initial</span> keyword</a>
<li><a href=#inherit><span class=secno>7.3.2</span> Explicit Inheritance: the <span class=css data-link-type=maybe title=inherit>inherit</span> keyword</a>
<li><a href=#inherit-initial><span class=secno>7.3.3</span> Erasing All Declarations: the <span class=css data-link-type=maybe title=unset>unset</span> keyword</a></ul></ul>
<li><a href=#changes><span class=secno>8</span> Changes</a>
<ul class=toc>
<li><a href=#changes-2013><span class=secno>8.1</span> Changes Since the 30 July 2013 Last Call Working Draft</a></ul>
<li><a href=#acknowledgments><span class=secno></span>Acknowledgments</a>
<li><a href=#conformance><span class=secno></span> Conformance</a>
<ul class=toc>
<li><a href=#conventions><span class=secno></span> Document conventions</a>
<li><a href=#conformance-classes><span class=secno></span> Conformance classes</a>
<li><a href=#partial><span class=secno></span> Partial implementations</a>
<li><a href=#experimental><span class=secno></span> Experimental implementations</a>
<li><a href=#testing><span class=secno></span> Non-experimental implementations</a>
<li><a href=#cr-exit-criteria><span class=secno></span> CR exit criteria</a></ul>
<li><a href=#references><span class=secno></span> References</a>
<ul class=toc>
<li><a href=#normative><span class=secno></span> Normative References</a>
<li><a href=#informative><span class=secno></span> Informative References</a></ul>
<li><a href=#index><span class=secno></span> Index</a>
<li><a href=#property-index><span class=secno></span> Property index</a></ul></div>
<h2 class="heading settled heading" data-level=1 id=intro><span class=secno>1 </span><span class=content>
Introduction</span><a class=self-link href=#intro></a></h2>
<p>One of the fundamental design principles of CSS is <a data-link-type=dfn href=#cascade title=cascade>cascading</a>,
which allows several style sheets to influence the presentation of a document.
When different declarations try to set a value for the same element/property combination,
the conflicts must somehow be resolved.</p>
<p>The opposite problem arises when no declarations try to set a the value for an element/property combination.
In this case, a value is be found by way of <a data-link-type=dfn href=#inheritance title=inheritance>inheritance</a>
or by looking at the property’s <a data-link-type=dfn href=#initial-value title="initial value">initial value</a>.</p>
<p>The <a href=#cascade>cascading</a> and <a href=#defaulting>defaulting</a> process takes a set of declarations as input,
and outputs a <a data-link-type=dfn href=#specified-value title="specified value">specified value</a> for each property on each element.</p>
<p>The rules for finding the specified value for all properties on all elements in the document are described in this specification.
The rules for finding the specified values in the page context and its margin boxes are described in <a data-biblio-type=informative data-link-type=biblio href=#biblio-css3page title=biblio-css3page>[CSS3PAGE]</a>.</p>
<h2 class="heading settled heading" data-level=2 id=at-import><span class=secno>2 </span><span class=content>
Importing Style Sheets: the <a class=css data-link-type=maybe href=#at-ruledef-import title=@import>@import</a> rule</span><a class=self-link href=#at-import></a></h2>
<p>The <dfn class=css-code data-dfn-type=at-rule data-export="" id=at-ruledef-import>@import<a class=self-link href=#at-ruledef-import></a></dfn> rule allows users to import style rules from other style sheets.
Any <a class=css data-link-type=maybe href=#at-ruledef-import title=@import>@import</a> rules must precede all other at-rules and style rules in a style sheet
(besides <a class=css data-link-type=maybe href=http://www.w3.org/TR/css3-syntax/#at-ruledef-charset title=@charset>@charset</a>, which must be the first thing in the style sheet if it exists),
or else the <a class=css data-link-type=maybe href=#at-ruledef-import title=@import>@import</a> rule is invalid.
The syntax of <a class=css data-link-type=maybe href=#at-ruledef-import title=@import>@import</a> is:</p>
<pre class=prod>@import [ <a class="production css-code" data-link-type=type href=http://www.w3.org/TR/css3-values/#url-value title="<url>"><url></a> <a class=prod-punc data-link-type=grammar href=http://dev.w3.org/csswg/css-values-3/#comb-one title=|>|</a> <a class="production css-code" data-link-type=type href=http://www.w3.org/TR/css3-values/#string-value title="<string>"><string></a> ] <a class="production css-code" data-link-type=type href=http://dev.w3.org/csswg/mediaqueries-4/#typedef-media-query-list title="<media-query-list>"><media-query-list></a><a class=prod-punc data-link-type=grammar href=http://dev.w3.org/csswg/css-values-3/#mult-opt title=?>?</a> ;</pre>
<p>If a <a class="production css-code" data-link-type=type href=http://www.w3.org/TR/css3-values/#string-value title="<string>"><string></a> is provided,
it must be interpreted as a url with the same value.</p>
<div class=example>
The following lines are equivalent in meaning
and illustrate both <a class=css data-link-type=maybe href=#at-ruledef-import title=@import>@import</a> syntaxes
(one with <span class=css data-link-type=maybe title=url()>url()</span> and one with a bare string):
<pre>@import "mystyle.css";
@import url("mystyle.css");
</pre>
</div>
<p>If an <a class=css data-link-type=maybe href=#at-ruledef-import title=@import>@import</a> rule refers to a valid stylesheet,
user agents must treat the contents of the stylesheet as if they were written in place of the <a class=css data-link-type=maybe href=#at-ruledef-import title=@import>@import</a> rule.</p>
<p class=example>
For example, declarations in style rules from imported stylesheets interact with the cascade
as if they were written literally into the stylesheet at the point of the <a class=css data-link-type=maybe href=#at-ruledef-import title=@import>@import</a>.
Similarly, style rules in a stylesheet imported into a scoped stylesheet
are scoped in the same way.
<p>An <a class=css data-link-type=maybe href=#at-ruledef-import title=@import>@import</a> rule can be media-dependent:
such media-dependent imports include a comma-separated list of “media queries” after the URI,
which specify to which media the imported style sheet applies.
In the absence of any media query, the import is unconditional.
(Specifying <span class=css data-link-type=maybe title=all>all</span> for the medium has the same effect.)</p>
<p>The evaluation and full syntax of the expressions after the URL
is defined by the <a href=http://www.w3.org/TR/css3-mediaqueries/>Media Queries</a> specification <a data-biblio-type=normative data-link-type=biblio href=#biblio-mediaq title=biblio-mediaq>[MEDIAQ]</a>.
If the media query does not match,
the rules in the imported stylesheet do not apply,
exactly as if the imported stylesheet were wrapped in an <a class=css data-link-type=maybe href=http://dev.w3.org/csswg/css-conditional-3/#at-ruledef-media title=@media>@media</a> block with the given media query.
User agents may therefore avoid fetching a media-dependent import
as long as the media query does not match.</p>
<div class=example>
The following rules illustrate how <a class=css data-link-type=maybe href=#at-ruledef-import title=@import>@import</a> rules can be made media-dependent:
<pre>@import url("fineprint.css") print;
@import url("bluish.css") projection, tv;
@import url("narrow.css") handheld and (max-width: 400px);
</pre>
</div>
<p>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.</p>
<p class=note>Note: This does not place any requirements on resource fetching,
only how the style sheet is reflected in the CSSOM and used in specs such as this one.
Assuming appropriate caching,
it is perfectly appropriate for a UA to fetch a style sheet only once,
even though it’s linked or imported multiple times.</p>
<p>The <a data-link-type=dfn href=#origin title=origin>origin</a> of an imported style sheet is the same as the <a data-link-type=dfn href=#origin title=origin>origin</a> of the style sheet that imported it.</p>
<p>The <a data-link-type=dfn href=http://www.w3.org/TR/css3-syntax/#environment-encoding title="environment encoding">environment encoding</a> of an imported style sheet is the encoding of the style sheet that imported it. <a data-biblio-type=informative data-link-type=biblio href=#biblio-css3syn title=biblio-css3syn>[CSS3SYN]</a></p>
<h3 class="heading settled heading" data-level=2.1 id=content-type><span class=secno>2.1 </span><span class=content>
Content-Type of CSS Style Sheets</span><a class=self-link href=#content-type></a></h3>
<p>The processing of imported style sheets depends on the actual type of the linked resource.
If the resource does not have <a href=http://www.whatwg.org/specs/web-apps/current-work/multipage/fetching-resources.html#content-type>Content-Type metadata</a>,
or the host document is in <a href=http://www.whatwg.org/specs/web-apps/current-work/multipage/infrastructure.html#quirks-mode>quirks mode</a>
and has the <a href=http://www.whatwg.org/specs/web-apps/current-work/multipage/origin-0.html#same-origin>same origin</a> as the imported style sheet,
the type of the linked resource is <code>text/css</code>.
Otherwise, the type is determined from its <a href=http://www.whatwg.org/specs/web-apps/current-work/multipage/fetching-resources.html#content-type>Content-Type metadata</a>.</p>
<p>If the linked resource’s type is <code>text/css</code>,
it must be interpreted as a CSS style sheet.
Otherwise, it must be interpreted as a network error.</p>
<h2 class="heading settled heading" data-level=3 id=shorthand><span class=secno>3 </span><span class=content>
Shorthand Properties</span><a class=self-link href=#shorthand></a></h2>
<p>Some properties are <dfn data-dfn-type=dfn data-export="" id=shorthand-property title="shorthand property | shorthand">shorthand properties<a class=self-link href=#shorthand-property></a></dfn>,
133E
meaning that they allow authors to specify the values of several properties with a single property.
A <a data-link-type=dfn href=#shorthand-property title="shorthand property">shorthand property</a> sets all of its <dfn data-dfn-type=dfn data-export="" id=longhand title="longhand | longhand property | sub-property">longhand sub-properties<a class=self-link href=#longhand></a></dfn>,
exactly as if expanded in place.</p>
<div class=example>
For example, the <a class=property data-link-type=propdesc href=http://www.w3.org/TR/css-fonts-3/#propdef-font title=font>font</a> property
is a <a data-link-type=dfn href=#shorthand-property title=shorthand>shorthand</a> property for setting <a class=css-code data-link-type=property href=http://www.w3.org/TR/css-fonts-3/#propdef-font-style title=font-style>font-style</a>, <a class=css-code data-link-type=property href=http://www.w3.org/TR/css-fonts-3/#propdef-font-variant title=font-variant>font-variant</a>, <a class=css-code data-link-type=property href=http://www.w3.org/TR/css-fonts-3/#propdef-font-weight title=font-weight>font-weight</a>, <a class=property data-link-type=propdesc href=http://www.w3.org/TR/css-fonts-3/#propdef-font-size title=font-size>font-size</a>, <a class=property data-link-type=propdesc href=http://www.w3.org/TR/CSS21/visudet.html#propdef-line-height title=line-height>line-height</a>, and <a class=css-code data-link-type=property href=http://www.w3.org/TR/css-fonts-3/#propdef-font-family title=font-family>font-family</a> all at once.
The multiple declarations of this example:
<pre>h1 {
font-weight: bold;
font-size: 12pt;
line-height: 14pt;
font-family: Helvetica;
font-variant: normal;
font-style: normal;
}</pre>
<p>can therefore be rewritten as</p>
<pre>h1 { font: bold 12pt/14pt Helvetica }</pre>
</div>
<p>When values are omitted from a <a data-link-type=dfn href=#shorthand-property title=shorthand>shorthand</a> form,
unless otherwise defined,
each “missing” <a data-link-type=dfn href=#longhand title=sub-property>sub-property</a> is assigned its <a data-link-type=dfn href=#initial-value title="initial value">initial value</a>.</p>
<div class=note>
This means that a <a data-link-type=dfn href=#shorthand-property title=shorthand>shorthand</a> property declaration always sets <em title="">all</em> of its <a data-link-type=dfn href=#longhand title=sub-properties>sub-properties</a>,
even those that are not explicitly set.
Carelessly used, this might result in inadvertently resetting some <a data-link-type=dfn href=#longhand title=sub-properties>sub-properties</a>.
Carefully used, a <a data-link-type=dfn href=#shorthand-property title=shorthand>shorthand</a> can guarantee a “blank slate”
by resetting <a data-link-type=dfn href=#longhand title=sub-properties>sub-properties</a> inadvertently cascaded from other sources.
<p>For example, writing <a class=css data-link-type=propdesc href=http://www.w3.org/TR/css3-background/#background title=background>background: green</a> rather than <a class=css data-link-type=propdesc href=http://www.w3.org/TR/css3-background/#background-color title=background-color>background-color: green</a>
ensures that the background color overrides any earlier declarations
that might have set the background to an image.</p>
</div>
<p>In some cases, a <a data-link-type=dfn href=#shorthand-property title=shorthand>shorthand</a> might have different syntax
or special keywords
that don’t directly correspond to values of its <a data-link-type=dfn href=#longhand title=sub-properties>sub-properties</a>.
(In such cases, the <a data-link-type=dfn href=#shorthand-property title=shorthand>shorthand</a> will explicitly define the expansion of its values.)</p>
<p>If a <a data-link-type=dfn href=#shorthand-property title=shorthand>shorthand</a> is specified as one of the <a href=http://www.w3.org/TR/css3-values/#common-keywords>CSS-wide keywords</a> <a data-biblio-type=normative data-link-type=biblio href=#biblio-css3val title=biblio-css3val>[CSS3VAL]</a>,
it sets all of its <a data-link-type=dfn href=#longhand title=sub-properties>sub-properties</a> to that keyword.
(Note that these keywords cannot be combined with other values in a single declaration, not even in a shorthand.)</p>
<p>Declaring a <a data-link-type=dfn href=#shorthand-property title=shorthand>shorthand</a> property to be <a class=css data-link-type=maybe href=#important title=!important>!important</a>
is equivalent to declaring all of its <a data-link-type=dfn href=#longhand title=sub-properties>sub-properties</a> to be <a class=css data-link-type=maybe href=#important title=!important>!important</a>.</p>
<h3 class="heading settled heading" data-level=3.1 id=all-shorthand><span class=secno>3.1 </span><span class=content>
Resetting All Properties: the <span class=css data-link-type=maybe title=all>all</span> property</span><a class=self-link href=#all-shorthand></a></h3>
<table class=propdef>
<tr>
<th>Name:
<td><dfn class=css-code data-dfn-type=property data-export="" id=propdef-all>all<a class=self-link href=#propdef-all></a></dfn><tr>
<th>Value:
<td>initial | inherit | unset
<tr>
<th>Initial:
<td>See individual properties
<tr>
<th>Applies to:
<td>See individual properties
<tr>
<th>Inherited:
<td>See individual properties
<tr>
<th>Percentages:
<td>See individual properties
<tr>
<th>Media:
<td>See individual properties
<tr>
<th>Computed value:
<td>See individual properties
<tr>
<th>Animatable:
<td>See individual properties
</table>
<p>The <span class=css data-link-type=maybe title=all>all</span> property is a <a data-link-type=dfn href=#shorthand-property title=shorthand>shorthand</a> that resets <em title="">all</em> CSS properties
except <a class=property data-link-type=propdesc href=http://www.w3.org/TR/css3-writing-modes/#propdef-direction title=direction>direction</a> and <a class=property data-link-type=propdesc href=http://www.w3.org/TR/css3-writing-modes/#propdef-unicode-bidi title=unicode-bidi>unicode-bidi</a>.
It only accepts the <a href=http://www.w3.org/TR/css3-values/#common-keywords>CSS-wide keywords</a>.</p>
<p class=note>Note: The excepted properties are actually markup-level features,
and <a href=http://www.w3.org/TR/css3-writing-modes/#text-direction>should not be set in the author’s style sheet</a>.
(They exist as CSS properties only to style document languages not supported by the UA.)
Authors should use the appropriate markup, such as HTML’s <code>dir</code> attribute, instead.
<a data-biblio-type=informative data-link-type=biblio href=#biblio-css3-writing-modes title=biblio-css3-writing-modes>[CSS3-WRITING-MODES]</a></p>
<div class=example>
For example, if an author specifies <a class=css data-link-type=propdesc href=#propdef-all title=all>all: initial</a> on an element
it will block all inheritance and reset all properties,
as if no rules appeared in the author, user, or user-agent levels of the cascade.
<p>This can be useful for the root element of a "widget" included in a page,
which does not wish to inherit the styles of the outer page.
Note, however, that any "default" style applied to that element
(such as, e.g. <a class=css data-link-type=propdesc href=http://www.w3.org/TR/CSS21/visuren.html#propdef-display title=display>display: block</a> from the UA style sheet on block elements such as <code><div></code>)
will also be blown away.</p>
</div>
<h2 class="heading settled heading" data-level=4 id=value-stages><span class=secno>4 </span><span class=content>
Value Processing</span><a class=self-link href=#value-stages></a></h2>
<p>Once a user agent has parsed a document and constructed a document tree,
it must assign,
to every element in the tree,
and correspondingly to every box in the formatting structure,
a value to every property that applies to the target media type.</p>
<p>The final value of a CSS property for a given element or box
is the result of a multi-step calculation:</p>
<ul>
<li>
First, all the <a data-link-type=dfn href=#declared-value title="declared values">declared values</a> applied to an element are collected,
for each property on each element.
There may be zero or many <a data-link-type=dfn href=#declared-value title="declared values">declared values</a> applied to the element.
<li>
Cascading yields the <a data-link-type=dfn href=#cascaded-value title="cascaded value">cascaded value</a>.
There is at most one <a data-link-type=dfn href=#cascaded-value title="cascaded value">cascaded value</a> per property per element.
<li>
Defaulting yields the <a data-link-type=dfn href=#specified-value title="specified value">specified value</a>.
Every element has exactly one <a data-link-type=dfn href=#specified-value title="specified value">specified value</a> per property.
<li>
Resolving value dependencies yields the <a data-link-type=dfn href=#computed-value title="computed value">computed value</a>.
Every element has exactly one <a data-link-type=dfn href=#computed-value title="computed value">computed value</a> per property.
<li>
Formatting the document yields the <a data-link-type=dfn href=#used-value title="used value">used value</a>.
An element only has a <a data-link-type=dfn href=#used-value title="used value">used value</a> for a given property
if that property applies to the element.
<li>
Finally, the used value is transformed to the <a data-link-type=dfn href=#actual-value title="actual value">actual value</a>
based on constraints of the display environment.
As with the <a data-link-type=dfn href=#used-value title="used value">used value</a>, there may or may not be an <a data-link-type=dfn href=#actual-value title="actual value">actual value</a>
for a given property on an element.
</ul>
<h3 class="heading settled heading" data-level=4.1 id=declared><span class=secno>4.1 </span><span class=content>
Declared Values</span><a class=self-link href=#declared></a></h3>
<p>Each property declaration <a href=#filtering>applied to an element</a>
contributes a <dfn data-dfn-type=dfn data-export="" id=declared-value>declared value<a class=self-link href=#declared-value></a></dfn> for that property
associated with the element.
See <a href=#filtering>Filtering Declarations</a> for details.</p>
<p>These values are then processed by the <a data-link-type=dfn href=#cascade title=cascade>cascade</a>
to choose a single “winning value”.</p>
<h3 class="heading settled heading" data-level=4.2 id=cascaded><span class=secno>4.2 </span><span class=content>
Cascaded Values</span><a class=self-link href=#cascaded></a></h3>
<p>The <dfn data-dfn-type=dfn data-export="" id=cascaded-value>cascaded value<a class=self-link href=#cascaded-value></a></dfn> represents the result of <a href=#cascade>the cascade</a>:
it is the <a data-link-type=dfn href=#declared-value title="declared value">declared value</a> that wins the cascade
(is sorted first in the <a data-link-type=dfn href=#output-of-the-cascade title="output of the cascade">output of the cascade</a>).
If the <a data-link-type=dfn href=#output-of-the-cascade title="output of the cascade">output of the cascade</a> is an empty list,
there is no <a data-link-type=dfn href=#cascaded-value title="cascaded value">cascaded value</a>.</p>
<h3 class="heading settled heading" data-level=4.3 id=specified><span class=secno>4.3 </span><span class=content>
Specified Values</span><a class=self-link href=#specified></a></h3>
<p>The <dfn data-dfn-type=dfn data-export="" id=specified-value>specified value<a class=self-link href=#specified-value></a></dfn> the value of a given property that the style sheet authors intended for that element.
It is the result of putting the <a data-link-type=dfn href=#cascaded-value title="cascaded value">cascaded value</a> through the <a href=#defaulting>defaulting</a> processes,
guaranteeing that a <a data-link-type=dfn href=#specified-value title="specified value">specified value</a> exists for every property on every element.</p>
<p>In many cases, the <a data-link-type=dfn href=#specified-value title="specified value">specified value</a> is the <a data-link-type=dfn href=#cascaded-value title="cascaded value">cascaded value</a>.
However, if there is no <a data-link-type=dfn href=#cascaded-value title="cascaded value">cascaded value</a> at all,
the <a data-link-type=dfn href=#specified-value title="specified value">specified value</a> is <a href=#defaulting>defaulted</a>.
The <a class=css data-link-type=maybe href=#valuedef-initial title=initial>initial</a> and <a class=css data-link-type=maybe href=#valuedef-inherit title=inherit>inherit</a> keywords
are handled specially when they are the <a data-link-type=dfn href=#cascaded-value title="cascaded value">cascaded value</a> of a property,</p>
<h3 class="heading settled heading" data-level=4.4 id=computed><span class=secno>4.4 </span><span class=content>
Computed Values</span><a class=self-link href=#computed></a></h3>
<p>The <dfn data-dfn-type=dfn data-export="" id=computed-value>computed value<a class=self-link href=#computed-value></a></dfn> is the result of resolving the <a data-link-type=dfn href=#specified-value title="specified value">specified value</a>
as defined in the “Computed Value” line of the property definition table,
generally absolutizing it in preparation for <a data-link-type=dfn href=#inheritance title=inheritance>inheritance</a>.</p>
<p class=note>Note: The <a data-link-type=dfn href=#computed-value title="computed value">computed value</a> is the value that is transferred from parent to child during <a data-link-type=dfn href=#inheritance title=inheritance>inheritance</a>.
For historical reasons,
it is not necessarily the value returned by the <code>getComputedStyle()</code> function.</p>
<div class=example>
A <a data-link-type=dfn href=#specified-value title="specified value">specified value</a> can be either absolute (i.e., not relative to another value, as in <span class=css data-link-type=maybe title=red>red</span> or <span class=css data-link-type=maybe title=2mm>2mm</span>)
or relative (i.e., relative to another value, as in <span class=css data-link-type=maybe title=auto>auto</span>, <span class=css data-link-type=maybe title=2em>2em</span>).
Computing a relative value generally absolutizes it:
<ul>
<li>
values with relative units
(<a class=css data-link-type=maybe href=http://dev.w3.org/csswg/css-values-3/#em title=em>em</a>, <a class=css data-link-type=maybe href=http://dev.w3.org/csswg/css-values-3/#ex title=ex>ex</a>, <a class=css data-link-type=maybe href=http://dev.w3.org/csswg/css-values-3/#vh title=vh>vh</a>, <a class=css data-link-type=maybe href=http://dev.w3.org/csswg/css-values-3/#vw title=vw>vw</a>)
must be made absolute by multiplying with the appropriate reference size
<li>
certain keywords
(e.g., <span class=css data-link-type=maybe title=smaller>smaller</span>, <span class=css data-link-type=maybe title=bolder>bolder</span>)
must be replaced according to their definitions
<li>
percentages on some properties must be multiplied by a reference value
(defined by the property)
<li>
valid relative URLs must be resolved to become absolute.
</ul>
<p>See examples (f), (g) and (h) in the <a href=#stages-examples>table below</a>.</p>
</div>
<p class=note>Note: In general, the <a data-link-type=dfn href=#computed-value title="computed value">computed value</a> resolves the <a data-link-type=dfn href=#specified-value title="specified value">specified value</a>
as far as possible without laying out the document
or performing other expensive or hard-to-parallelize operations,
such as resolving network requests
or retrieving values other than from the element and its parent.</p>
<p>The <a data-link-type=dfn href=#computed-value title="computed value">computed value</a> exists even when the property does not apply
(as defined by the “Applies To” line).
However, some properties may change how they determine the <a data-link-type=dfn href=#computed-value title="computed value">computed value</a>
based on whether the property applies to the element.</p>
<h3 class="heading settled heading" data-level=4.5 id=used><span class=secno>4.5 </span><span class=content>
Used Values</span><a class=self-link href=#used></a></h3>
<p>The <dfn data-dfn-type=dfn data-export="" id=used-value>used value<a class=self-link href=#used-value></a></dfn> is the result of taking the <a data-link-type=dfn href=#computed-value title="computed value">computed value</a>
and completing any remaining calculations to make it the absolute theoretical value
used in the layout of the document.
If the property does not apply to this element,
then the element has no <a data-link-type=dfn href=#used-value title="used value">used value</a> for that property.</p>
<p class=example>
For example, a declaration of <a class=css
6D50
data-link-type=propdesc href=http://www.w3.org/TR/CSS21/visudet.html#propdef-width title=width>width: auto</a> can’t be resolved into a length without knowing the layout of the element’s ancestors,
so the <a data-link-type=dfn href=#computed-value title="computed value">computed value</a> is <span class=css data-link-type=maybe title=auto>auto</span>,
while the <a data-link-type=dfn href=#used-value title="used value">used value</a> is an absolute length, such as <span class=css data-link-type=maybe title=100px>100px</span>. <a data-biblio-type=informative data-link-type=biblio href=#biblio-css21 title=biblio-css21>[CSS21]</a>
<p class=example>
As another example, a <code><div></code> might have a computed <a class=property data-link-type=propdesc href=http://www.w3.org/TR/css3-break/#break-before title=break-before>break-before</a> value of <span class=css data-link-type=maybe title=auto>auto</span>,
but acquire a used <a class=property data-link-type=propdesc href=http://www.w3.org/TR/css3-break/#break-before title=break-before>break-before</a> value of <span class=css data-link-type=maybe title=page>page</span> by propagation from its first child. <a data-biblio-type=informative data-link-type=biblio href=#biblio-css3-break title=biblio-css3-break>[CSS3-BREAK]</a>
<p class=example>
Lastly, if a property does not apply to an element,
it has no <a data-link-type=dfn href=#used-value title="used value">used value</a>;
so, for example, the <a class=property data-link-type=propdesc href=http://www.w3.org/TR/css3-flexbox/#propdef-flex title=flex>flex</a> property has no <a data-link-type=dfn href=#used-value title="used value">used value</a>
on elements that aren’t <a data-link-type=dfn href=http://www.w3.org/TR/css3-flexbox/#flex-item title="flex items">flex items</a>.
<h3 class="heading settled heading" data-level=4.6 id=actual><span class=secno>4.6 </span><span class=content>
Actual Values</span><a class=self-link href=#actual></a></h3>
<p>A <a data-link-type=dfn href=#used-value title="used value">used value</a> is in principle ready to be used,
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 have to approximate the <a data-link-type=dfn href=#used-value title="used value">used</a> width.
Also, the font size of an element may need adjustment based on the availability of fonts
or the value of the <a class=property data-link-type=propdesc href=http://www.w3.org/TR/css-fonts-3/#propdef-font-size-adjust title=font-size-adjust>font-size-adjust</a> property.
The <dfn data-dfn-type=dfn data-export="" id=actual-value>actual value<a class=self-link href=#actual-value></a></dfn> is the used value after any such adjustments have been made.</p>
<p class=note>Note: By probing the actual values of elements,
much can be learned about how the document is laid out.
However, not all information is recorded in the actual values.
For example, the actual value of the <a class=property data-link-type=propdesc href=http://www.w3.org/TR/CSS21/page.html#propdef-page-break-after title=page-break-after>page-break-after</a> property
does not reflect whether there is a page break or not after the element.
Similarly, the actual value of <a class=property data-link-type=propdesc href=http://www.w3.org/TR/css3-break/#orphans title=orphans>orphans</a>
does not reflect how many orphan lines there is in a certain element.
See examples (j) and (k) in the <a href=#stages-examples>table below</a>.</p>
<h3 class="heading settled heading" data-level=4.7 id=stages-examples><span class=secno>4.7 </span><span class=content>
Examples</span><a class=self-link href=#stages-examples></a></h3>
<table class=data>
<thead>
<tr>
<th>
<th>Property
<th>Winning declaration
<th>Cascaded value
<th>Specified value
<th>Computed value
<th>Used value
<th>Actual value
<tbody>
<tr>
<td>(a)
<th><a class=property data-link-type=propdesc href=http://www.w3.org/TR/css3-text/#text-align title=text-align>text-align</a>
<td><code class=declaration>text-align: left</code>
<td><a class=css data-link-type=maybe href=http://www.w3.org/TR/css3-writing-modes/#left title=left>left</a>
<td><a class=css data-link-type=maybe href=http://www.w3.org/TR/css3-writing-modes/#left title=left>left</a>
<td><a class=css data-link-type=maybe href=http://www.w3.org/TR/css3-writing-modes/#left title=left>left</a>
<td><a class=css data-link-type=maybe href=http://www.w3.org/TR/css3-writing-modes/#left title=left>left</a>
<td><a class=css data-link-type=maybe href=http://www.w3.org/TR/css3-writing-modes/#left title=left>left</a>
<tr>
<td>(b)
<th><a class=property data-link-type=propdesc href=http://www.w3.org/TR/css3-background/#border-top-width title=border-top-width>border-top-width</a>, <a class=property data-link-type=propdesc href=http://www.w3.org/TR/css3-background/#border-right-width title=border-right-width>border-right-width</a>, <a class=property data-link-type=propdesc href=http://www.w3.org/TR/css3-background/#border-bottom-width title=border-bottom-width>border-bottom-width</a>, <a class=property data-link-type=propdesc href=http://www.w3.org/TR/css3-background/#border-left-width title=border-left-width>border-left-width</a>
<td><code class=declaration>border-width: inherit</code>
<td><a class=css data-link-type=maybe href=#valuedef-inherit title=inherit>inherit</a>
<td class=say><span class=css data-link-type=maybe title=4.2px>4.2px</span>
<td><span class=css data-link-type=maybe title=4.2px>4.2px</span>
<td><span class=css data-link-type=maybe title=4.2px>4.2px</span>
<td><span class=css data-link-type=maybe title=4px>4px</span>
<tr>
<td>(c)
<th><a class=property data-link-type=propdesc href=http://www.w3.org/TR/CSS21/visudet.html#propdef-width title=width>width</a>
<td><small>(none)</small>
<td><small>(none)</small>
<td><span class=css data-link-type=maybe title=auto>auto</span> <small>(initial value)</small>
<td><span class=css data-link-type=maybe title=auto>auto</span>
<td><span class=css data-link-type=maybe title=120px>120px</span>
<td><span class=css data-link-type=maybe title=120px>120px</span>
<tr>
<td>(d)
<th><a class=property data-link-type=propdesc href=http://www.w3.org/TR/css3-lists/#propdef-list-style-position title=list-style-position>list-style-position</a>
<td><code class=declaration>list-style-position: inherit</code>
<td><a class=css data-link-type=maybe href=#valuedef-inherit title=inherit>inherit</a>
<td class=say><span class=css data-link-type=maybe title=inside>inside</span>
<td><span class=css data-link-type=maybe title=inside>inside</span>
<td><span class=css data-link-type=maybe title=inside>inside</span>
<td><span class=css data-link-type=maybe title=inside>inside</span>
<tr>
<td>(e)
<th><a class=property data-link-type=propdesc href=http://www.w3.org/TR/css3-lists/#propdef-list-style-position title=list-style-position>list-style-position</a>
<
9E70
td><code class=declaration>list-style-position: initial</code>
<td><a class=css data-link-type=maybe href=#valuedef-initial title=initial>initial</a>
<td><span class=css data-link-type=maybe title=outside>outside</span> <small>(initial value)</small>
<td><span class=css data-link-type=maybe title=outside>outside</span>
<td><span class=css data-link-type=maybe title=outside>outside</span>
<td><span class=css data-link-type=maybe title=outside>outside</span>
<tr>
<td>(f)
<th><a class=property data-link-type=propdesc href=http://www.w3.org/TR/css-fonts-3/#propdef-font-size title=font-size>font-size</a>
<td><code class=declaration>font-size: 1.2em</code>
<td><span class=css data-link-type=maybe title=1.2em>1.2em</span>
<td><span class=css data-link-type=maybe title=1.2em>1.2em</span>
<td class=say><span class=css data-link-type=maybe title=14.1px>14.1px</span>
<td><span class=css data-link-type=maybe title=14.1px>14.1px</span>
<td><span class=css data-link-type=maybe title=14px>14px</span>
<tr>
<td>(g)
<th><a class=property data-link-type=propdesc href=http://www.w3.org/TR/CSS21/visudet.html#propdef-width title=width>width</a>
<td><code class=declaration>width: 80%</code>
<td><span class=css data-link-type=maybe title=80%>80%</span>
<td><span class=css data-link-type=maybe title=80%>80%</span>
<td><span class=css data-link-type=maybe title=80%>80%</span>
<td class=say><span class=css data-link-type=maybe title=354.2px>354.2px</span>
<td><span class=css data-link-type=maybe title=354px>354px</span>
<tr>
<td>(h)
<th><a class=property data-link-type=propdesc href=http://www.w3.org/TR/CSS21/visudet.html#propdef-width title=width>width</a>
<td><code class=declaration>width: auto</code>
<td><span class=css data-link-type=maybe title=auto>auto</span>
<td><span class=css data-link-type=maybe title=auto>auto</span>
<td><span class=css data-link-type=maybe title=auto>auto</span>
<td class=say><span class=css data-link-type=maybe title=134px>134px</span>
<td><span class=css data-link-type=maybe title=134px>134px</span>
<tr>
<td>(i)
<th><a class=property data-link-type=propdesc href=http://www.w3.org/TR/CSS21/visudet.html#propdef-height title=height>height</a>
<td><code class=declaration>height: auto</code>
<td><span class=css data-link-type=maybe title=auto>auto</span>
<td><span class=css data-link-type=maybe title=auto>auto</span>
<td><span class=css data-link-type=maybe title=auto>auto</span>
<td class=say><span class=css data-link-type=maybe title=176px>176px</span>
<td><span class=css data-link-type=maybe title=176px>176px</span>
<tr>
<td>(j)
<th><a class=property data-link-type=propdesc href=http://www.w3.org/TR/CSS21/page.html#propdef-page-break-after title=page-break-after>page-break-after</a>
<td><small>(none)</small>
<td><small>(none)</small>
<td><span class=css data-link-type=maybe title=auto>auto</span> <small>(initial value)</small>
<td><span class=css data-link-type=maybe title=auto>auto</span>
<td><span class=css data-link-type=maybe title=auto>auto</span>
<td><span class=css data-link-type=maybe title=auto>auto</span>
<tr>
<td>(k)
<th><a class=property data-link-type=propdesc href=http://www.w3.org/TR/css3-break/#orphans title=orphans>orphans</a>
<td><code class=declaration>orphans: 3</code>
<td><span class=css data-link-type=maybe title=3>3</span>
<td><span class=css data-link-type=maybe title=3>3</span>
<td><span class=css data-link-type=maybe title=3>3</span>
<td><span class=css data-link-type=maybe title=3>3</span>
<td><span class=css data-link-type=maybe title=3>3</span>
</table>
<h2 class="heading settled heading" data-level=5 id=filtering><span class=secno>5 </span><span class=content>
Filtering</span><a class=self-link href=#filtering></a></h2>
<p>In order to find the <a data-link-type=dfn href=#declared-value title="declared values">declared values</a>,
implementations must first identify all declarations that apply to each element.
A declaration applies to an element if:</p>
<ul>
<li>
It belongs to a style sheet that currently applies to this document.
<li>
It is not qualified by a conditional rule <a data-biblio-type=normative data-link-type=biblio href=#biblio-css3-conditional title=biblio-css3-conditional>[CSS3-CONDITIONAL]</a> with a false condition.
<li>
It belongs to a style rule whose selector matches the element. <a data-biblio-type=normative data-link-type=biblio href=#biblio-select title=biblio-select>[SELECT]</a>
(Taking <a href=http://www.w3.org/TR/selectors4/#scoping>scoping</a> into account, if necessary.)
<li>
It is syntactically valid:
the declaration’s property is a known property name,
and the declaration’s value matches the syntax for that property.
</ul>
<p>The values of the declarations that apply form,
for each property on each element,
a list of <a data-link-type=dfn href=#declared-value title="declared values">declared values</a>.
The next section,
the <a data-link-type=dfn href=#cascade title=cascade>cascade</a>,
prioritizes these lists.</p>
<h2 class="heading settled heading" data-level=6 id=cascading><span class=secno>6 </span><span class=content>
Cascading</span><a class=self-link href=#cascading></a></h2>
<p>The <dfn data-dfn-type=dfn data-export="" id=cascade>cascade<a class=self-link href=#cascade></a></dfn>
takes a unordered list of <a data-link-type=dfn href=#declared-value title="declared values">declared values</a>
for a given property on a given element,
sorts them by their declaration’s precedence as determined below,
and outputs a single <a data-link-type=dfn href=#cascaded-value title="cascaded value">cascaded value</a>.</p>
<p>The cascade sorts declarations according to the following criteria,
in descending order of priority:</p>
<dl>
<dt id=cascade-origin><a class=self-link href=#cascade-origin></a>Origin and Importance
<dd>
The <a data-link-type=dfn href=#origin title=origin>origin</a> of a declaration is based on where it comes from
and its <a data-link-type=dfn href=#important0 title=important>importance</a> is whether or not it is declared <a class=css data-link-type=maybe href=#important title=!important>!important</a> (see below).
The precedence of the various <a data-link-type=dfn href=#origin title=origins>origins</a> is, in descending order:
<ol>
<li>Transition declarations <a data-biblio-type=normative data-link-type=biblio href=#biblio-css3-transitions title=biblio-css3-transitions>[CSS3-TRANSITIONS]</a>
<li>Important user agent declarations
<li>Important user declarations
<li>Important override declarations <a data-biblio-type=normative data-link-type=biblio href=#biblio-dom-level-2-style title=biblio-dom-level-2-style>[DOM-LEVEL-2-STYLE]</a>
<li>Important author declarations
<li>Animation declarations <a data-biblio-type=normative data-link-type=biblio href=#biblio-css3-animations title=biblio-css3-animations>[CSS3-ANIMATIONS]</a>
<li>Normal override declarations <a data-biblio-type=normative data-link-type=biblio href=#biblio-dom-level-2-style title=biblio-dom-level-2-style>[DOM-LEVEL-2-STYLE]</a>
<li>Normal author declarations
<li>Normal user declarations
<li>Normal user agent declarations
</ol>
<p>Declarations from <a data-link-type=dfn href=#origin title=origins>origins</a> earlier in this list win over declarations from later <a data-link-type=dfn href=#origin title=origins>origins</a>.</p>
<dt id=cascade-scope><a class=self-link href=#cascade-scope></a>Scope
<dd>
A declaration can be <dfn data-dfn-type=dfn data-export="" id=scoped>scoped<a class=self-link href=#scoped></a></dfn> to a subtree of the document
so that it only affects its <dfn data-dfn-type=dfn data-export="" id=scoping-element>scoping element<a class=self-link href=#scoping-element></a></dfn> and that element’s descendants.
For example, <a data-biblio-type=informative data-link-type=biblio href=#biblio-html5 title=biblio-html5>[HTML5]</a> defines scoped <code><style></code> elements,
whose style sheets are scoped to the element’s parent.
<p>If the <a data-link-type=dfn href=#scoping-element title="scoping elements">scoping elements</a> of
6D50
two declarations
have an ancestor/descendant relationship,
then for normal rules the declaration whose <a data-link-type=dfn href=#scoping-element title="scoping element">scoping element</a> is the descendant wins,
and for important rules the declaration whose <a data-link-type=dfn href=#scoping-element title="scoping element">scoping element</a> is the ancestor wins.</p>
<p class=note>Note: In other words, for normal declarations the inner scope’s declarations override,
but for <code>!important</code> rules <em>outer</em> scope’s override.</p>
<p>For the purpose of this step,
all unscoped declarations are considered to be <a data-link-type=dfn href=#scoped title=scoped>scoped</a> to the root element.
Normal declarations from style attributes
are considered to be <a data-link-type=dfn href=#scoped title=scoped>scoped</a> to the element with the attribute,
whereas important declarations from style attributes
are considered to be <a data-link-type=dfn href=#scoped title=scoped>scoped</a> to the root element.
<a data-biblio-type=normative data-link-type=biblio href=#biblio-cssstyleattr title=biblio-cssstyleattr>[CSSSTYLEATTR]</a></p>
<p class=note>Note: This odd handling of <code>!important</code> style attribute declarations
is to match the behavior defined in CSS Levels 1 and 2,
where style attributes simply have higher specificity than any other author rules. <a data-biblio-type=informative data-link-type=biblio href=#biblio-css21 title=biblio-css21>[CSS21]</a></p>
<dt id=cascade-specificity><a class=self-link href=#cascade-specificity></a>Specificity
<dd>
The <a href=http://www.w3.org/TR/selectors/#specificity>Selectors module</a> <a data-biblio-type=normative data-link-type=biblio href=#biblio-select title=biblio-select>[SELECT]</a> describes how to compute the specificity of a selector.
Each declaration has the same specificity as the style rule it appears in.
For the purpose of this step,
declarations that do not belong to a style rule
(such as the <a href=http://www.w3.org/TR/css-style-attr/#interpret>contents of a style attribute</a>)
are considered to have a specificity higher than any selector.
The declaration with the highest specificity wins.
<dt id=cascade-order><a class=self-link href=#cascade-order></a>Order of Appearance
<dd>
The last declaration in document order wins.
For this purpose:
<ul>
<li>Declarations from <a class=css-code data-link-type=at-rule href=#at-ruledef-import title=@import>imported style sheets</a>
are ordered as if their style sheets were substituted in place of the <a class=css data-link-type=maybe href=#at-ruledef-import title=@import>@import</a> rule.
<li>Declarations from style sheets independently linked by the originating document
are treated as if they were concatenated in linking order,
as determined by the host document language.
<li>Declarations from style attributes
are ordered according to the document order of the element the style attribute appears on,
and are all placed after any style sheets.
</ul>
</dl>
<p>The <dfn data-dfn-type=dfn data-noexport="" id=output-of-the-cascade>output of the cascade<a class=self-link href=#output-of-the-cascade></a></dfn>
is a (potentially empty) sorted list of <a data-link-type=dfn href=#declared-value title="declared values">declared values</a> for each property on each element.</p>
<h3 class="heading settled heading" data-level=6.1 id=cascading-origins><span class=secno>6.1 </span><span class=content>
Cascading Origins</span><a class=self-link href=#cascading-origins></a></h3>
<p>Each style rule has an <dfn data-dfn-type=dfn data-export="" id=origin>origin<a class=self-link href=#origin></a></dfn>,
which determines where it enters the cascade.
CSS defines three core <a data-link-type=dfn href=#origin title=origins>origins</a>:</p>
<dl>
<dt id=cascade-origin-author><a class=self-link href=#cascade-origin-author></a>Author
<dd>
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.
<dt id=cascade-origin-user><a class=self-link href=#cascade-origin-user></a>User
<dd>
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 behaves as if it did).
<dt id=cascade-origin-ua><a class=self-link href=#cascade-origin-ua></a>User agent
<dd>
Conforming user agents must apply a default style sheet
(or behave as if they did).
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 e.g. the <a href=http://www.whatwg.org/specs/web-apps/current-work/multipage/rendering.html#the-css-user-agent-style-sheet-and-presentational-hints>HTML user agent style sheet</a>. <a data-biblio-type=informative data-link-type=biblio href=#biblio-html5 title=biblio-html5>[HTML5]</a>
</dl>
<p>Extensions to CSS define the following additional <a data-link-type=dfn href=#origin title=origins>origins</a>:</p>
<dl>
<dt id=cascade-origin-override><a class=self-link href=#cascade-origin-override></a>Override
<dd>
DOM Level 2 Style <a data-biblio-type=normative data-link-type=biblio href=#biblio-dom-level-2-style title=biblio-dom-level-2-style>[DOM-LEVEL-2-STYLE]</a> defines an interface for “override” styles,
which enter the cascade at a higher level than other author rules.
<dt id=cascade-origin-animation><a class=self-link href=#cascade-origin-animation></a>Animation
<dd>
CSS Animations <a data-biblio-type=informative data-link-type=biblio href=#biblio-css3-animations title=biblio-css3-animations>[CSS3-ANIMATIONS]</a> generate “virtual” rules representing their effects when running.
<dt id=cascade-origin-transition><a class=self-link href=#cascade-origin-transition></a>Transition
<dd>
Like CSS Animations, CSS Transitions <a data-biblio-type=informative data-link-typ
9E70
e=biblio href=#biblio-css3-transitions title=biblio-css3-transitions>[CSS3-TRANSITIONS]</a> generate “virtual” rules representing their effects when running.
</dl>
<h3 class="heading settled heading" data-level=6.2 id=importance><span class=secno>6.2 </span><span class=content>
Important Declarations: the <a class=css data-link-type=maybe href=#important title=!important>!important</a> annotation</span><a class=self-link href=#importance></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,
which override those in the user-agent’s default style sheet.
To balance this, a declaration can be made <dfn data-dfn-type=dfn data-export="" id=important0>important<a class=self-link href=#important0></a></dfn>,
which increases its weight in the cascade and inverts the order of precedence.</p>
<p>A declaration is <a data-link-type=dfn href=#important0 title=important>important</a> if it has a <dfn data-dfn-type=dfn data-export="" id=important>!important<a class=self-link href=#important></a></dfn> annotation,
as defined by <a data-biblio-type=informative data-link-type=biblio href=#biblio-css3syn title=biblio-css3syn>[CSS3SYN]</a>.
i.e. if the last two (non-whitespace, non-comment) tokens
in its value are the delimiter token <span class=css data-link-type=maybe title=!>!</span> followed by the identifier token <a class=css data-link-type=maybe href=#important0 title=important>important</a>.</p>
<div class=example>
<pre>[hidden] { display: none !important; }</pre>
</div>
<p>An <a data-link-type=dfn href=#important0 title=important>important</a> declaration takes precedence over a normal declaration.
Author and user style sheets may contain <a class=css data-link-type=maybe href=#important title=!important>!important</a> declarations,
with user <a class=css data-link-type=maybe href=#important title=!important>!important</a> declarations overriding author <a class=css data-link-type=maybe href=#important title=!important>!important</a> declarations.
This CSS feature improves accessibility of documents by giving users with special requirements
(large fonts, color combinations, etc.)
control over presentation.</p>
<p>Important declarations from all origins take precedence over animations.
This allows authors to override animated values in important cases.
(Animated values normally override all other rules.)
<a data-biblio-type=informative data-link-type=biblio href=#biblio-css3-animations title=biblio-css3-animations>[CSS3-ANIMATIONS]</a></p>
<p>User agent style sheets may also contain <a class=css data-link-type=maybe href=#important title=!important>!important</a> declarations.
These override all author and user declarations.</p>
<div class=example>
The first rule in the user’s style sheet in the following example contains an <a class=css data-link-type=maybe href=#important title=!important>!important</a> declaration,
which overrides the corresponding declaration in the author’s style sheet.
The declaration in the second rule will also win due to being marked <a class=css data-link-type=maybe href=#important title=!important>!important</a>.
However, the third declaration in the user’s style sheet is not <a class=css data-link-type=maybe href=#important title=!important>!important</a>
and will therefore lose to the second rule in the author’s style sheet
(which happens to set style on a <a data-link-type=dfn href=#shorthand-property title=shorthand>shorthand</a> property).
Also, the third author rule will lose to the second author rule since the second declaration is <a class=css data-link-type=maybe href=#important title=!important>!important</a>.
This shows that <a class=css data-link-type=maybe href=#important title=!important>!important</a> 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: normal 12pt sans-serif !important }
p { font-size: 24pt }
</pre>
</div>
<h3 class="heading settled heading" data-level=6.3 id=preshint><span class=secno>6.3 </span><span class=content>
Precedence of Non-CSS Presentational Hints</span><a class=self-link href=#preshint></a></h3>
<p>The UA may choose to honor presentational hints in a source document’s markup,
for example the <code>bgcolor</code> attribute or <code><s></code> element in <a data-biblio-type=informative data-link-type=biblio href=#biblio-html5 title=biblio-html5>[HTML5]</a>.
All document language-based styling must be translated to corresponding CSS rules
and either enter the cascade at the user agent level or
be treated as author level rules with a specificity of zero placed at the start of the author style sheet.
A document language may define whether a presentational hint enters at the UA or author level of the cascade;
if so, the UA must behave accordingly.
For example, <a data-biblio-type=informative data-link-type=biblio href=#biblio-svg11 title=biblio-svg11>[SVG11]</a> maps its presentation attributes into the author level.</p>
<p>Presentational hints entering the cascade at the author level can be overridden by author styles,
but not by non-<code>!important</code> user styles.
Host languages should choose the appropriate level for presentational hints with these considerations in mind.</p>
<h2 class="heading settled heading" data-level=7 id=defaulting><span class=secno>7 </span><span class=content>
Defaulting</span><a class=self-link href=#defaulting></a></h2>
<p>When the <a data-link-type=dfn href=#cascade title=cascade>cascade</a> does not result in a value,
the <a data-link-type=dfn href=#specified-value title="specified value">specified value</a> must be found some other way.
<a data-link-type=dfn href=#inherited-property title="inherited properties">Inherited properties</a> draw their defaults from their parent element through <a data-link-type=dfn href=#inheritance title=inheritance>inheritance</a>;
all other properties take their <a data-link-type=dfn href=#initial-value title="initial value">initial value</a>.
Authors can explicitly request inheritance or initialization
via the <a class=css data-link-type=maybe href=#valuedef-inherit title=inherit>inherit</a> and <a class=css data-link-type=maybe href=#valuedef-initial title=initial>initial</a> keywords.</p>
<h3 class="heading settled heading" data-level=7.1 id=initial-values><span class=secno>7.1 </span><span class=content>
Initial Values</span><a class=self-link href=#initial-values></a></h3>
<p>Each property has an <dfn data-dfn-type=dfn data-export="" id=initial-value>initial value<a class=self-link href=#initial-value></a></dfn>,
defined in the property’s definition table.
If the property is not an <a data-link-type=dfn href=#inherited-property title="inherited property">inherited property</a>,
and the <a data-link-type=dfn href=#cascade title=cascade>cascade</a> does not result in a value,
then the <a data-link-type=dfn href=#specified-value title="specified value">specified value</a> of the property is its <a data-link-type=dfn href=#initial-value title="initial value">initial value</a>.</p>
<h3 class="heading settled heading" data-level=7.2 id=inheriting><span class=secno>7.2 </span><span class=content>
Inheritance</span><a class=self-link href=#inheriting></a></h3>
<p><dfn data-dfn-type=dfn data-export="" id=inheritance>Inheritance<a class=self-link href=#inheritance></a></dfn> propagates property values from parent elements to their children.
The <dfn data-dfn-type=dfn data-export="" id=inherited-value>inherited value<a class=self-link href=#inherited-value></a></dfn> of a property on an element
is the <a data-link-type=dfn href=#computed-value title="computed value">computed value</a> of the property on the element’s parent element.
For the root element,
which has no parent element,
the <a data-link-type=dfn href=#inherited-value title="inherited value">inherited value</a> is the <a data-link-type=dfn href=#initial-value title="initial value">initial value</a> of the property.</p>
<p>(Pseudo-elements inherit according to a fictional tag sequence described for each pseudo-element <a data-biblio-type=normative data-link-type=biblio href=#biblio-select title=biblio-select>[SELECT]</a>.)</p>
<p>Some properties are <dfn data-dfn-type=dfn data-export="" id=inherited-property title="inherited property">inherited properties<a class=self-link href=#inherited-property></a></dfn>,
as defined in their property definition table.
This means that,
unless the cascade results in a value,
the value will be determined by inheritance.</p>
<p>A property can also be explicitly inherited. See the <a class=css data-link-type=maybe href=#valuedef-inherit title=inherit>inherit</a> keyword.</p>
<p class=note>Note: Inheritance follows the document tree and is not intercepted by <a href=http://www.w3.org/TR/CSS21/visuren.html#box-gen>anonymous boxes</a>,
or otherwise affected by manipulations of the box tree.</p>
<h3 class="heading settled heading" data-level=7.3 id=defaulting-keywords><span class=secno>7.3 </span><span class=content>
Explicit Defaulting</span><a class=self-link href=#defaulting-keywords></a></h3>
<p>Several CSS-wide property values are defined below;
declaring a property to have these values explicitly specifies a particular defaulting behavior.
As specified in <a href=http://www.w3.org/TR/css3-values/#common-keywords>CSS Values and Units Level 3</a> <a data-biblio-type=normative data-link-type=biblio href=#biblio-css3val title=biblio-css3val>[CSS3VAL]</a>,
all CSS properties can accept these values.</p>
<h4 class="heading settled heading" data-level=7.3.1 id=initial><span class=secno>7.3.1 </span><span class=content>
Resetting a Property: the <a class=css data-link-type=maybe href=#valuedef-initial title=initial>initial</a> keyword</span><a class=self-link href=#initial></a></h4>
<p>If the <a data-link-type=dfn href=#cascaded-value title="cascaded value">cascaded value</a> is the <dfn class=css-code data-dfn-for=all data-dfn-type=value data-export="" id=valuedef-initial><a class=css data-link-type=maybe href=#valuedef-initial title=initial>initial</a><a class=self-link href=#valuedef-initial></a></dfn> keyword,
the property’s <a data-link-type=dfn href=#initial-value title="initial value">initial value</a> becomes its <a data-link-type=dfn href=#specified-value title="specified value">specified value</a>.</p>
<h4 class="heading settled heading" data-level=7.3.2 id=inherit><span class=secno>7.3.2 </span><span class=content>
Explicit Inheritance: the <a class=css data-link-type=maybe href=#valuedef-inherit title=inherit>inherit</a> keyword</span><a class=self-link href=#inherit></a></h4>
<p>If the <a data-link-type=dfn href=#cascaded-value title="cascaded value">cascaded value</a> of a property is the <dfn class=css-code data-dfn-for=all data-dfn-type=value data-export="" id=valuedef-inherit><a class=css data-link-type=maybe href=#valuedef-inherit title=inherit>inherit</a><a class=self-link href=#valuedef-inherit></a></dfn> keyword,
the <a data-link-type=dfn href=#inherited-value title="inherited value">inherited value</a> becomes the property’s <a data-link-type=dfn href=#specified-value title="specified value">specified</a> and <a data-link-type=dfn href=#computed-value title="computed values">computed values</a>.</p>
<h4 class="heading settled heading" data-level=7.3.3 id=inherit-initial><span class=secno>7.3.3 </span><span class=content>
Erasing All Declarations: the <a class=css data-link-type=maybe href=#valuedef-unset title=unset>unset</a> keyword</span><a class=self-link href=#inherit-initial></a></h4>
<p>If the <a data-link-type=dfn href=#cascaded-value title="cascaded value">cascaded value</a> of a property is the <dfn class=css-code data-dfn-for=all data-dfn-type=value data-export="" id=valuedef-unset><a class=css data-link-type=maybe href=#valuedef-unset title=unset>unset</a><a class=self-link href=#valuedef-unset></a></dfn> keyword,
then if it is an inherited property, this is treated as <a class=css data-link-type=maybe href=#valuedef-inherit title=inherit>inherit</a>,
and if it is not, this is treated as <a class=css data-link-type=maybe href=#valuedef-initial title=initial>initial</a>.
This keyword effectively erases all <a data-link-type=dfn href=#declared-value title="declared values">declared values</a> occurring earlier in the <a data-link-type=dfn href=#cascade title=cascade>cascade</a>,
correctly inheriting or not as appropriate for the property
(or all longhands of a <a data-link-type=dfn href=#shorthand-property title=shorthand>shorthand</a>).</p>
<h2 class="heading settled heading" data-level=8 id=changes><span class=secno>8 </span><span class=content>
Changes</span><a class=self-link href=#changes></a></h2>
<h3 class="heading settled heading" data-level=8.1 id=changes-2013><span class=secno>8.1 </span><span class=content>
Changes Since the 30 July 2013 Last Call Working Draft</span><a class=self-link href=#changes-2013></a></h3>
<p>The following changes were made to this specification since the
<a href=http://www.w3.org/TR/2013/WD-css-cascade-3-20130730/>30 July 2013 Last Call Working Draft</a>:</p>
<ul>
<li>Clarified interaction of media-dependent <a class=css data-link-type=maybe href=#at-ruledef-import title=@import>@import</a> statements and style sheet loading requirements.
</ul>
<p>A <a href=http://dev.w3.org/csswg/css-cascade/issues-lc-2013>Disposition of Comments</a> is available.
<h2 class="no-num heading settled heading" id=acknowledgments><span class=content>Acknowledgments</span><a class=self-link href=#acknowledgments></a></h2>
<p>David Baron, Simon Sapin, and Boris Zbarsky contributed to this specification.</p>
<h2 class="no-ref no-num heading settled heading" id=conformance><span class=content>
Conformance</span><a class=self-link href=#conformance></a></h2>
<h3 class="no-ref heading settled heading" id=conventions><span class=content>
Document conventions</span><a class=self-link href=#conventions></a></h3>
<p>Conformance requirements are expressed with a combination of
descriptive assertions and RFC 2119 terminology. The key words "MUST",
"MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT",
"RECOMMENDED", "MAY", and "OPTIONAL" in the normative parts of this
document are to be interpreted as described in RFC 2119.
However, for readability, these words do not appear in all uppercase
letters in this specification.
<p>All of the text of this specification is normative except sections
explicitly marked as non-normative, examples, and notes. <a data-biblio-type=normative data-link-type=biblio href=#biblio-rfc2119 title=biblio-rfc2119>[RFC2119]</a></p>
<p>Examples in this specification are introduced with the words "for example"
or are set apart from the normative text with <code>class="example"</code>,
like this:
<div class=example>
<p>This is an example of an informative example.</p>
</div>
<p>Informative notes begin with the word "Note" and are set apart from the
normative text with <code>class="note"</code>, like this:
<p class=note>Note, this is an informative note.</p>
<h3 class="no-ref heading settled heading" id=conformance-classes><span class=content>
Conformance classes</span><a class=self-link href=#conformance-classes></a></h3>
<p>Conformance to this specification
is defined for three conformance classes:
<dl>