-
Notifications
You must be signed in to change notification settings - Fork 791
Expand file tree
/
Copy pathOverview.src.html
More file actions
1328 lines (1005 loc) · 43.5 KB
/
Overview.src.html
File metadata and controls
1328 lines (1005 loc) · 43.5 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 http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<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 rel="stylesheet" type="text/css" href="../default.css">
<link rel="stylesheet" type="text/css" href="http://www.w3.org/StyleSheets/TR/W3C-[STATUS].css">
</head>
<body>
<div class="head">
<!--logo-->
<h1 id="css3-template">CSS3 Values and Units</h1>
<h2 class="no-num no-toc">[LONGSTATUS] [DATE]</h2>
<dl>
<dt>This version:</dt>
<dd><a href="[VERSION]">[VERSION]</a></dd>
<dt>Latest version:</dt>
<dd><a href="http://www.w3.org/TR/css3-values">[LATEST]</a></dd>
<dt>Previous version:</dt>
<dd><a href="http://www.w3.org/TR/2005/WD-css3-values-20050726">http://www.w3.org/TR/2005/WD-css3-values-20050726</a></dd>
<dt>Editors:</dt>
<dd>Håkon Wium Lie, Opera Software <howcome@opera.com></dd>
<dd>Chris Lilley, W3C <chris@w3.org></dd>
</dl>
<!--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" 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.</p>
<h2 class="no-num no-toc" id="status">Status of this document</h2>
<!--status-->
<p>All features described in this specification that also
exist in CSS 2.1 [[!CSS21]] are intended to be backwards compatible.
In case of conflict between this draft and CSS 2.1 [[!CSS21]],
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>.</p>
<h2 class="no-num no-toc" id="contents">Table of contents</h2>
<!--toc-->
<h2>Dependencies on other modules</h2>
<p>This CSS3 module depends on the following other CSS3 modules:</p>
<ul>
<li><cite>Cascading and Inheritance</cite> [[!CSS3CASCADE]], 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>
<li><cite>Syntax</cite> [[!CSS3SYN]], which describes the syntax of values at the
lexical level.</li>
<li><cite>Color</cite> [[!CSS3COLOR]], which defines additional values used for some properties that control color of text, borders, etc</li>
<li><cite>Fonts</cite> [[!CSS3FONT]], which describes additional values used for font-related properties</li>
</ul>
<h2>Introduction</h2>
<p>By setting property values on elements in a document, style sheets
express the appearance of the document. In order to express rich
designs, a wide range of values and associated units are necessary.
This specification describes the various types of values and units that
can be used in CSS style sheets.
<h2>Value definitions</h2>
<p>Each CSS property has a value definition field in the property description.
The value definition describes what types of values the property accepts. The
syntax used in the value definitions field is <a href="http://www.w3.org/TR/css3-syntax/#property-def-value">defined</a> in [[!CSS3SYN]].
<div class=example>
<p>Here are some sample properties with corresponding value definition fields:
<table>
<tr><th>Property<th>Value definition field
<tr><td>min-width<td><length> | <percentage> | inherit
<tr><td>outline-color<td><color> | invert | inherit
<tr><td>orphans<td><integer> | inherit
<tr><td>pitch<td><frequency> | x-low | low | medium | high | x-high | inherit
<tr><td>string-set<td>[[ <identifier> <content-list>] [, <identifier> <content-list>]* ] | none
</table>
</div>
<p>The value definition fields contain keywords, data types (which appear between "<" and ">", and information on how they can be combined. Generic data types (<length> being the most widely used) that can be used by many properties are described in this specification, while more specific data types (e.g., <border-width>) are described in the corresponding modules.
<h2>Syntax and terminology</h2>
<p>The generic data types described in the next sections use some
common syntactic building blocks and terms that are described in this
section.
<h3>Integers</h3>
<p>An <dfn>integer</dfn> is one or more decimal digits "0" to "9".
Integers may be preceded by "-" or "+" to indicate the sign.
<div class="example">
<pre>
orphans: 3
</pre>
</div>
<h3>Numbers</h3>
<p>A <dfn>number</dfn> is either an integer, or zero or more decimal
digits followed by a dot (.) followed by one or more decimal digits.
Numbers may be preceded by "-" or "+" to indicate the sign.
<div class=example>
<pre>
line-height: 1.2
</pre>
</div>
<h3>Numbers with unit identifiers</h3>
<p>A <dfn>number with a unit identifier</dfn> is a number immediately followed by a unit identifier.
<div class="example">
<pre>
border-left: -1.2em
</pre>
</div>
<h3>Identifiers</h3>
<p>An <dfn>identifier</dfn> is an sequence of characters. Identifiers
cannot start with a digit, and there are other restrictions
[[!CSS3SYN]] on what characters an identifier can contain. Identifiers
must not be quoted.</p>
<div class="example">
<pre>
pitch-range: inherit;
counter-increment: header;
</pre>
</div>
<h3>Strings</h3>
<p>A <dfn>string</dfn> is a sequence of characters enclosed by double quotes or single quotes. Double quotes cannot occur inside double quotes, unless escaped (as '\"' or as '\22'). Analogously for single quotes ("\'" or "\27").<!--"-->
<div class=example>
<pre>
content: "this is a 'string'.";
content: "this is a \"string\".";
content: 'this is a "string".';
content: 'this is a \'string\'.';
</pre>
</div>
<p>A string cannot directly contain a <span class="index">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">'content'</span> property for an
example.</p>
<p>It is possible to break strings over several lines, for aesthetic 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:</p>
<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>Functional notation</h3>
<p>Some values use a <dfn>functional notation</dfn> to type values and
to and lump values together. The syntax starts with the name of the
function 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
(',') with optional whitespace before and after the comma.
<div class="example">
background: url(http://www.example.org/image);
color: rgb(100, 200, 50 );
</div>
<p>Some properties accept space- or comma-separated lists of values. A value
that is composed of several values with spaces or commas between them,
is called a <dfn>compound value</dfn>. A value that is not a compound
value is a <dfn>simple value</dfn>.
<h2>Keywords</h2>
<p>In the value definition fields, keywords appear literally. Keywords are identifiers.</p>
<div class="example">
<p>For example, here is the value definition for the 'border-collapse'
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">'inherit'</span> and <span class="css">'initial'</span>, as described in [[!CSS3CASCADE]].
<p class="issue">Would it be useful to have a 'default' value, defined
to be equivalent to <span class="css">'inherit'</span> for properties
that are inherited by default and equivalent to <span
class="css">'initial'</span> for properties that are not inherited by
default? This might be easier for authors to use than <span
class="css">'initial'</span> and <span class="css">'inherit'</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).</p>
<h2>Generic data types</h2>
<h3><integer></h3>
<p>Integer values are denoted by <dfn><integer></dfn> in the value
definitions. Properties may restrict the integer value to some range.
If the value is outside the allowed range, the declaration is ignored.
<h3><number></h3>
<p>Number values are denoted by <dfn><number></dfn> in the value
definitions. Properties may restrict the number value to some range.
If the value is outside the allowed range, the declaration is ignored.
<h3><length></h3>
<p>Lengths are denoted by <dfn><length></dfn> in the property
definitions. Lengths refer to horizontal or vertical measurements.
Lengths are numbers with a unit identifier. After the '0' length, the
unit identifier is optional.</p>
<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>
<p>There are several types of length units. <dfn>Relative length
5B28
div>units</dfn> specify a length relative to other lengths,
while <dfn>absolute length units</dfn> express fixed lengths.
<h4>Absolute length units: cm, mm. in, pt, pc</h4>
<p>Absolute length units are useful when the physical
properties of the output medium are known. The absolute units are:</p>
<table>
<tr><th>unit<th>definition
<tr><td><span class="css">cm</span><td>centimeters
<tr><td><span class="css">mm</span><td>millimeters
<tr><td><span class="css">in</span><td>inches; 1 inch is equal to 2.54 centimeters.
<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">
<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.</p>
<h4>Relative length units</h4>
<p>Relative units are:</p>
<table>
<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">'font-size'</span> property)
<tr><td><span class="css">ex</span><td>the <em>x-height</em> of the element's font
<tr><td><span class="css">px</span<td>viewing device
<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><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>The 'em' unit</h5>
<p>The <dfn title="em (unit)">em</dfn> unit is equal to the
computed value of the 'font-size' property of the element on which it
is used. The exception is when "em" occurs in the value of the
'font-size' property itself, in which case it refers to the font size
of the parent element.
<p>When specified on the 'font-size' property of the root element, the ''em'' units refer to the
property's <em>initial value</em>.</p>
<p>The rule:</p>
<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:</p>
<div class="example">
<pre>
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.</p> </div>
<div class="example">
<pre>
h1 { margin: 0.5em } /* em */
h1 { margin: 1ex } /* ex */
p { font-size: 12px } /* px */
</pre>
</div>
<h5>The 'ex' unit</h5>
8096
div><p>The <dfn title="x-height|ex (unit)">ex</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 ''ex'' is defined even for fonts that
do not contain an "x". <span class="issue">Should we say that ex is 0.5em if no better value exists?</span></p>
<p>When specified on the 'font-size' property of the root element, the ''ex'' units refer to the
property's <em>initial value</em>.</p>
<h5>The 'px' unit</h5>
<p>The pixel unit, <dfn title="pixel unit|px (pixel)">px</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>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>
<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>
<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.</p>
<div class="figure">
<p><img src="pixel1" alt="Showing that pixels must become larger if the viewing distance increases">
</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).</p>
<div class="figure">
<p><img src="pixel2"
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">
</p>
</div>
<h5>The 'rem' unit</h5>
<p>The <dfn title="root em|rem (unit)">rem</dfn> unit ("root em") is
relative to the computed value of 'font-size' on the root element.
<p>When specified on the 'font-size' property of the root element, the
''rem'' units refer to the property's <em>initial value</em>.</p>
<h5>The 'vw' unit</h5>
<p>The <dfn title="vw (unit)">vw</dfn> unit is relative to
the viewport's width. The viewport's width is equal to 100
'vw' 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 specified in the 'vw' unit are scaled
proportionally.
<h5>The 'vh' unit</h5>
<p>The <dfn title="vh (unit)">vh</dfn> unit is relative to
the viewport's height. The viewport's height is equal to 100
'vh' units. When the height of the viewport is changed (for example,
when the browser window is enlarged), lengths specified in the 'vh'
unit are scaled proportionally.
<h5>The 'vm' unit</h5>
<p class=issue>Do we need this now that we have the min() function?
<p>The <dfn title="vm (unit)">vm</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 ''vm''
units. When the height or width of the viewport is changed, lengths
specified in the 'vm' unit are scaled proportionally.
<h4>The 'calc', 'min' and 'max' functions</h4>
<p>The <dfn>calc()</dfn>, <dfn>min()</dfn>, and <dfn>max()</dfn> functions can be used wherever length, frequency, angle, time, or number values are allowed.
<div class="example">
<pre>
section {
float: left;
margin: 1em; border: solid 1px;
width: calc(100%/3 - 2*1em - 2*1px);
}
</pre>
</div>
<div class="example">
<pre>
p {
margin: calc(1rem - 2px) calc(1rem - 1px);
}
</pre>
</div>
<div class="example">
<pre>
p { font-size: min(10px, 3em) }
blockquote { font-size: max(30px, 3em) }
</pre>
</div>
<div class="example">
<pre>
.box { width: min(10% + 20px, 300px) }
</pre>
</div>
<p>The expression language of these functions is described by
the grammar and prose below.
<pre>
S : calc | min | max;
calc : "calc(" S* sum ")" S*;
min : "min(" S* sum [ "," S* sum ]* ")" S*;
max : "max(" S* sum [ "," S* sum ]* ")" S*;
sum : product [ [ "+" | "-" ] S* product ]*;
product : unit [ [ "*" | "/" | "mod" ] S* unit ]*;
unit : ["+"|"-"]? [ NUMBER S* | DIMENSION S* | PERCENTAGE S* |
min | max | "(" S* sum ")" S* ];
</pre>
<p>The context of the expression imposes a target type, which is one
of length, frequency, angle, time, or number. NUMBER tokens are of
type number. DIMENSION tokens have types of their units ('cm' is
length, 'deg' is angle etc.); any DIMENSION whose type does not match
the target type is not allowed and must be a parse error. If
percentages are accepted in that context and convertible to the target
type, a PERCENTAGE token in the expression has the target type;
otherwise percentages are not allowed and must be a parse error.
<p>To make expressions simpler, operators have restrictions on the
types they accept. At each operator, the types of the left and right
side have to be checked for these restrictions. If compatible, they
return roughly as follows (the following ignores precedence rules on
the operators for simplicity):
<ol>
<li>At ",", "+", "-":<br>
check: both sides have the same type<br>
return: that type
<li>At "*":<br>
check: at least one side is "number" <br>
return: the type of the other side
<li>At "/":<br>
check: right side is "number"<br>
return: the type of the left side
</ol>
<p>Division by zero is a parse error.
<p>The value resulting from an expression must be clamped to the
range allowed in the target context.
<div class=example>
These two are equivalentequivalent to 'width: 0px' since widths
smaller than 0px are not allowed.
<pre>
width: calc(5px - 10px);
width: 0px;
</pre>
</div>
<p>Given the complexities of 'width' and 'height' on table cells and
table elements, calc() expressions for 'width' and 'height' on table
columns, table column groups, table rows, table row groups, and
table cells in both auto and fixed layout tables are treated as if
'auto' had been specified.
<h3><string></h3>
<p>Strings are denoted by <dfn><string></dfn> in the value
definitions.
<h3><color></h3>
<p><em>This section is not normative. The CSS3 Color module [[!CSS3COLOR]] defines the CSS3 color values.</em>
<p>Color values are denoted by <dfn><color></dfn> in the value
definitions.
<p>A <dfn>color</dfn> value can either be a keyword, a numerical
specification in a functional notation, or a numerical RGB
specification in a hexadecimal notation. The hexadecimal notation is
special shorthand format that allows compact color descriptions.
<div class="example">
<pre>
em { color: #F00 }
span.issue { color: red }
* { color: hsl(120, 75%, 75%) }
</pre>
</div>
<h3><percentage></h3>
<p>The format of a percentage value, denoted by <dfn
title="<percentage>::definition of"><percentage></dfn>,
is a <span class="index"><number></span>
immediately followed by '%'.</p>
<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.</p>
<div class="example">
<p style="display:none">Example(s):</p>
<p>Since child elements (generally) inherit the <em>computed values</em> of
their parent, in the following example, the children of the P element will
inherit a value of 12pt for <span class="property">'line-height'</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><angle></h3>
<p>Angle values (denoted by <dfn
title="<angle>::definition of"><angle></dfn> in the text) are
used with aural cascading style sheets.</p>
<p>Their format is a <span class="index"><number></span>
immediately followed by an angle unit identifier.</p>
<p>Angle unit identifiers are:</p>
<ul>
<li><dfn title="deg (degrees)">deg</dfn>: degrees</li>
<li><dfn title="grad (grads)">grad</dfn>: grads</li>
<li><dfn title="rad (radians)">rad</dfn>: radians</li>
<li><dfn title="turn">turn</dfn>: turns</li>
</ul>
<p>Angle values should be normalized to the range
0-360deg by the user agent. For example, -10deg and 350deg are equivalent.</p>
<p>For example, a right angle is '90deg' or '100grad' or
'1.570796326794897rad'.</p>
<h3><time></h3>
<p>Time values are denoted by <dfn title="<time>::definition of"><time></dfn> in the text. Their format is a <span class="index"><number></span> immediately
followed by a time unit identifier.</p>
<p>Time unit identifiers are:</p>
<ul>
<li><dfn title="ms (milliseconds)">ms</dfn>: milliseconds</li>
<li><dfn title="s (seconds)">s</dfn>: seconds</li>
</ul>
<p>Time values are always positive.
<h3><frequency></h3>
<p>Frequency values (denoted by <dfn title="<frequency>::definition of"><frequency></dfn> in the text) are used with aural cascading style sheets.</p>
<p>Their format is a <span class="index"><number></span> immediately
followed by a frequency unit identifier.</p>
<p>Frequency unit identifiers are:</p>
<ul>
<li><dfn title="Hz (Hertz)">Hz:</dfn> Hertz</li>
<li><dfn title="kHz (kilohertz)">kHz:</dfn> kilohertz</li>
</ul>
<p>For example, 200Hz (or 200hz) is a bass sound, and 6kHz (or 6khz) is a
treble sound.</p>
<p>Frequency values are always positive.
<h3><attr></h3>
<p class=issue>Describe the feature fully here, not just a delta from CSS 21.
<p class=issue>When attr is set on a pseudo-element, it should apply to the originating element
<p>In CSS2.1 [[!CSS21]], the 'attr()' expression always returns a
string. In CSS3, the 'attr()' 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 '|', with no whitespace before or after the
separator [[CSS3NAMESPACE]].
<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 'color' property.
<dt>url
<dd>The attribute value will be interpreted as the URI part of a
'url()' 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
nondescript 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, gr, 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 'float: attr(align)'</p>
<p>If the <type> is missing, 'string' is implied.
<p class="issue">Ideally, it shouldn't be necessary to specify the
type if it is obvious. For example, this should be valid:
"<tt>background-image: attr(href);</tt>". This could be described as:
<q>If the property only accepts one type of value (aside from
'inherit' and 'initial'), that type is implied</q>.
<p>The attr() form is only valid if the type given (or implied, if it
is missing) is valid for the property. For example, all of the
following are invalid and would cause a parse-time error (and thus
cause the relevant declaration, in this case all of them, to be
ignored):
<div class="illegal-example">
<p style="display:none">Illegal Examples:
<pre>
content: attr(title, color); /* 'content' doesn't accept colors */
content: attr(end-of-quote, string, inherit) close-quote; /* the
'inherit' value is not allowed there, since the result would be
'inherit close-quote', which is invalid. */
margin: attr(vertical, length) attr(horizontal, deg); /* deg
units are not valid at that point */
<!--
font: attr(weight, integer) attr(size, length)/attr(height,
integer) attr(family, string); /* invalid because
<'font-weight'>s are not integers, but identifiers. */
-->
color: attr(color); /* 'color' doesn't accept strings */
</pre>
</div>
<p>The attr() expression cannot return everything, for example it cannot
do counters, named strings, quotes, or values such as 'auto',
'nowrap', or 'baseline'. This is intentional, as the intent of the
'attr()' expression is not to make it possible to describe a
presentational language's formatting using CSS, but to enable CSS
to take semantic data into account.
<p>Note that the default value need not be of the type given. For
instance, if the type required of the attribute by the author is
'px', the default could still be '5em'.
<div class="example">
<p>Examples:
<pre>
<stock>
<wood length="12"/>
<wood length="5"/>
<metal length="19"/>
<wood length="4"/>
</stock>
stock::before {
display: block;
content: "To scale, the lengths of materials in stock are:";
}
stock > * {
display: block;
width: attr(length, em); /* default 0 */
height: 1em;
border: solid thin;
margin: 0.5em;
}
wood {
background: orange url(wood.png);
}
metal {
background: silver url(metal.png);
}
/* this also uses a possible extension to the 'content' property
to handle replaced content and alternatives to unavailable,
corrupted or unsupported content */
img {
content: replaced attr(src, url), attr(alt, string, none);
height: attr(height, px, auto);
width: attr(width, px, auto);
}
</pre>
</div>
<p>The attr() expression cannot currently fall back onto another
attribute. Future versions of CSS may extend attr() in this
direction.
<p class="issue">Should 'attr()' be allowed on any property, in any
source language? For example, do we expect UAs to honor this rule for HTML
documents?: <tt>P[COLOR] { color: attr(COLOR, color)
}</tt>.
<h3 id="uris"><url></h3>
<p><dfn title="Uniform Resource Locator (URL)|URL (Uniform Resource
Locator)">URLs</dfn> (Uniform Resource Locators, see [[RFC1738]] and
[[RFC1808]]) provide the address of a resource on the Web. An
alternative and more general term is <dfn title="Resource Identifier
(URI)|URI (Uniform Resource Identifier)">URIs</dfn> (Uniform Resource
Identifiers, see [!URI]). This specification uses the term URI.</p>
<p>For historical reasons, the name of the URI function is "url". The
URI function takes one URI as the argument. The URI may be quoted with
single quote (') or double quote (") characters. If quoted, the two
quote characters must be the same.
<div class="example">
<p style="display:none">Example(s):</p>
<pre>
body { background: url("http://www.example.com/pinkish.gif") }
</pre>
</div>
<div class="example">
<p>An example without quotes:</p>
<pre>
li { list-style: url(http://www.example.com/redball.png) disc }
</pre>
</div>
<p>Parentheses, commas, whitespace characters, single quotes (') and double
quotes ("<!--"-->) appearing in a URI must be escaped with a backslash: '\(', '\)',
'\,'.</p>
<p>Depending on the type of URI, it might also be possible to write the above
characters as URI-escapes (where "(" = %28, ")" = %29, etc.) as described in
[!URI].</p>
<p>In order to create modular style sheets that are not dependent on the
absolute location of a resource, authors should use relative URIs. Relative URIs
(as defined in [[RFC1808]]) are resolved to full URIs using a base URI.
RFC 1808, section 3, defines the normative algorithm for this process. For
CSS style sheets, the base URI is that of the style sheet, not that of the
source document.</p>
<div class="example">
<p>For example, suppose the following rule:</p>
<pre>
body { background: url("yellow") }
</pre>
<p>is located in a style sheet designated by the URI:</p>
<pre>
http://www.example.org/style/basic.css
</pre>
<p>The background of the source document's BODY will be tiled with whatever
image is described by the resource designated by the URI</p>
<pre>
http://www.example.org/style/yellow
</pre>
</div>
<p>User agents may vary in how they handle URIs that designate unavailable or
inapplicable resources.</p>
<h3><image></h3>
<p>TBD.
<!--
<h4>The 'counter' function</h4>
<p><dfn title="<counter>, definition of">Counters</dfn> are denoted by
identifiers (see the <span class="property">'counter-increment'</span> and
<span class="property">'counter-reset'</span> properties). To refer to the
value of a counter, the notation <dfn>'counter(<identifier>)'</dfn> or
<dfn>'counter(<identifier>, <list-style-type>)'</dfn> is used.
The default style is 'decimal'.</p>
<p>To refer to a sequence of nested counters of the same name, the notation
is 'counters(<identifier>, <string>)' or
'counters(<identifier>, <string>, <list-style-type>)'. See
"Nested counters and scope" [add ref] in the chapter on generated content
[add ref].</p>
<p>In CSS2.1, the values of counters can only be referred to from the <span
class="property">'content'</span> property. Note that 'none' is a possible
<list-style-type>: 'counter(x, none)' yields an empty string.</p>
<div class="example">
<p style="display:none">Example(s):</p>
You can’t perform that action at this time.