-
Notifications
You must be signed in to change notification settings - Fork 790
Expand file tree
/
Copy pathOverview.html
More file actions
1909 lines (1431 loc) · 67.9 KB
/
Overview.html
File metadata and controls
1909 lines (1431 loc) · 67.9 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
157
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 PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html lang=en>
<head><meta content="text/html; charset=iso-8859-1" http-equiv=Content-Type>
<title>CSS3 Values and Units</title>
<style type="text/css">
.issue { color: red }
table { border-collapse: collapse; border: 1px solid black; margin: 1em 0 }
th, td { border: 1px solid black; padding: 0.2em; text-align: left }
tt.declaration { white-space: nowrap }
.del { text-decoration: line-through}
.say { font-style: italic }
</style>
<link href=default.css rel=stylesheet type="text/css">
<link href="http://www.w3.org/StyleSheets/TR/W3C-ED.css" rel=stylesheet
type="text/css">
<body>
<div class=head> <!--begin-logo-->
<p><a href="http://www.w3.org/"><img alt=W3C height=48
src="http://www.w3.org/Icons/w3c_home" width=72></a> <!--end-logo-->
<h1 id=css3-template>CSS3 Values and Units</h1>
<h2 class="no-num no-toc" id=w3c-working>W3C Working Draft 3 January 2009</h2>
<dl>
<dt>This version:
<dd><a
href="http://www.w3.org/TR/2009/ED-css3-values-20090103">http://www.w3.org/TR/2009/ED-css3-values-20090103</a>
<dt>Latest version:
<dd><a
href="http://www.w3.org/TR/css3-values">http://www.w3.org/TR/css3-values</a>
<dt>Previous version:
<dd><a
href="http://www.w3.org/TR/2005/WD-css3-values-20050726">http://www.w3.org/TR/2005/WD-css3-values-20050726</a>
<dt>Editors:
<dd>Håkon Wium Lie, Opera Software <howcome@opera.com>
<dd>Chris Lilley, W3C <chris@w3.org>
</dl>
<!--begin-copyright-->
<p class=copyright><a
href="http://www.w3.org/Consortium/Legal/ipr-notice#Copyright"
rel=license>Copyright</a> © 2009 <a
href="http://www.w3.org/"><acronym title="World Wide Web
Consortium">W3C</acronym></a><sup>®</sup> (<a
href="http://www.csail.mit.edu/"><acronym title="Massachusetts Institute
of Technology">MIT</acronym></a>, <a
href="http://www.ercim.org/"><acronym title="European Research Consortium
for Informatics and Mathematics">ERCIM</acronym></a>, <a
href="http://www.keio.ac.jp/">Keio</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>
<!--end-copyright-->
<hr title="Separator for header">
</div>
<h2 class="no-num no-toc" id=abstract>Abstract</h2>
<p>This CSS3 module describes the various values and units that CSS
properties accept. Also, it describes how values are computed from
"specified" (which is what the cascading process yields) through
"computed" and "used" into "actual" values. The main purpose of this
module is to define common values and units in one specification which can
be referred to by other modules. As such, it does not make sense to claim
conformance with this module alone.
<h2 class="no-num no-toc" id=status>Status of this document</h2>
<!--begin-status-->
<p>This is a public copy of the editors' draft. It is provided for
discussion only and may change at any moment. Its publication here does
not imply endorsement of its contents by W3C. Don't cite this document
other than as 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">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 “css3-values” in the subject, preferably like this:
“[<!---->css3-values<!---->] <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>
<!--end-status-->
<p>All features described in this specification that also exist in CSS 2.1
<a href="#CSS21" rel=biblioentry>[CSS21]<!--{{!CSS21}}--></a> are intended
to be backwards compatible. In case of conflict between this draft and
CSS 2.1 <a href="#CSS21"
rel=biblioentry>[CSS21]<!--{{!CSS21}}--></a>, CSS 2.1 probably
represents the intention of the CSS WG better than this draft (other than
on values and units that are new to CSS3).
<p>This is a draft of a <a href="http://www.w3.org/TR/css3-roadmap/">module
of CSS level 3</a>. It will probably be bundled with some other modules
before it becomes a <a href="http://www.w3.org/TR/#About">W3C
Recommendation</a>.
<h2 class="no-num no-toc" id=contents>Table of contents</h2>
<!--begin-toc-->
<ul class=toc>
<li><a href="#dependencies"><span class=secno>1. </span>Dependencies on
other modules</a>
<li><a href="#introduction"><span class=secno>2. </span>Introduction</a>
<li><a href="#values"><span class=secno>3. </span>Values</a>
<ul class=toc>
<li><a href="#keywords"><span class=secno>3.1 </span>Keywords</a>
<li><a href="#numbers"><span class=secno>3.2 </span>Numbers</a>
<li><a href="#numbers0"><span class=secno>3.3 </span>Numbers with unit
identifiers</a>
<ul class=toc>
<li><a href="#lengths"><span class=secno>3.3.1 </span>Lengths</a>
<li><a href="#absolute"><span class=secno>3.3.2 </span>Absolute length
units</a>
<li><a href="#relative"><span class=secno>3.3.3 </span>Relative length
units</a>
<ul class=toc>
<li><a href="#the-em"><span class=secno>3.3.3.1. </span>The
‘<code class=property>em</code>’ unit</a>
<li><a href="#the-ex"><span class=secno>3.3.3.2. </span>The
‘<code class=property>ex</code>’ unit</a>
<li><a href="#the-px"><span class=secno>3.3.3.3. </span>The
‘<code class=property>px</code>’ unit</a>
<li><a href="#the-re"><span class=secno>3.3.3.4. </span>The
‘<code class=property>re</code>’ unit</a>
<li><a href="#the-vw"><span class=secno>3.3.3.5. </span>The
‘<code class=property>vw</code>’ unit</a>
<li><a href="#the-vh"><span class=secno>3.3.3.6. </span>The
‘<code class=property>vh</code>’ unit</a>
<li><a href="#the-vm"><span class=secno>3.3.3.7. </span>The
‘<code class=property>vm</code>’ unit</a>
</ul>
<li><a href="#fractions"><span class=secno>3.3.4 </span>Fractions</a>
<ul class=toc>
<li><a href="#the-fr"><span class=secno>3.3.4.1. </span>The
‘<code class=property>fr</code>’ unit</a>
</ul>
<li><a href="#grids"><span class=secno>3.3.5 </span>Grids</a>
<ul class=toc>
<li><a href="#the-gr"><span class=secno>3.3.5.1. </span>The
‘<code class=property>gr</code>’ unit</a>
</ul>
<li><a href="#percentages"><span class=secno>3.3.6
</span>Percentages</a>
</ul>
<li><a href="#angles"><span class=secno>3.4 </span>Angles</a>
<li><a href="#times"><span class=secno>3.5 </span>Times</a>
<li><a href="#frequencies"><span class=secno>3.6 </span>Frequencies</a>
<li><a href="#strings"><span class=secno>3.7 </span>Strings</a>
<li><a href="#functional"><span class=secno>3.8 </span>Functional
notation</a>
<ul class=toc>
<li><a href="#attribute"><span class=secno>3.8.1 </span>The
‘<code class=property>attr</code>’ function</a>
<li><a href="#uris"><span class=secno>3.8.2 </span>The ‘<code
class=property>url</code>’ function</a>
<li><a href="#the-counter"><span class=secno>3.8.3 </span>The
‘<code class=property>counter</code>’ function</a>
<li><a href="#calc"><span class=secno>3.8.4 </span>The ‘<code
class=property>calc</code>’ function</a>
</ul>
<li><a href="#special"><span class=secno>3.9 </span>Special cases</a>
<ul class=toc>
<li><a href="#font-families"><span class=secno>3.9.1 </span>Font
families</a>
<li><a href="#colors"><span class=secno>3.9.2 </span>Colors</a>
</ul>
</ul>
<li><a href="#specified"><span class=secno>4. </span>Specified, computed,
used, and actual values</a>
<ul class=toc>
<li><a href="#cascaded"><span class=secno>4.1 </span>Cascaded values</a>
<li><a href="#resulting"><span class=secno>4.2 </span>Specified
values</a>
<li><a href="#computed"><span class=secno>4.3 </span>Computed values</a>
<li><a href="#actual"><span class=secno>4.4 </span>Actual values</a>
</ul>
<li class=no-num><a href="#acknowledgments">Acknowledgments</a>
<li class=no-num><a href="#references">References</a>
<ul class=toc>
<li class=no-num><a href="#normative">Normative references</a>
<li class=no-num><a href="#other">Other references</a>
</ul>
<li class=no-num><a href="#index">Index</a>
</ul>
<!--end-toc-->
<h2 id=dependencies><span class=secno>1. </span>Dependencies on other
modules</h2>
<p>This CSS3 module depends on the following other CSS3 modules:
<ul>
<li><cite>Cascading and Inheritance</cite> <a href="#CSS3CASCADE"
rel=biblioentry>[CSS3CASCADE]<!--{{!CSS3CASCADE}}--></a>, which describes
how to find the <cite>resulting value</cite> from several competing
values. Also, it describes how to replace the "inherit" keyword with the
inherited value.
<li><cite>Syntax</cite> <a href="#CSS3SYN"
rel=biblioentry>[CSS3SYN]<!--{{!CSS3SYN}}--></a>, which describes the
syntax of values at the lexical level.</li>
<!--
<li><cite>Text</cite> <a href="#CSS3TEXT" rel="biblioentry">[CSS3TEXT]<!--{{!CSS3TEXT}}-->
</ul>
<p>, which describes how to establish grids referred to by the 'gd' unit.
-->
<ul>
<li><cite>Color</cite> <a href="#CSS3COLOR"
rel=biblioentry>[CSS3COLOR]<!--{{!CSS3COLOR}}--></a>, which defines
additional values used for some properties that control color of text,
borders, etc
<li><cite>Fonts</cite> <a href="#CSS3FONT"
rel=biblioentry>[CSS3FONT]<!--{{!CSS3FONT}}--></a>, which describes
additional values used for font-related properties
</ul>
<h2 id=introduction><span class=secno>2. </span>Introduction</h2>
<p>There are eight main types of values in CSS:
<ol>
<li>keywords (e.g. "pitch-range: inherit")
<li>numbers (e.g. "orphans: 3")
<li>non-negative numbers (e.g. "orphans: 3")
<li>numbers with unit identifiers (e.g. "border-left: -1.2em")
<li>non-negative numbers with unit identifiers (e.g. "border-width:
0.2em")
<li>strings (e.g. "content: ‘<code class=css>Figure:
</code>’")
<li>functional notations (e.g. "background:
url(http://www.example.org/image)")
<li>special cases (e.g. "color: #F00" and "font-family: Helvetica,
sans-serif")
</ol>
<p class=issue>Should the special cases also be described in this draft?
<p>Most properties accept values from several of the above types. Some
properties accept space- or comma-separated lists of values.
Comma-separated lists have optional whitespace before and after the comma.
<p>Each CSS property has a formal definition of what types of values it
accepts which can be found in the description of the property. For special
case types not described in this module, the individual property
descriptions should be consulted.
<h2 id=values><span class=secno>3. </span>Values</h2>
<h3 id=keywords><span class=secno>3.1 </span>Keywords</h3>
<p>In the formal definition of property values, keywords appear literally.
<div class=example>
<p>For example, here is the value definition for the ‘<code
class=property>border-collapse</code>’ property:</p>
<pre>
Value: collapse | separate
</pre>
<p>And here is an example of its use:</p>
<pre>
table { border-collapse: separate }
</pre>
</div>
<p>All CSS3 properties accept the keyword values <span
class=css>‘<code class=property>inherit</code>’</span> and
<span class=css>‘<code class=property>initial</code>’</span>.
Keywords must not be quoted.
<p class=issue>Would it be useful to have a ‘<code
class=property>default</code>’ value, defined to be equivalent to
<span class=css>‘<code class=property>inherit</code>’</span>
for properties that are inherited by default and equivalent to <span
class=css>‘<code class=property>initial</code>’</span> for
properties that are not inherited by default? This might be easier for
authors to use than <span class=css>‘<code
class=property>initial</code>’</span> and <span
class=css>‘<code class=property>inherit</code>’</span> since
it wouldn't require thinking about whether a property is inherited by
default or not (which isn't obvious for some properties, such as
text-decoration and visibility).
<h3 id=numbers><span class=secno>3.2 </span>Numbers</h3>
<p>Number values can either be integer or real numbers Integer values are
denoted by <dfn id=ltintegergt><integer></dfn> and real number
values are denoted by <dfn id=ltnumbergt><number></dfn>. Integers
and real numbers are specified in decimal notation only. An
<integer> consists of one or more digits "0" to "9". A
<number> can either be an <integer>, or it can be zero or more
digits followed by a dot (.) followed by one or more digits. Both integers
and real numbers may be preceded by a "-" or "+" to indicate the sign, and
the sign character is considered part of the <number> value.
<p>Many properties that allow an integer or real number as a value actually
restrict the value to some range. If the restriction is to a non-negative
value, then a non-negative number type is used.
<p>Non-negative number values can either be integer or real numbers.
Integer values are denoted by <dfn id=ltnon-negative><non-negative
integer></dfn> and real number values are denoted by <dfn
id=ltnon-negative0><non-negative number></dfn>. The syntax for
non-negative numbers is the same as for other numbers execept that the "-"
sign is not allowed.
<h3 id=numbers0><span class=secno>3.3 </span>Numbers with unit identifiers</h3>
<p>Many CSS values consist of a number with a unit identifier. The most
common types is lengths, but percentages, angles, times, and frequences
also belong to this group.
<h4 id=lengths><span class=secno>3.3.1 </span>Lengths</h4>
<p>Lengths refer to horizontal or vertical measurements. The format of a
length value (denoted by <dfn id=ltlengthgt><length></dfn>) is a
<number> immediately followed by a unit identifier (e.g.,
‘<code class=property>px</code>’, ‘<code
class=property>pt</code>’). After the ‘<code
class=css>0</code>’ length, the unit identifier is optional.
<p>Some properties allow negative length values, but this may complicate
the formatting and there may be implementation-specific limits. If a
negative length value is allowed but cannot be supported, it should be
converted to the nearest value that can be supported.
<p>There are several types of length units. Absolute <dfn
id=relative0>Relative length units</dfn> specify a length relative to
other lengths. <!--Style sheets that use relative units will
more easily scale from one medium to another (e.g., from a computer
display to a laser printer).-->
<h4 id=absolute><span class=secno>3.3.2 </span>Absolute length units</h4>
<p><dfn id=absolute0>Absolute length</dfn> units are useful when the
physical properties of the output medium are known. The absolute units
are:
<table>
<tbody>
<tr>
<th>unit
<th>definition
<tr>
<td><span class=css>in</span>
<td>inches; 1 inch is equal to 2.54 centimeters.
<tr>
<td><span class=css>cm</span>
<td>centimeters
<tr>
<td><span class=css>mm</span>
<td>millimeters
<tr>
<td><span class=css>pt</span>
<td>points; 1pt is equal to 1/72 inch.
<tr>
<td><span class=css>pc</span>
<td>picas; 1 pica is equal to 12 points.
</table>
<div class=example>
<p style=display:none>Examples:</p>
<pre>
h1 { margin: 0.5in } /* inches */
h2 { line-height: 3cm } /* centimeters */
h3 { word-spacing: 4mm } /* millimeters */
h4 { font-size: 12pt } /* points */
h4 { font-size: 1pc } /* picas */</pre>
</div>
<p>In cases where the specified length cannot be supported, user agents
must approximate it in the actual value.
<h4 id=relative><span class=secno>3.3.3 </span>Relative length units</h4>
<p id=absrel-units>
<p>Relative units are:
<table>
<tbody>
<tr>
<th>unit
<th>relative to
<tr>
<td><span class=css>em</span>
<td>the font size of the element (or, to the parent element's font size
if set on the <span class=property>‘<code
class=property>font-size</code>’</span> property)
<tr>
<td><span class=css>ex</span>
<td>the <em><a href="#ex">x-height</a></em> of the element's font
<tr>
<td><span class=css>px</span>
<td>viewing device <!--
<tr><td><span class="css">gd</span><td>the grid defined by <span class="property">'layout-grid'</span> described in the CSS3 Text module !CSS3TEXT
-->
<tr>
<td><span class=css>rem</span>
<td>the font size of the root element
<tr>
<td><span class=css>vw</span>
<td>the viewport's width
<tr>
<td><span class=css>vh</span>
<td>the viewport's height
<tr>
<td><span class=css>vm</span>
<td>the viewport's height or width, whichever is smaller of the two
<tr>
<td><span class=css>ch<span></span></span>
<td>The width of the "0" (ZERO, U+0030) glyph found in the font for the
font size used to render. If the "0" glyph is not found in the font,
the average character width may be used. <span class=issue>How is the
"average character width" found?</span>
</table>
<h5 id=the-em><span class=secno>3.3.3.1. </span>The ‘<code
class=property>em</code>’ unit</h5>
<p>The <dfn id=em title="em (unit)|quad width">‘<code
class=property>em</code>’</dfn> unit is equal to the computed value
of the <span class=property>‘<code
class=property>font-size</code>’</span> property of the element on
which it is used. The exception is when ‘<code
class=property>em</code>’ occurs in the value of the <span
class=property>‘<code class=property>font-size</code>’</span>
property itself, in which case it refers to the font size of the parent
element. On the root element, It may be used for vertical or horizontal
measurement. (This unit is also sometimes called the quad-width in
typographic texts.)
<p>The rule:
<pre class=example>
h1 { line-height: 1.2em }
</pre>
<p>means that the line height of <code>h1</code> elements will be 20%
greater than the font size of the elements. On the other hand:
<pre class=example>
h1 { font-size: 1.2em }
</pre>
<p>means that the font size of <code>h1</code> elements will be 20% greater
than the font size inherited by <code>h1</code> elements.
<div class=example>
<pre>
h1 { margin: 0.5em } /* em */
h1 { margin: 1ex } /* ex */
p { font-size: 12px } /* px */
</pre>
</div>
<h5 id=the-ex><span class=secno>3.3.3.2. </span>The ‘<code
class=property>ex</code>’ unit</h5>
<p>The <dfn id=ex title="x-height|ex (unit)">‘<code
class=property>ex</code>’</dfn> unit is defined by the font's
x-height. The x-height is so called because it is often equal to the
height of the lowercase "x". However, an ‘<code
class=property>ex</code>’ is defined even for fonts that don't
contain an "x". <span class=issue>Should we say that ex is 0.5em if no
better value exists?</span>
<p>When specified on the <span class=property>‘<code
class=property>font-size</code>’</span> property of the root
element, ‘<code class=property>em</code>’ and ‘<code
class=property>ex</code>’ units refer to the property's <em>initial
value</em>.
<h5 id=the-px><span class=secno>3.3.3.3. </span>The ‘<code
class=property>px</code>’ unit</h5>
<p>The pixel unit, <dfn id=px title="pixel unit|px (pixel)::definition
of">‘<code class=property>px</code>’</dfn> is relative to the
resolution of the viewing device. For example, the viewing device can be a
computer display or a printer. Normally, the pixel unit refers to physical
pixels of the viewing device. However, if the pixel density of the output
device is very different from that of a typical computer display, the user
agent should rescale pixel values. It is recommended that the <dfn
id=reference>reference pixel</dfn> be the visual angle of one pixel on a
device with a pixel density of 96dpi and a distance from the reader of an
arm's length. For a nominal arm's length of 28 inches, the visual angle is
therefore about 0.0213 degrees.
<p>For reading at arm's length, 1px thus corresponds to about 0.26mm
(1/96 inch). When printed on a laser printer, meant for reading at a
little less than arm's length (55 cm, 21 inches), 1px is about
0.21mm. On a 300 dots-per-inch (dpi) printer, that may be rounded up to 3
dots (0.25 mm); on a 600 dpi printer, it can be rounded to 5
dots.
<p>The two images below illustrate the effect of viewing distance on the
size of a pixel and the effect of a device's resolution. In the first
image, a reading distance of 71cm (28 inch) results in a px of
0.26mm, while a reading distance of 3.5m (12 feet) requires a px of
1.3mm.
<div class=figure>
<p><img alt="Showing that pixels must become larger if the viewing
distance increases" src=pixel1></p>
</div>
<p>In the second image, an area of 1px by 1px is covered by a single dot in
a low-resolution device (a computer screen), while the same area is
covered by 16 dots in a higher resolution device (such as a 400 dpi
laser printer).
<div class=figure>
<p><img alt="Showing that more device pixels (dots) are needed to cover a
1px by 1px area on a high-resolution device than on a low-res one"
src=pixel2></p>
</div>
<!--
<p>Grid units, <dfn title="grid units|gd (grid)::definition
of">'gd'</dfn>, are frequently used in East Asian typography,
especially for margins. The existence of a grid in an element makes it
possible to express various measurements in terms of grid units.
<div class="example">
<p style="display:none">Example(s):
<pre>
p { layout-grid: strict both 20pt 15pt; margin: 1gd 3gd 1gd 2gd }
</pre>
<p>The <span class="property">'layout-grid'</span> property, described
in the CSS3 Text module <a href="#CSS3TEXT" rel="biblioentry">[CSS3TEXT]<!--{{!CSS3TEXT}}-->
<p>, establishes the grid. In the example above, <code class=html>p</code>
elements acquire a 15pt top margin, a 60pt right margin, a 15pt bottom
margin and a 40pt left margin.
<p>If no grid is specified on the element, the 'gd' unit is treated as the
'em' unit. --><!--
<p>Relative values are not inherited. Instead, <em><a
href="#computed1">computed values</a></em> are passed on to child
elements.
<div class="example">
<p style="display:none">Example(s):</p>
<p>In the following rules, the computed <span
class="property">'text-indent'</span> value of H1 elements will be 36pt, not
45pt, if H1 is a child of the BODY element.</p>
<pre>
body {
font-size: 12pt;
text-indent: 3em; /* i.e., 36pt */
}
h1 { font-size: 15pt }
</pre>
</div>
<p>There are some exceptions to this rule. For more information on
inheritance, see the "Cascading and Inheritance" module.
-->
<h5 id=the-re><span class=secno>3.3.3.4. </span>The ‘<code
class=property>re</code>’ unit</h5>
<p>The <dfn id=re title="root em|em (grid)::definition of">‘<code
class=property>re</code>’</dfn> unit (‘<code class=css><a
href="#re">root em</a></code>’) is relative to the computed value of
the <span class=property>‘<code
class=property>font-size</code>’</span> value of the root element.
The exception is when ‘<code class=property>re</code>’ occurs
in the value of the <span class=property>‘<code
class=property>font-size</code>’</span> property of the root element
itself, in which case it is relative to the ‘<code
class=property>medium</code>’ font-size. It may be used for vertical
or horizontal measurement.
<h5 id=the-vw><span class=secno>3.3.3.5. </span>The ‘<code
class=property>vw</code>’ unit</h5>
<p>The <dfn id=vw title="vw::definition of">‘<code
class=property>vw</code>’</dfn> unit is relative to the viewport's
width. The viewport's width is equal to 100 ‘<code
class=property>vw</code>’ units.
<div class=example>
<p style=display:none>Example:
<pre>
h1 { font-size: 8vw }
</pre>
</div>
<p>If the width of the viewport is 200mm, the font size of <code
class=html>h1</code> elements will be 16mm ((8×200)/100). When the
width of the viewport is changed (for example, when the browser window is
enlarged), lengths specifed in the ‘<code
class=property>vh</code>’ unit is scaled propertionally.
<h5 id=the-vh><span class=secno>3.3.3.6. </span>The ‘<code
class=property>vh</code>’ unit</h5>
<p>The <dfn id=vh title="vh::definition of">‘<code
class=property>vh</code>’</dfn> unit is relative to the viewport's
height. The viewport's width is equal to 100 ‘<code
class=property>vh</code>’ units. When the height of the viewport is
changed (for example, when the browser window is enlarged), lengths
specifed in the ‘<code class=property>vh</code>’ unit are
scaled proportionally.
<h5 id=the-vm><span class=secno>3.3.3.7. </span>The ‘<code
class=property>vm</code>’ unit</h5>
<p>The <dfn id=vm title="vm::definition of">‘<code
class=property>vm</code>’</dfn> unit is relative to the viewport's
height or width, whichever of the two is smaller. The minimum of the
viewport's width/height is equivalent to 100 ‘<code
class=property>vm</code>’ units. When the height or width of the
viewport is changed, lengths specified in the ‘<code
class=property>vm</code>’ unit are scaled proportionally.
<h4 id=fractions><span class=secno>3.3.4 </span>Fractions</h4>
<h5 id=the-fr><span class=secno>3.3.4.1. </span>The ‘<code
class=property>fr</code>’ unit</h5>
<h4 id=grids><span class=secno>3.3.5 </span>Grids</h4>
<h5 id=the-gr><span class=secno>3.3.5.1. </span>The ‘<code
class=property>gr</code>’ unit</h5>
<h4 id=percentages><span class=secno>3.3.6 </span>Percentages</h4>
<p>The format of a percentage value (denoted by <dfn id=ltpercentagegt
title="<percentage>::definition of"><percentage></dfn> in this
specification) is a <a class=index href="#ltnumbergt"
id=ltnumbergt0><number></a> immediately followed by ‘<code
class=css>%</code>’.
<p>Percentage values are always relative to another value, for example a
length. Each property that allows percentages also defines the value to
which the percentage refers. The value may be that of another property for
the same element, a property for an ancestor element, or a value of the
formatting context (e.g., the width of a <em>containing block</em>). When
a percentage value is set for a property of the <em>root</em> element and
the percentage is defined as referring to the inherited value of some
property, the resultant value is the percentage times the <em>initial
value</em> of that property.
<div class=example>
<p style=display:none>Example(s):</p>
<p>Since child elements (generally) inherit the <em><a
href="#computed0">computed values</a></em> of their parent, in the
following example, the children of the P element will inherit a value of
12pt for <span class=property>‘<code
class=property>line-height</code>’</span>, not the percentage value
(120%):</p>
<pre>
p { font-size: 10pt }
p { line-height: 120% } /* 120% of 'font-size' */
</pre>
</div>
<p class=issue>Do we need a "non-negative percentage", e.g. for
"font-size"?
<h3 id=angles><span class=secno>3.4 </span>Angles</h3>
<p>Angle values (denoted by <dfn id=ltanglegt
title="<angle>::definition of"><angle></dfn> in the text) are
used with aural cascading style sheets.
<p>Their format is a <a class=index href="#ltnumbergt"
id=ltnumbergt1><number></a> immediately followed by an angle unit
identifier.
<p>Angle unit identifiers are:
<ul>
<li><dfn id=deg title="deg (degrees)">deg:</dfn> degrees
<li><dfn id=grad title="grad (grads)">grad:</dfn> grads
<li><dfn id=rad title="rad (radians)">rad:</dfn> radians
<li><dfn id=turn title=turn>turn:</dfn> turns
</ul>
<p>Angle values should be normalized to the range 0-360deg by the user
agent. For example, -10deg and 350deg are equivalent.
<p>For example, a right angle is ‘<code class=css>90deg</code>’
or ‘<code class=css>100grad</code>’ or ‘<code
class=css>1.570796326794897rad</code>’.
<h3 id=times><span class=secno>3.5 </span>Times</h3>
<p>Time values (denoted by <dfn id=lttimegt title="<time>::definition
of"><time></dfn> in the text) are used with aural cascading style
sheets.
<p>Their format is a <a class=index href="#ltnumbergt"
id=ltnumbergt2><number></a> immediately followed by a time unit
identifier.
<p>Time unit identifiers are:
<ul>
<li><dfn id=ms title="ms (milliseconds)">ms:</dfn> milliseconds
<li><dfn id=s title="s (seconds)">s:</dfn> seconds
</ul>
<p>Time values are always positive.
<h3 id=frequencies><span class=secno>3.6 </span>Frequencies</h3>
<p>Frequency values (denoted by <dfn id=ltfrequencygt
title="<frequency>::definition of"><frequency></dfn> in the
text) are used with aural cascading style sheets.
<p>Their format is a <a class=index href="#ltnumbergt"
id=ltnumbergt3><number></a> immediately followed by a frequency unit
identifier.
<p>Frequency unit identifiers are:
<ul>
<li><dfn id=hz title="Hz (Hertz)">Hz:</dfn> Hertz
<li><dfn id=khz title="kHz (kilohertz)">kHz:</dfn> kilohertz
</ul>
<p>For example, 200Hz (or 200hz) is a bass sound, and 6kHz (or 6khz) is a
treble sound.
<p>Frequency values are always positive.
<h3 id=strings><span class=secno>3.7 </span>Strings</h3>
<p><dfn id=strings0 title="<string>, definition of">Strings</dfn> can
either be written with double quotes or with single quotes. Double quotes
cannot occur inside double quotes, unless escaped (as ‘<code
class=css>\"</code>’ or as ‘<code
class=css>\22</code>’). Analogously for single quotes ("\'" or
"\27").
<div class=example>
<p style=display:none>Example(s):</p>
<p></p>
<pre>
"this is a 'string'"
"this is a \"string\""
'this is a "string"'
'this is a \'string\''
</pre>
</div>
<p>A string cannot directly contain a <span class=index
id=newline>newline</span>. To include a newline in a string, use the
escape "\A" (hexadecimal A is the line feed character in Unicode (U+000A),
but represents the generic notion of "newline" in CSS). See the <span
class=property>‘<code class=property>content</code>’</span>
property for an example.
<p>It is possible to break strings over several lines, for esthetic or
other reasons, but in such a case the newline itself has to be escaped
with a backslash (\). The newline is subsequently removed from the string.
For instance, the following two selectors are exactly the same:
<div class=example>
<p style=display:none>Example(s):</p>
<pre>
a[title="a not s\
o very long title"] {/*...*/}
a[title="a not so very long title"] {/*...*/}
</pre>
</div>
<h3 id=functional><span class=secno>3.8 </span>Functional notation</h3>
<p>The functional notation is used to denote colors, attributes and URIs in
CSS3. The syntax of the functional notation is: the name of the functions
(e.g. ‘<code class=property>rgb</code>’) followed by a left
parenthesis followed by optional whitespace followed by the argument(s) to
the functions followed by optional whitespace followed by a right
parenthesis. If a function takes more than one argument, the arguments are
separated by a comma (‘<code class=css>,</code>’) with
optional whitespace before and after the comma.
<h4 id=attribute><span class=secno>3.8.1 </span>The ‘<code
class=property>attr</code>’ function</h4>
<p>In CSS2.1 <a href="#CSS21" rel=biblioentry>[CSS21]<!--{{!CSS21}}--></a>,
the ‘<code class=css>attr()</code>’ expression always returns
a string. In CSS3, the ‘<code class=css>attr()</code>’
expression can return many different types. The new syntax for the attr()
expression is:
<pre>
'attr(' ident [ ',' <type> [ ',' <value> ]? ]? ')'
</pre>
<p>The first argument represents the attribute name. The value of the
attribute with that name on the element whose computed values are being
computed is used as the value of the expression, according to the rules
given below.
<p>The first argument accepts an optional namespace prefix to identify the
namespace of the attribute. The namespace prefix and the attribute name is
separated by ‘<code class=css>|</code>’, with no whitespace
before or after the separator <a href="#CSS3NAMESPACE"
rel=biblioentry>[CSS3NAMESPACE]<!--{{CSS3NAMESPACE}}--></a>.
<p>The second argument (which is optional but must be present if the third
argument is present) is a <type> and tells the UA how to interpret the
attribute value. It may be one of the values from the list below.
<p>The third argument (which is optional) is a CSS value which must be
valid where the attr() expression is placed. If it is not valid, then the
whole attr() expression is invalid.
<p>If the attribute named by the first argument is missing, cannot be
parsed, or is invalid for the property, then the value returned by attr()
will be the third argument, or, if the third argument is absent, will be
the value given as the default for the relevant type in the list below.
<dl>
<dt>string
<dd>The attribute value will be interpreted as the contents of a CSS
string. The default is the empty string.
<dt>color
<dd>The attribute value will be interpreted as a CSS <color> value. The
default is UA dependent but must be the same as the initial value of the
‘<code class=property><a href="#color">color</a></code>’
property.
<dt>url
<dd>The attribute value will be interpreted as the URI part of a
‘<code class=css>url()</code>’ expression. The default is a
UA-dependent URI defined to point to a non-existent document with a
generic error condition. (i.e. it shouldn't be an FTP URI that causes a
DNS error, or an HTTP URI that results in a 404, it should be a
non-descript error condition.)
<dt>integer
<dd>The attribute value will be interpreted as a CSS integer. The default
is 0. The default should also be used if the property in question only
accepts integers within a certain range and the attribute is out of
range.
<dt>number
<dd>The attribute value will be interpreted as a CSS number. The default
is 0.0. The default should also be used if the property in question only
accepts numbers within a certain range and the attribute is out of range.
<dt>length, angle, time, frequency
<dd>The attribute value will be interpreted as a CSS length, angle, time
or frequency (respectively), and the unit identifier (if any) will appear
in the attribute value. The default is 0. The default should also be used
if the property in question only accepts values within a certain range
(e.g. positive lengths or angles from 0 to 90deg) and the attribute is
out of range (e.g. a negative length or 180deg).
<dt>em, ex, px, gd, rem, vw, vh, vm, mm, cm, in, pt, pc, deg, grad, rad,
ms, s, Hz, kHz, %
<dd>The attribute value will be interpreted as a float, with the given
type suffixed as a unit. The default is 0 in the relevant units.
</dl>
<p class=issue>Should there also be a "keyword" type to, e.g., support
‘<code class=css>float: attr(align)</code>’
<p>If the <type> is missing, ‘<code
class=property>string</code>’ is implied.
<p class=issue>Ideally, it shouldn't be necessary to specify the type if it