-
Notifications
You must be signed in to change notification settings - Fork 790
Expand file tree
/
Copy pathsyndata.src
More file actions
867 lines (708 loc) · 31.1 KB
/
syndata.src
File metadata and controls
867 lines (708 loc) · 31.1 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
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html lang="en">
<!-- $Id: syndata.src,v 1.38 1997-11-27 03:30:41 ian Exp $ -->
<HEAD>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<TITLE>CSS2 syntax and basic data types</TITLE>
<LINK rel="next" href="selector.html">
<LINK rel="previous" href="convent.html">
<LINK rel="STYLESHEET" href="style/default.css" type="text/css">
</HEAD>
<BODY>
<H1 align="center">CSS2 syntax and basic data types</H1>
<H2><a name="syntax">Syntax</a></H2>
<P>This section describes a grammar common to any version of
CSS (including CSS2). Future versions of CSS will adhere to this core
syntax, although they may add additional syntactic constraints.
<P>The following descriptions are normative. They are also
complemented by the normative grammar rules presented in <a
href="grammar.html">Appendix B</a>.
<H3><a name="tokenization">Tokenization</a></H3>
<P>All levels of CSS, level 1, level 2, but also any future levels,
use the same core syntax. This allows UAs to parse (though not, of
course, completely understand) style sheets written in levels of CSS
that didn't exist at the time the UAs were created. Designers can use
this feature to create style sheets that work with downlevel UA, while
also exercising the possibilities of the latest levels of CSS.
<P>CSS style sheets consist of a sequence of tokens. The list of
tokens for CSS2 is as follows. The definitions use Lex-style regular
expressions. Octal codes refer to <a rel="biblioentry"
href="./refs.html#ref-ISO10646">[ISO10646]</a> Like in Lex, in case of
multiple matches, the longest match determines the token.
<TABLE>
<TR><TH>Token <TH>Definition
<TR><TD colspan=2><HR>
<TR><TD>IDENT <TD><var>{ident}</var>
<TR><TD>AT-KEYWORD <TD>@<var>{ident}</var>
<TR><TD>STRING <TD><var>{string}</var>
<TR><TD>HASH <TD>#<var>{name}</var>
<TR><TD>NUMBER <TD><var>{num}</var>
<TR><TD>PERCENTAGE <TD><var>{num}</var>%
<TR><TD>DIMENSION <TD><var>{num}{ident}</var>
<TR><TD>URL <TD><p>url\(<var>{w}{string}{w}</var>\)|url\(<var>{w}</var>([^ \n\'\")]|\\\ |\\\'|\\\"|\\\))+<var>{w}</var>\)
<TR><TD>RGB <TD>rgb\(<var>{w}{num}</var>%?<var>{w}</var>\,<var>{w}{num}</var>%?<var>{w}</var>\,<var>{w}{num}</var>%?<var>{w}</var>\)
<TR><TD>UNICODE-RANGE <TD>U\+[0-9A-F?]{1,8}(-[0-9A-F]{1,8})?
<TR><TD>CDO <TD>\<!--
<TR><TD>CDC <TD>-->
<TR><TD>DELIM <TD>[^][;{} \t\r\n()]
<TR><TD>SEMICOLON <TD>;
<TR><TD>LBRACE <TD>\{
<TR><TD>RBRACE <TD>\}
<TR><TD>LPAR <TD>\(
<TR><TD>RPAR <TD>\)
<TR><TD>LBRACK <TD>\[
<TR><TD>RBRACK <TD>\]
<TR><TD>WHITESPACE <TD>[ \t\r\n]+
<TR><TD>COMMENT <TD>/\*([^*]|\*[^/])*\*/
</TABLE>
<P>The macros in curly braces ({}) above are defined as follows:
<TABLE>
<TR><TH>Macro <TH>Definition
<TR><TD colspan=2><HR>
<TR><TD>ident <TD><var>{nmstart}{nmchar}*</var>
<TR><TD>nmstart <TD>[a-zA-Z]|<var>{nonascii}</var>|<var>{escape}</var>
<TR><TD>nonascii <TD>[^\0-\177]
<TR><TD>escape <TD>\\[0-9a-fA-F]{1,6}
<TR><TD>nmchar <TD><var>{nmstart}</var>|[-0-9]
<TR><TD>num <TD>[0-9]+|[0-9]*\.[0-9]+
<TR><TD>string <TD>\"(<var>{stringchar}</var>|\')*\"|\'(<var>{stringchar}</var>|\")*\'
<TR><TD>stringchar <TD><var>{escape}</var>|<var>{nonascii}</var>|[\40-\176]
</TABLE>
<P>Below is the core syntax for CSS. The following sections describe
how to use it. Also see <a href="grammar.html">Appendix B</a>, for a
more restrictive grammar that is closer to the CSS level 2 language.
<PRE>
stylesheet : (CDO | CDC | statement)*;
statement : ruleset | at-rule;
at-rule : AT-KEYWORD any* (block | ';');
block : '{' (at-rule | any | block)* '}';
ruleset : selector '{' declaration? (';' declaration)* '}';
selector : any+;
declaration : property ':' value;
property : IDENT;
value : (any | block | AT-KEYWORD)+;
any : IDENT | NUMBER | PERCENTAGE | DIMENSION | STRING
| DELIM | URL | RGB | HASH | UNICODE-RANGE
| '(' any* ')' | '[' any* ']';
</PRE>
<P><a name="whitespace">WHITESPACE</a> and COMMENT tokens do not occur
in the grammar (to keep it readable), but any number of these tokens
may appear anywhere. The content of these tokens (the matched text)
doesn't matter, but their presence or absence may change the
interpretation of some part of the style sheet. For example, in CSS2,
WHITESPACE is significant in selectors.
<H3>Characters and case</H3>
<P> The following rules always hold:
<UL>
<LI> All CSS style sheets are <span class="index-inst" title="case
sensitivity">case-insensitive</span>, except for parts that are
not under the control of CSS. For example, the case-sensitivity of
value of the HTML attributes 'id' and 'class', of font names, and
of URLs lies outside the scope of this specification. Note in
particular that element names are case-insensitive in HTML, but
case-sensitive in XML.
<LI> In CSS2, <a href="selector.html">selectors</a> (element
names, classes and IDs) can contain only the characters
[A-Za-z0-9] and <a rel="biblioentry"
href="./refs.html#ref-ISO10646">[ISO10646]</a> characters 161 and
higher, plus the hyphen (-); they cannot start with a hyphen or a
digit. They can also contain escaped characters and any <a
rel="biblioentry" href="./refs.html#ref-ISO10646">[ISO10646]</a>
character as a numeric code (see next item).
<P>Note that <a rel="biblioentry"
href="./refs.html#ref-UNICODE">[UNICODE]</a> is code-by-code
equivalent to <a rel="biblioentry"
href="./refs.html#ref-ISO10646">[ISO10646]</a>.
<LI> <a name="escaped-characters">The backslash</a> (\) followed
by at most six hexadecimal digits (0..9A..F) stands for the <a
rel="biblioentry" href="./refs.html#ref-ISO10646">[ISO10646]</a>
character with that number.
<LI> Any character except a hexadecimal digit can be escaped to
remove its special meaning, by putting a backslash (\) in front,
For example, <samp>"\""</samp> is a string consisting of one
double quote.
<LI> The two preceding items define <span class="index-inst"
title="backslash
escapes"><EM>backslash-escapes</EM></span>. Backslash-escapes are
always considered to be part of an identifier or a
string (i.e., "\7B" is not punctuation, even though "{" is, and
"\32" is allowed at the start of a class name, even though "2" is
not).
</UL>
<H3>Statements</H3>
<P> A CSS style sheet, for any version of CSS, consists of a list of
<span class="index-inst" title="statements"><em>statements</em></span>
(see the grammar above).
There are two kinds of statements: <span class="index-inst"
title="at-rules|@-rules"><em>at-rules</em></span> and <span
class="index-inst" title="rule sets"><em>rule sets.</em></span> There
may be whitespace (spaces, tabs, newlines) around the statements.
<P>In this specification, the expressions "immediately before" or
"immediate after" mean with no intervening white space or comments.
<!-- Should comments be defined as white space? -->
<H3><a name="at-rules">At-rules</a></H3>
<P> At-rules start with an <DFN>at-keyword</DFN>, which is an
identifier beginning with '@' (for example, '@import', '@page',
etc.). An <a name="identifier">identifier</a> consists of letters,
digits, hyphens, non-ASCII, and <a href="#escaped-characters">escaped
characters.</a>
<P> An at-rule consists of everything up to and including the next
semicolon (;) or the next <a href="#block">block,</a> whichever comes
first. A CSS UA that encounters an unrecognized at-rule must ignore
the whole of the @-rule and continue parsing after it.
<P> CSS2 User agents have some additional constraints, e.g., they must
also ignore any '@import' rule that occurs inside a <a
href="#block">block</a> or that doesn't preceded all rule sets.
<div class="illegal-example"><P>
Here is an example. Assume a CSS2 parser encounters this style sheet:
<PRE>
@import "subs.css";
H1 { color: blue }
@import "list.css";
</PRE>
<P> The second '@import' is illegal according to CSS2. The CSS2 parser
skips the whole at-rule, effectively reducing the style sheet to:
<PRE>
@import "subs.css";
H1 { color: blue }
</PRE>
</div>
<div class="example"><P>
In the following example, the second '@import' rule is invalid,
since it occurs inside a '@media' <a href="#block">block</a>.
<PRE>
@import "subs.css";
@media print {
@import "print-main.css";
BODY { font-size: 10pt }
}
H1 {color: blue}
</PRE>
</div>
<H3><a name="block">Blocks</a></H3>
<P> A <span class="index-inst" title="block"><em>block</em></span>
starts with a left curly brace ({) and ends with the matching right
curly brace (}). In between there may be any characters, except that
parentheses (()), brackets ([]) and braces ({}) must always occur in
matching pairs and may be nested. Single (') and double quotes (")
<!-- " --> must also occur in matching pairs, and characters between them
are parsed as a <span class="index-inst" title="string">string</span>.
See <a href="#tokenization">Tokenization</a> above for the definition
of a string.
<div class="illegal-example">
<P> Here is an example of a block. Note that the right brace between
the double quotes does not match the opening brace of the block, and that the
second single quote is an <a href="#escaped-characters">escaped
character</a>, and thus doesn't match the first single quote:
<PRE>
{ causta: "}" + ({7} * '\'') }
</PRE>
<P>Note that the above rule is not legal CSS2, but it is still
a block as defined above.
</div>
<H3>Rule sets, declaration blocks, and selectors</H3>
<P> A rule set consists of a selector followed by a
declaration block.
<P> A <span class="index-def"
title="declaration-block"><em>declaration-block</em></span> (also
called a {}-block in the following text) starts with a left curly
brace ({) and ends with the matching right curly brace (}). In between
there must be a list of zero or more <DFN>declarations,</DFN>
separated by semicolons (;).
<P>The <span class="index-def"
title="selector"><em>selector</em></span> (see also the section on <a
href="selector.html">selectors</a>) consists of everything up to (but
not including) the first left curly brace ({). A selector always goes
together with a {}-block. When a UA can't parse the selector (i.e., it
is not valid CSS2), it should skip (i.e., ignore) the {}-block as
well.
<div class="note"><P>
<em><strong>Note.</strong>
CSS2 gives a special meaning to the comma (,) in
selectors. However, since it is not known if the comma may acquire
other meanings in future versions of CSS, the whole statement should
be ignored if there is an error anywhere in the selector, even though
the rest of the selector may look reasonable in CSS2.</em>
</div>
<DIV class=illegal-example>
<P>For example, since the "&" is not a legal token in a CSS2
selector, a CSS2 UA must ignore the whole second line, and not set the
color of H3 to red:
<PRE>
H1, H2 {color: green}
H3, H4 & H5 {color: red}
H6 {color: black}
</PRE>
</DIV>
<div class="example"><P>
<P>Here is a more complex example. The first two pairs of curly braces
are inside a string, and do not mark the end of the selector. This is
a legal CSS2 statement.
<PRE>
P[example="public class foo
{
private int x;
foo(int x) {
this.x = x;
}
}"] {color: red}
</PRE>
</div>
<H3><a name="declaration">Declarations</a> and <a
name="properties">properties</a></H3>
<P> A declaration consists of a <span class="index-inst"
title="property"><em>property</em></span>, a colon (:) and a
<DFN>value</DFN>. Around each of these there may be whitespace.
<p>Multiple declarations for the same selector may be
organized into semicolon (;) separated groups.</p>
<div class="example"><p>
Thus, the following rules:</p>
<pre>
H1 { font-weight: bold }
H1 { font-size: 12pt }
H1 { line-height: 14pt }
H1 { font-family: Helvetica }
H1 { font-variant: normal }
H1 { font-style: normal }
</pre>
<p>are equivalent to:</p>
<pre>
H1 {
font-weight: bold;
font-size: 12pt;
line-height: 14pt;
font-family: Helvetica;
font-variant: normal;
font-style: normal;
}
</pre>
</div>
<P>A property is an identifier, as defined earlier. Any character may
occur in the value, but parentheses (()), brackets ([]), braces ({}),
single quotes (') and double quotes (")
<!-- " -->
must come in matching pairs. Parentheses, brackets, and braces may be
nested. Inside the quotes, characters are parsed as a string.
<P> To ensure that new properties and new values for existing
properties can be added in the future, a UA must skip a declaration
with an invalid property name or an invalid value. Every CSS2 property
has its own syntactic and semantic restrictions on the values it
accepts.
<div class="example"><P>
For example, assume a CSS2 parser encounters this style sheet:
<PRE>
H1 { color: red; font-style: 12pt } /* Invalid value: 12pt */
P { color: blue; font-vendor: any; /* Invalid prop.: font-vendor */
font-variant: small-caps }
EM EM { font-style: normal }
</PRE>
<P> The second declaration on the first line has an invalid value
'12pt'. The second declaration on the second line contains an
undefined property 'font-vendor'. The CSS2 parser will skip these
declarations, effectively reducing the style sheet to:
<PRE>
H1 { color: red; }
P { color: blue; font-variant: small-caps }
EM EM { font-style: normal }
</PRE>
</div>
<H3><a name="comments">Comments</a></H3>
<P><span class="index-inst" title="comments">Comments </span> begin
with the characters "/*" and end with the characters "*/". They may
occur anywhere where whitespace can occur and their contents have no
influence on the rendering.
Comments may not be nested.
<P>CSS also allows the SGML comment delimiters ("<!--" and
"-->") in certain places, but they do not delimit CSS
comments. They are permitted so that style rules appearing in an HTML
source document (in the STYLE element) may be hidden from pre-HTML3.2
user agents. See <a rel="biblioentry" href="./refs.html#ref-HTML40"
class="informref">[HTML40]</a> for more information.
<H2><a name="parsing-errors">Rules for handling parsing
errors</a></H2>
<P>User agents are required to obey the following rules
when it encounters these parsing errors:
<UL>
<LI><strong>Unknown properties.</strong>
User agents must ignore a <a
href="syndata.html#declaration">declaration</a> with an unknown
property. For example, if the style sheet is:
<PRE> H1 { color: red; rotation: 70minutes }
</PRE>
<P> the UA will treat this as if the style sheet had been
<PRE> H1 { color: red; }
</PRE>
<LI><strong>Illegal values.</strong> User agents must treat illegal
values, <EM>or values with illegal parts</EM>, as if the entire declaration
weren't there at all:
<PRE>
IMG { float: left } /* CSS2 */
IMG { float: left here } /* "here" is not a value of 'float' */
IMG { background: "red" } /* keywords cannot be quoted in CSS2 */
IMG { border-width: 3 } /* a unit must be specified for length values */
</PRE>
<P> In the above example, a CSS2 parser would honor the first rule and
ignore the rest, as if the style sheet had been:
<PRE>
IMG { float: left }
IMG { }
IMG { }
IMG { }
</PRE>
<P>A UA conforming to a future CSS specification may accept one or
more of the other rules as well.</P>
<LI>User agents must ignore an invalid at-keyword together with everything
following it, up to and including the next semicolon (;) or brace pair
({...}), whichever comes first. For example, assume the style sheet
reads:
<PRE>
@three-dee {
@background-lighting {
azimuth: 30deg;
elevation: 190deg;
}
H1 { color: red }
}
H1 { color: blue }
</PRE>
<P> The '@three-dee' at-rule is not part of CSS2. Therefore, the whole
at-rule (up to, and including, the third right curly brace) is
ignored. The CSS2 UA skips it, effectively reducing the style sheet
to:
<PRE>
H1 { color: blue }
</PRE>
</UL>
<H2>Values</H2>
<H3>Integers and numbers</H3>
<P>Some value types may have integer values, denoted by <span
class="index-def" title="<integer>, definition of"><a
name="value-def-integer" class="value-def"><integer></a></span>
in this specification.
<P>Some value types may have number values, denoted by <span
class="index-def" title="<number>, definition of"><a
name="value-def-number" class="value-def"><number></a></span> in
this specification. A number may have a decimal point.
<P>In CSS2, numbers and integers 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 of more
digits followed by a dot followed by one or more digits. Both integers
and numbers may be preceded by a "-" or "+" to indicate the sign.
<P>Note that many properties that allow a number or integer as value
actually restrict the value to some range, often to a non-negative
value.
<H3><A NAME="length-units">Lengths</A></H3>
<P> The format of a length value (denoted by <span class="index-def"
title="<length>, definition of"><a name="value-def-length"
class="value-def"><length></a></span> in this specification) is
an optional sign character ('+' or '-', with '+' being the default)
immediately followed by a <span
class="value-inst-number"><number></span> (with or without a
decimal point) immediately followed by a unit identifier (e.g., px,
deg, etc.). After the number '0', the unit identifier is optional.
<P> Some properties allow negative length units, but this may
complicate the formatting model and there may be
implementation-specific limits. If a negative length value cannot be
supported, it should be converted to the nearest value that can be
supported.
<P><a name="absrel-units">There are two types of length units:
relative and absolute.</a> <span class="index-def" title="relative
units"><em>Relative length</em></span> units specify a length relative
to another length property. 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).
<P>Relative units are: em, ex, and px.
<div class="example"><P>
<PRE>
H1 { margin: 0.5em } /* em: the height of the element's font */
H1 { margin: 1ex } /* ex: the height of the letter 'x' */
P { font-size: 12px } /* px: pixels, relative to viewing device */
</PRE>
</div>
<P>The 'em' unit, as used in CSS, is equal to the <span
class="index-inst" title="font size">font size</span> used when
rendering an element's text. It may be used for vertical or horizontal
measurement. The 'ex' unit is equal to the font's x-height (the height
of the letter 'x') of the element's font. A font need not contain the
letter "M" to have an 'em' size or the letter "x" to have an x-height;
the font should still define the two units.
<!-- Incomplete -->
<P>Both 'em' and 'ex' refer to the font size of an element except when
used in the <span class="propinst-font-size">'font-size'</span>
property, where they are relative to the font size inherited from the
parent element.
<div class="example"><P>
<P>The rule:
<PRE>
H1 { line-height: 1.2em }
</PRE>
<P>means that the line height of H1 elements will be 20% greater
than the font size of the H1 elements. On the other hand:
<PRE>
H1 { font-size: 1.2em }
</PRE>
<P>means that the font-size of H1 elements will be 20% greater than
the font size inherited by H1 elements.
</div>
<P>When specified for the root element, 'em' and 'ex' refer to the
property's initial value. Please consult the section on <a
href="cascade.html#inheritance">inheritance</a> for more information
about inherited values.
<P>Please consult the section on <a href="flowobj2.html#line-height">line
height calculations</a> for more information about line heights
in the <a href="flowobj.html">visual flow model</a>.
<P><a name="pixel-units">Pixel units</a> are relative to the
resolution of the viewing device, i.e., most often a computer
display. If the pixel density of the output device is very different
from that of a typical computer display, the UA should rescale pixel
values. The suggested <span class="index-def" title="reference
pixel"><EM>reference pixel</EM></span> is the visual angle of one
pixel on a device with a pixel density of 90dpi and a distance from
the reader of an arm's length. For a nominal arm's length of 28
inches, the visual angle is about 0.0227 degrees.
<P>Child elements do not inherit the relative values specified for
their parent; they inherit the computed values. For example:
<div class="example"><P>
<PRE>
BODY {
font-size: 12pt;
text-indent: 3em; /* i.e. 36pt */
}
H1 { font-size: 15pt }
</PRE>
<P> In these rules, the 'text-indent' value of H1 elements will be
36pt, not 45pt, if H1 is a child of the BODY element.
</div>
<P><span class="index-def" title="absolute length"><em> Absolute
length</em></span> units are only useful when the physical properties
of the output medium are known. These absolute units are supported:
in (inches), cm (centimeters), mm (millimeters), pt (points), and pc
(picas).
<div class="example"><P>
For example:
<PRE>
H1 { margin: 0.5in } /* inches, 1in = 2.54cm */
H2 { line-height: 3cm } /* centimeters */
H3 { word-spacing: 4mm } /* millimeters */
H4 { font-size: 12pt } /* points, 1pt = 1/72 in */
H4 { font-size: 1pc } /* picas, 1pc = 12pt */
</PRE>
</div>
<P> In cases where the specified length cannot be supported, UAs
should try to approximate. For all CSS2 properties, further
computations and inheritance should be based on the approximated
value.
<H3> <A NAME="percentage-units">Percentages</A></H3>
<P> The format of a percentage value (denoted by <span
class="index-def" title="<percentage>, definition of"><a
name="value-def-percentage"
class="value-def"><percentage></a></span> in this specification)
is an optional sign character ('+' or '-', with '+' being the default)
immediately followed by a number immediately followed by '%'.
<P> Percentage values are always relative to another value, for
example a length unit. Each property that allows percentage units also
defines to which value the percentage refers.
<div class="example"><P>
Since child elements inherit the computed, not relative, values
specified for their parent, in the following example, the children
of the P element will inherit a value of 12pt for
<span class="propinst-line-height">'line-height'</span> (i.e., 12pt),
not the percentage value (120%):
<PRE>
P { font-size: 10pt }
P { line-height: 120% } /* relative to 'font-size', i.e. 12pt */
</PRE>
</div>
<H3><A NAME="url">URLs</A></H3>
<P> A Uniform Resource Locator, or <span class="index-def"
title="URL">URL</span> (denoted by <span class="index-def"
title="<url>, definition of"><a name="value-def-url"
class="value-def"><url></a></span> in this specification) is
identified with a functional notation.
<div class="example"><P>
For example:
<PRE>
BODY { background: url(http://www.bg.com/pinkish.gif) }
</PRE>
</div>
<P> The format of a URL value is 'url(' followed by optional white
space followed by an optional single quote (') or double quote (")
<!-- " --> character followed by the URL itself (as defined in <a
rel="biblioentry" href="./refs.html#ref-RFC1738" class="normref">[RFC1738]</a>)
followed by an optional single quote (') or double quote (") <!-- "
--> character followed by optional whitespace followed by ')'. Quote
characters that are not part of the URL itself must be balanced.
<P> Parentheses, commas, whitespace characters, single quotes (') and
double quotes (") <!-- " --> appearing in a URL must be escaped with a
backslash: '\(', '\)', '\,'.
<P> In order to create modular style sheets that are not dependent on
the absolute location of a resource, authors may specify the location
of <a href="colors.html#background-properties">background images</a>
with partial URLs. Partial URLs (as defined in <a rel="biblioentry"
href="./refs.html#ref-RFC1808" class="normref">[RFC1808]</a>) are
interpreted relative to the base URL of the style sheet, not relative
to the base URL of the source document.
<div class="example">
<P>For example, suppose the following rule is located in a style sheet
designated by the URL <tt>http://www.myorg.org/style/basic.css</tt>:
<PRE>
BODY { background: url(yellow) }
</PRE>
<P>The background of the source document's BODY will be tiled with
whatever image is described by the resource designated
by the URL <tt>http://www.myorg.org/style/yellow</tt>.
</div>
<P>User agents may vary in how they handle URLs that designate
unavailable or inapplicable resources.
<H3><a name="color-units">Colors</a></H3>
A <span class="index-def" title="<color>, definition of"><a
name="value-def-color" class="value-def"><color></a></span>
is a either a keyword or a numerical RGB specification.
<P> The suggested list of keyword color names is: aqua, black, blue,
fuchsia, gray, green, lime, maroon, navy, olive, purple, red, silver,
teal, white, and yellow. These 16 colors are taken from the Windows
VGA palette, and their RGB values are not defined in this
specification.
<PRE>
BODY {color: black; background: white }
H1 { color: maroon }
H2 { color: olive }
</PRE>
<P>
The RGB color model is used in numerical color specifications. These
examples all specify the same color:
<PRE>
EM { color: #f00 } /* #rgb */
EM { color: #ff0000 } /* #rrggbb */
EM { color: rgb(255,0,0) } /* integer range 0 - 255 */
EM { color: rgb(100%, 0%, 0%) } /* float range 0.0% - 100.0% */
</PRE>
<P>In addition to these color keywords, users may specify keywords that
correspond to the colors used by certain objects in the user's
environment. Please consult the section on <a
href="./ui.html#system-colors">system colors</a> for more information.
<P> The format of an RGB value in hexadecimal notation is a '#'
immediately followed by either three or six hexadecimal
characters. The three-digit RGB notation (#rgb) is converted into
six-digit form (#rrggbb) by replicating pairs of digits, not by adding
zeros. For example, #fb0 expands to #ffbb00. This makes sure that
white (#ffffff) can be specified with the short notation (#fff) and
removes any dependencies on the color depth of the display.
<P> The format of an RGB value in the functional notation is 'rgb('
followed by a comma-separated list of three numerical values (either
three integer values in the range of 0-255, or three percentage
values, typically in the range of 0.0% to 100.0%) followed by
')'. Whitespace characters are allowed around the numerical values.
<P>Values outside the device gamut should be clipped. For a device
whose gamut is sRGB, the three rules below are equivalent:
<PRE>
EM { color: rgb(255,0,0) } /* integer range 0 - 255 */
EM { color: rgb(300,0,0) } /* clipped to 255 */
EM { color: rgb(110%, 0%, 0%) } /* clipped to 100% */
</PRE>
<P>All RGB colors are specified in the sRGB color space (see <a
rel="biblioentry" href="./refs.html#ref-SRGB"
class="normref">[SRGB]</a>). UAs may vary in the fidelity with which
they represent these colors, but using sRGB provides an unambiguous
and objectively measurable definition of what the color should be,
which can be related to international standards (see <a
rel="biblioentry" href="./refs.html#ref-COLORIMETRY"
class="normref">[COLORIMETRY]</a>).
<P>Conforming UAs may limit their color-displaying efforts to
performing a gamma-correction on them. sRGB specifies a display gamma
of 2.2 under specified viewing conditions. UAs should adjust the
colors given in CSS such that, in combination with an output device's
"natural" display gamma, an effective display gamma of 2.2 is
produced. See the section on <a
href="notes.html#gamma-correction">gamma correction</a> for further
details. Note that only colors specified in CSS are affected; e.g.,
images are expected to carry their own color information.
<H3>Angles</H3>
<P>Angle units (denoted by <span class="index-def"
title="<angle>, definition of"><a
name="value-def-angle"><angle></a></span> in the text) are used
with <a href="./aural.html">aural cascading style sheets</a>.
<P>These following are legal angle units:
<UL>
<LI>deg: degrees
<LI>grad: gradient
<LI>rad: radians
</UL>
<p>Values in these units may be negative. They should be normalized to
the range 0-360deg by the UA. For example, -10deg and 350deg are
equivalent. The angle value must be followed
immediately by the angle unit.
<H3>Times</H3>
<P>Time units (denoted by <span class="index-def" title="<time>,
definition of"><a name="value-def-time"><time></a></span> in the
text) are used with <a href="./aural.html">aural cascading style
sheets</a>.
<P>These following are legal time units:
<UL>
<LI>ms: milliseconds
<LI>s: seconds
</UL>
<p>Time values may not be negative. The time value must be followed
immediately by the time unit.
<H3>Frequencies</H3>
<P>Frequency units (denoted by <span class="index-def"
title="<frequency>, definition of"><a
name="value-def-frequency"><frequency></a></span> in the text)
are used with <a href="./aural.html">aural cascading style
sheets</a>.
<p>There are two legal frequency units:
<ul>
<li>Hz: Hertz
<li>kHz: kilo Hertz
</ul>
<div class="example"><P>
For example, 200Hz (or 200hz) is a bass sound, and 6kHz (or 6khz)
is a treble sound.
</div>
<P>The frequency value must be followed immediately by the frequency
unit.
<H2><a name="css-in-html">CSS embedded in HTML</a></H2>
<P> CSS style sheets may be embedded in HTML documents, and to be able
to hide style sheets from older UAs, it is convenient put the style
sheets inside HTML comments. Please consult <a rel="biblioentry"
href="./refs.html#ref-HTML40" class="informref">[HTML40]</a> for more
information.
<P>When CSS is embedded in HTML, it shares the <tt>charset</tt>
parameter used to transmit the enclosing HTML document. As with HTML,
the value of the charset parameter is used to convert from the transfer
encoding to the document character set, which is specified by <a
rel="biblioentry" href="./refs.html#ref-ISO10646">[ISO10646]</a>.
<H2><a name="css-by-itself">CSS as a stand-alone file</a></H2>
<!-- Add reference to rfc2045? -->
<p>CSS style sheets may exist in files by themselves, being linked
from the document. In this case, the CSS files are served with the
media type <tt>text/css</tt>. As with all text media types, a charset
parameter may be added which is used to convert from the transfer
encoding to <a rel="biblioentry"
href="./refs.html#ref-ISO10646">[ISO10646]</a>.
<h2><a name="char-escapes">Character escapes in CSS</a></h2>
<p>CSS may need to use characters that are outside the encoding used
to transmit the document. For example, the "class" attribute of HTML
allows more characters in a class name than the set allowed for
selectors above. In CSS2, such characters can be <a
href="#escaped-characters">escaped</a> or written as <a
rel="biblioentry" href="./refs.html#ref-ISO10646">[ISO10646]</a>
numbers.
<P>For instance, "B&W?" may be written as "B\&W\?" or
"B\26W\3F". For example, a document transmitted as ISO-8859-1
(Latin-1) cannot contain Greek letters directly:
"κουρος" (Greek: "kouros") has to be
written as "\3BA\3BF\3C5\3C1\3BF\3C2". These escapes are thus the CSS
equivalent of numeric character references in HTML or XML documents.
</BODY>
</html>
<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
sgml-declaration:"~/SGML/HTML4.decl"
sgml-default-doctype-name:"html"
sgml-minimize-attributes:t
sgml-nofill-elements:("pre" "style" "br")
sgml-live-element-indicator:t
End:
-->