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 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN">
<html lang="en">
<head>
<title>Syntax and basic data types</title>
<link rel="stylesheet" href="style/default.css" type="text/css">
<link rel="stylesheet" href="http://www.w3.org/StyleSheets/TR/W3C-CR.css" type="text/css">
<link rel="prev" href="conform.html">
<link rel="next" href="selector.html">
<link rel="contents" href="cover.html#minitoc">
<link rel="CSS-properties" href="propidx.html" title="properties">
<link rel="index" href="indexlist.html" title="index">
<link rel="first" href="cover.html">
<meta name="editor" lang="tr" content="Tantek Çelik">
<style type="text/css">
span.colorsquare { float:left; width:5em; height:3em; text-align:center; padding:1.2em 0 .8em }
span.colorname { font-weight:bold }
div.colordiagram { width:25em; height:20em; margin:1em auto; font-family:Verdana,sans-serif; font-size:12px }
div.diagramrow { height:5em }
</style>
<style type="text/css">
.current,.proposed,span.delcurrent { background:#feb }
ins.proposed,span.insproposed { background:#bfb }
del.proposed,span.delproposed { background:#fbb }
span.insproposed { text-decoration:underline }
span.delproposed,span.delcurrent { text-decoration:line-through }
body>del,body>ins {display:block}
</style>
</head>
<body>
<div class="navbar">
<p><a href="conform.html">previous</a>
<a href="selector.html">next</a>
<a href="cover.html#minitoc">contents</a>
<a href="propidx.html">properties</a>
<a href="indexlist.html">index</a>
</div>
<hr class="navbar">
<h1><a name="q0">4 Syntax and basic data types</a></h1>
<div class="subtoc">
<p><strong>Contents</strong>
<ul class="toc">
<li class="tocline2"><a href="syndata.html#syntax" class="tocxref">4.1 Syntax</a>
<ul class="toc">
<li class="tocline3"><a href="syndata.html#tokenization" class="tocxref">4.1.1 Tokenization</a>
<li class="tocline3"><a href="syndata.html#keywords" class="tocxref">4.1.2 Keywords</a>
<ul class="toc">
<li class="tocline4"><a href="syndata.html#vendor-keywords" class="tocxref">4.1.2.1 Vendor-specific extensions</a>
<li class="tocline4"><a href="syndata.html#vendor-keyword-history" class="tocxref">4.1.2.2 Informative Historical Notes</a>
</ul>
<li class="tocline3"><a href="syndata.html#characters" class="tocxref">4.1.3 Characters and case</a>
<li class="tocline3"><a href="syndata.html#statements" class="tocxref">4.1.4 Statements</a>
<li class="tocline3"><a href="syndata.html#at-rules" class="tocxref">4.1.5 <span class="index-def" title="at-rule"> At-rules</span></a>
<li class="tocline3"><a href="syndata.html#block" class="tocxref">4.1.6 Blocks</a>
<li class="tocline3"><a href="syndata.html#rule-sets" class="tocxref">4.1.7 Rule sets, declaration blocks, and selectors</a>
<li class="tocline3"><a href="syndata.html#declaration" class="tocxref">4.1.8 Declarations and properties</a>
<li class="tocline3"><a href="syndata.html#comments" class="tocxref">4.1.9 Comments</a>
</ul>
<li class="tocline2"><a href="syndata.html#parsing-errors" class="tocxref">4.2 Rules for handling parsing errors</a>
<li class="tocline2"><a href="syndata.html#values" class="tocxref">4.3 Values</a>
<ul class="toc">
<li class="tocline3"><a href="syndata.html#numbers" class="tocxref">4.3.1 Integers and real numbers</a>
<li class="tocline3"><a href="syndata.html#length-units" class="tocxref">4.3.2 Lengths</a>
<li class="tocline3"><a href="syndata.html#percentage-units" class="tocxref">4.3.3 Percentages</a>
<li class="tocline3"><a href="syndata.html#uri" class="tocxref">4.3.4 URLs and URIs</a>
<li class="tocline3"><a href="syndata.html#counter" class="tocxref">4.3.5 Counters</a>
<li class="tocline3"><a href="syndata.html#color-units" class="tocxref">4.3.6 Colors</a>
<li class="tocline3"><a href="syndata.html#strings" class="tocxref">4.3.7 Strings</a>
<li class="tocline3"><a href="syndata.html#unsupported-values" class="tocxref">4.3.8 Unsupported Values</a>
</ul>
<li class="tocline2"><a href="syndata.html#charset" class="tocxref">4.4 CSS style sheet representation</a>
<ul class="toc">
<li class="tocline3"><a href="syndata.html#escaping" class="tocxref">4.4.1 Referring to characters not represented in a character encoding</a>
</ul>
</ul>
</div>
<h2>4.1 <a name="syntax">Syntax</a></h2>
<p>This section describes a grammar (and <a name="x0"><span class="index-def"
title="forward-compatible parsing"><dfn>forward-compatible
parsing</dfn></span></a> rules) common to any level of CSS (including
CSS 2.1). Future updates of CSS will adhere to this core syntax,
although they may add additional syntactic constraints.
</p>
<p>These descriptions are normative. They are also
complemented by the normative grammar rules presented in <a
href="grammar.html">Appendix G</a>.
</p>
<p>In this specification, the expressions "immediately before" or
"immediately after" mean with no intervening white space or comments.
<h3>4.1.1 <a name="tokenization">Tokenization</a></h3>
<p>All levels of CSS — level 1, level 2, and any future levels — use
the same core syntax. This allows UAs to parse (though not 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 older user agents, while also
exercising the possibilities of the latest levels of CSS.
</p>
<p>At the lexical level, CSS style sheets consist of a sequence of tokens.
The list of tokens for CSS is as follows. The definitions use Lex-style
regular expressions. Octal codes refer to ISO 10646 (<a href="refs.html#ref-ISO10646" rel="biblioentry" class="noxref"><span class="normref">[ISO10646]</span></a>). As in
Lex, in case of multiple matches, the longest match determines the token.
</p>
<table>
<thead>
<tr><th>Token </th><th>Definition</th></tr>
</thead>
<tr><td colspan=2><hr></td></tr>
<tr><td>IDENT </td><td><code><var>{ident}</var></code></td></tr>
<tr><td>ATKEYWORD </td><td><code>@<var>{ident}</var></code></td></tr>
<tr><td>STRING </td><td><code><var>{string}</var></code></td></tr>
<tr><td>INVALID </td><td><code><var>{invalid}</var></code></td></tr>
<tr><td>HASH </td><td><code>#<var>{name}</var></code></td></tr>
<tr><td>NUMBER </td><td><code><var>{num}</var></code></td></tr>
<tr><td>PERCENTAGE </td><td><code><var>{num}</var>%</code></td></tr>
<tr><td>DIMENSION </td><td><code><var>{num}{ident}</var></code></td></tr>
<tr><td>URI </td><td><code>url\(<var>{w}{string}{w}</var>\)<br>
|url\(<var>{w}</var>([!#$%&*-~]|<var>{nonascii}</var>|<var>{escape}</var>)*<var>{w}</var>\)</code></td></tr>
<tr><td>UNICODE-RANGE </td><td><code>u\+[0-9a-f?]{1,6}(-[0-9a-f]{1,6})?</code></td></tr>
<tr><td>CDO </td><td><code><!--</code></td></tr>
<tr><td>CDC </td><td><code>--></code></td></tr>
<tr><td>; </td><td><code>;</code></td></tr>
<tr><td>{ </td><td><code>\{</code></td></tr>
<tr><td>} </td><td><code>\}</code></td></tr>
<tr><td>( </td><td><code>\(</code></td></tr>
<tr><td>) </td><td><code>\)</code></td></tr>
<tr><td>[ </td><td><code>\[</code></td></tr>
<tr><td>] </td><td><code>\]</code></td></tr>
<tr><td>S </td><td><code>[ \t\r\n\f]+</code></td></tr>
<tr><td>COMMENT </td><td><code>\/\*[^*]*\*+([^/*][^*]*\*+)*\/</code></td></tr>
<tr><td>FUNCTION </td><td><code><var>{ident}</var>\(</code></td></tr>
<tr><td>INCLUDES </td><td><code>~=</code></td></tr>
<tr><td>DASHMATCH </td><td><code>|=</code></td></tr>
<tr><td>DELIM </td><td><var>any other character not matched by
the above rules, and neither a single nor a double quote</var>
</td></tr></table>
<p>The macros in curly braces ({}) above are defined as follows:
</p>
<table>
<thead>
<tr><th>Macro </th><th>Definition</th></tr>
</thead>
<tr><td colspan=2><hr></td></tr>
<tr><td>ident </td><td><code>[-]?<var>{nmstart}</var><var>{nmchar}*</var></code></td></tr>
<tr><td>name </td><td><code><var>{nmchar}+</var></code></td></tr>
<tr><td>nmstart </td><td><code>[_a-z]|<var>{nonascii}</var>|<var>{escape}</var></code></td></tr>
<tr><td>nonascii</td><td><code>[^\0-\177]</code></td></tr>
<tr><td>unicode </td><td><code>\\[0-9a-f]{1,6}(\r\n|[ \n\r\t\f])?</code></td></tr>
<tr><td>escape </td><td><code><var>{unicode}</var>|\\[^\n\r\f0-9a-f]</code></td></tr>
<tr><td>nmchar </td><td><code>[_a-z0-9-]|<var>{nonascii}</var>|<var>{escape}</var></code></td></tr>
<tr><td>num </td><td><code>[0-9]+|[0-9]*\.[0-9]+</code></td></tr>
<tr><td>string </td><td><code><var>{string1}</var>|<var>{string2}</var></code></td></tr>
<tr><td>string1 </td><td><code>\"([^\n\r\f\\"]|\\{nl}|<var>{escape}</var>)*\"</code></td></tr>
<tr><td>string2 </td><td><code>\'([^\n\r\f\\']|\\{nl}|<var>{escape}</var>)*\'</code></td></tr>
<tr><td>invalid </td><td><code><var>{invalid1}</var>|<var>{invalid2}</var></code></td></tr>
<tr><td>invalid1</td><td><code>\"([^\n\r\f\\"]|\\{nl}|<var>{escape}</var>)*</code></td></tr>
<tr><td>invalid2</td><td><code>\'([^\n\r\f\\']|\\{nl}|<var>{escape}</var>)*</code></td></tr>
<tr><td>nl </td><td><code>\n|\r\n|\r|\f</code></td></tr>
<tr><td>w </td><td><code>[ \t\r\n\f]*</code></td></tr>
</table>
<p>Below is the core syntax for CSS. The sections that follow describe
how to use it. <a href="grammar.html">Appendix G</a> describes a
more restrictive grammar that is closer to the CSS level 2 language.
Parts of style sheets that can be parsed according to this grammar but
not according to the grammar in Appendix G are among the parts that
will be ignored according to the <a href="syndata.html#parsing-errors">rules for
handling parsing errors</a>.
</p>
<pre>
stylesheet : [ CDO | CDC | S | statement ]*;
statement : ruleset | at-rule;
at-rule : ATKEYWORD S* any* [ block | ';' S* ];
block : '{' S* [ any | block | ATKEYWORD S* | ';' S* ]* '}' S*;
ruleset : selector? '{' S* declaration? [ ';' S* declaration? ]* '}' S*;
selector : any+;
declaration : property S* ':' S* value;
property : IDENT;
value : [ any | block | ATKEYWORD S* ]+;
any : [ IDENT | NUMBER | PERCENTAGE | DIMENSION | STRING
| DELIM | URI | HASH | UNICODE-RANGE | INCLUDES
| DASHMATCH | FUNCTION S* any* ')'
| '(' S* any* ')' | '[' S* any* ']' ] S*;
</pre>
<p><a name="comment">COMMENT</a> tokens do not occur
in the grammar (to keep it readable), but any number of these tokens
may appear anywhere outside other tokens. (Note, however, that a
comment before or within the @charset rule disables the @charset.)</p>
<p>The token S in the grammar above stands for <a
name="whitespace">white space</a>. Only the characters "space" (U+0020), "tab" (U+0009), "line feed" (U+000A), "carriage return" (U+000D), and
"form feed" (U+000C) can occur in white space. Other space-like characters,
such as "em-space" (U+2003) and "ideographic space" (U+3000), are never part of white space.
</p>
<p>The meaning of input that cannot be tokenized or parsed is
undefined in CSS 2.1.
</p>
<h3>4.1.2 <a name="keywords">Keywords</a></h3>
<p>Keywords have the form of <a
href="syndata.html#value-def-identifier">identifiers.</a> Keywords must not be
placed between quotes ("..." or '...'). Thus,
</p>
<pre>
red
</pre>
<p>is a keyword, but
</p>
<pre>
"red"
</pre>
<p>is not. (It is a <a href="syndata.html#strings">string</a>.) Other illegal examples:
<div class="illegal-example"><P style="display:none">Illegal example(s):</P>
<pre><code>
width: "auto";
border: "none";
background: "red";
</code></pre>
</div>
<h4>4.1.2.1 <a name="vendor-keywords">Vendor-specific extensions</a></h4>
<p>In CSS, identifiers may begin with '<code
class="css">-</code>' (dash) or '<code
class="css">_</code>' (underscore). Keywords
and <a href="syndata.html#properties">property names</a> beginning
with <code class="css">-</code>' or '<code
class="css">_</code>' are reserved for vendor-specific extensions. Such vendor-specific extensions should have one of the following formats:
</p>
<pre>
'-' + vendor identifier + '-' + meaningful name
'_' + vendor identifier + '-' + meaningful name
</pre>
<div class="example"><P style="display:none">Example(s):</P>
<p>For example, if XYZ organization added a property to describe the color of the
border on the East side of the display, they might call it <span
class="css">-xyz-border-east-color</span>.
</p>
<p>Other known examples:</p>
<pre>
-moz-box-sizing
-moz-border-radius
-wap-accesskey
</pre>
</div>
<p>An initial dash or underscore is guaranteed never to be used in a property or keyword by any current or future level of CSS. Thus typical CSS implementations may not
recognize such properties and may ignore them according to the <a
href="syndata.html#parsing-errors">rules for handling parsing errors</a>. However, because the initial dash or underscore is part of the grammar, CSS 2.1 implementers should always be able to use a CSS-conforming parser, whether or not they support any vendor-specific extensions.
</p>
<p>Authors should avoid vendor-specific extensions</p>
<h4>4.1.2.2 <a name="vendor-keyword-history">Informative Historical Notes</a></h4>
<p>This section is informative.</p>
<p>At the time of writing, the following prefixes are known to exist:</p>
<table border='1'>
<thead><tr><th>prefix</th><th>organization</th></tr></thead>
<tbody>
<tr><td><code>-ms-</code>, <code>mso-</code></td><td>Microsoft</td></tr>
<tr><td><code>-moz-</code></td><td>Mozilla</td></tr>
<tr><td><code>-o-</code>, <code>-xv-</code></td><td>Opera Software</td></tr>
<tr><td><code>-atsc-</code></td><td>Advanced Television Standards Committee</td></tr>
<tr><td><code>-wap-</code></td><td>The WAP Forum</td></tr>
<tr><td><code>-khtml-</code></td><td>KDE</td></tr>
<tr><td><code>-webkit-</code></td><td>Apple</td></tr>
<tr><td><code>prince-</code></td><td>YesLogic</td></tr>
<tr><td><code>-ah-</code></td><td>Antenna House</td></tr>
<tr><td><code>-hp-</code></td><td>Hewlett Packard</td></tr>
<tr><td><code>-ro-</code></td><td>Real Objects</td></tr>
<tr><td><code>-rim-</code></td><td>Research In Motion</td></tr>
</tbody>
</table>
<h3>4.1.3 <a name="characters">Characters and case</a></h3>
<p> The following rules always hold:</p>
<ul>
<li> All CSS syntax is <a name="x1"><span class="index-inst" title="case
sensitivity">case-insensitive</span></a> within the ASCII
range (i.e. [a-z] and [A-Z] are equivalent), except for parts that are
not under the control of CSS. For example, the case-sensitivity of
values of the HTML attributes "id" and "class", of font names, and
of URIs lies outside the scope of this specification. Note in
particular that element names are case-insensitive in HTML, but
case-sensitive in XML.
</li>
<li> In CSS, <span class="index-def"
title="identifier|identifier, definition of"><a
name="value-def-identifier"><dfn>identifiers</dfn></a></span>
(including element names, classes, and IDs in <a
href="selector.html">selectors</a>) can contain only the
characters [a-zA-Z0-9] and ISO 10646 characters U+00A1 and higher,
plus the hyphen (-) and the underscore (_); they cannot start with
a digit, or a hyphen followed by a digit.
Identifiers can also contain escaped characters and any ISO 10646
character as a numeric code (see next item).
<span class="example">For instance, the identifier "B&W?" may
be written as "B\&W\?" or "B\26 W\3F".</span>
<p>Note that Unicode is code-by-code equivalent to ISO 10646 (see
<a href="refs.html#ref-UNICODE" rel="biblioentry" class="noxref"><span class="normref">[UNICODE]</span></a> and <a href="refs.html#ref-ISO10646" rel="biblioentry" class="noxref"><span class="normref">[ISO10646]</span></a>).
</p>
</li>
<li> In CSS 2.1, a backslash (\) character indicates three types of
<span class="index-def" title="backslash escapes">
<a name="escaped-characters">character escapes</a></span>.
<p>First, inside a <a href="syndata.html#strings">string</a>, a backslash
followed by a newline is ignored (i.e., the string is deemed not
to contain either the backslash or the newline).
</p>
<p>Second, it cancels the meaning of special CSS characters.
Except within CSS comments, any character (except a
hexadecimal digit, linefeed, carriage return or form feed)
can be escaped
with a backslash to remove its special meaning.
For example, <samp>"\""</samp> is a string consisting of one
double quote. Style sheet preprocessors must not remove
these backslashes from a style sheet since that would
change the style sheet's meaning.
</p>
<p>Third, backslash escapes allow authors to refer to characters
they can't easily put in a document. In this case, the backslash
is followed by at most six hexadecimal digits (0..9A..F), which
stand for the ISO 10646 (<a href="refs.html#ref-ISO10646" rel="biblioentry" class="noxref"><span class="normref">[ISO10646]</span></a>)
character with that number, which must not be zero.
(It is undefined in CSS 2.1 what happens if a style sheet
<em>does</em> contain a character with Unicode codepoint zero.)
If a character in the range [0-9a-fA-F] follows the hexadecimal number,
the end of the number needs to be made clear. There are two ways
to do that:
</p>
<ol>
<li>with a space (or other white space character): "\26 B" ("&B").
In this case, user agents should treat a "CR/LF" pair
(U+000D/U+000A) as a single white space character.</li>
<li>by providing exactly 6 hexadecimal digits: "\000026B" ("&B")</li>
</ol>
<p>In fact, these two methods may be combined. Only one white space
character is ignored after a hexadecimal escape. Note that this means
that a "real" space after the escape sequence must itself either be
escaped or doubled.
</p>
<p>If the number is outside the range allowed by Unicode (e.g.,
"\110000" is above the maximum 10FFFF allowed in current Unicode),
the UA may replace the escape with the "replacement character"
(U+FFFD). If the character is to be displayed, the UA should show
a visible symbol, such as a "missing character" glyph (cf. <a
href="fonts.html#algorithm">15.2,</a> point 5).
</li>
<li class=note>Note: Backslash escapes, where allowed, are always
considered to be part of an <a
href="syndata.html#value-def-identifier">identifier</a> 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).
<p>The identifier "te\st" is exactly the same identifier as "test".
</li>
</ul>
<h3>4.1.4 <a name="statements">Statements</a></h3>
<p> A CSS style sheet, for any level of CSS, consists of a list of
<a name="x5"><span class="index-inst" title="statements"><em>statements</em></span></a>
(see the <a href="syndata.html#tokenization">grammar</a> above). There are two
kinds of statements: <a name="x6"><span
class="index-inst" title="at-rules"><em>at-rules</em></span></a>
and <a name="x7"><span class="index-inst" title="rule sets"><em>rule
sets.</em></span></a> There may be <a href="syndata.html#whitespace">white space</a>
around the statements.
</p>
<h3>4.1.5 <span class="index-def" title="at-rule">
<a name="at-rules">At-rules</a></span></h3>
<p> At-rules start with an <dfn>at-keyword</dfn>, an '@' character
followed immediately by an <a
href="syndata.html#value-def-identifier">identifier</a> (for example, '@import',
'@page').
</p>
<p> An at-rule consists of everything up to and including the next
semicolon (;) or the next <a href="syndata.html#block">block,</a> whichever comes
first.
</p>
<p>CSS 2.1 user agents must <span class="index-inst" title="ignore"><a name="x9"
href="syndata.html#ignore">ignore</a></span> any <a
href="cascade.html#at-import">'@import'</a> rule that occurs inside a <a
href="syndata.html#block">block</a> or after any non-ignored statement other than an <a name="x10"><span
class="index-inst">@charset</span></a> or an @import rule.
</p>
<div class="illegal-example"><P style="display:none">Illegal example(s):</P><p>
Assume, for example, that a CSS 2.1 parser encounters this style sheet:
</p>
<pre><code>
@import "subs.css";
h1 { color: blue }
@import "list.css";
</code></pre>
<p> The second '@import' is illegal according to CSS 2.1. The CSS 2.1 parser
<span class="index-inst" title="ignore"><a name="x11" href="syndata.html#ignore">ignores</a></span>
the whole at-rule, effectively reducing the style sheet to:
</p>
<pre><code class="css">
@import "subs.css";
h1 { color: blue }
</code></pre>
</div>
<div class="illegal-example"><P style="display:none">Illegal example(s):</P><p>
In the following example, the second '@import' rule is invalid,
since it occurs inside a '@media' <a href="syndata.html#block">block</a>.
</p>
<pre><code>
@import "subs.css";
@media print {
@import "print-main.css";
body { font-size: 10pt }
}
h1 {color: blue }
</code></pre>
<p>Instead, to achieve the effect of only importing a style sheet
for 'print' media, use the @import rule with media syntax, e.g.:
</p>
<pre><code class="css">
@import "subs.css";
@import "print-main.css" print;
@media print {
body { font-size: 10pt }
}
h1 {color: blue }
</code></pre>
</div>
<h3>4.1.6 <a name="block">Blocks</a></h3>
<p> A <a name="x12"><span class="index-inst" title="block"><em>block</em></span></a>
starts with a left curly brace ({) and ends with the matching right
curly brace (}). In between there may be any tokens, 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 <a name="x13"><span class="index-inst" title="string">string</span></a>.
See <a href="syndata.html#tokenization">Tokenization</a> above for the definition
of a string.
</p>
<div class="illegal-example"><P style="display:none">Illegal example(s):</P>
<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="syndata.html#escaped-characters">escaped
character</a>, and thus doesn't match the first single quote:
</p>
<pre><code>
{ causta: "}" + ({7} * '\'') }
</code></pre>
<p>Note that the above rule is not valid CSS 2.1, but it is still
a block as defined above.
</p>
</div>
<h3>4.1.7 <a name="rule-sets">Rule sets, declaration blocks, and selectors</a></h3>
<p> A rule set (also called "rule") consists of a selector followed by
a declaration block.
</p>
<p> A <a name="x14"><span class="index-def"
title="declaration block"><dfn>declaration block</dfn></span></a>
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 semicolon-separated (;)
declarations.
</p>
<p>The <a name="x15"><span class="index-def"
title="selector"><em>selector</em></span></a> (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 declaration block. When a user agent can't parse the selector (i.e., it
is not valid CSS 2.1), it must <span class="index-inst" title="ignore"><a name="x16"
href="syndata.html#ignore">ignore</a></span> the selector and the following
declaration block (if any) as well.
</p>
<p>CSS 2.1 gives a special meaning to the comma (,) in
selectors. However, since it is not known if the comma may acquire
other meanings in future updates of CSS, the whole statement should
be <span class="index-inst" title="ignore"><a name="x17"
href="syndata.html#ignore">ignored</a></span> if there is an error anywhere in the
selector, even though the rest of the selector may look reasonable in
CSS 2.1.
</p>
<div class=illegal-example><P style="display:none">Illegal example(s):</P>
<p>For example, since the "&" is not a valid token in a CSS 2.1
selector, a CSS 2.1 user agent must
<span class="index-inst" title="ignore"><a name="x18" href="syndata.html#ignore">ignore</a></span>
the whole second line, and not set the color of H3 to red:
</p>
<pre><code>
h1, h2 {color: green }
h3, h4 & h5 {color: red }
h6 {color: black }
</code></pre>
</div>
<div class="example"><P style="display:none">Example(s):</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 valid CSS 2.1 rule.
</p>
<pre><code class="css">
p[example="public class foo\
{\
private int x;\
\
foo(int x) {\
this.x = x;\
}\
\
}"] { color: red }
</code></pre>
</div>
<h3>4.1.8 <a name="declaration">Declarations</a> and <a
name="properties">properties</a></h3>
<p> A <a name="x19"><span class="index-def"
title="declaration"><dfn>declaration</dfn></span></a> is either empty or
consists of a <a name="x20"><span class="index-inst"
title="property">property name</span></a>, followed by a colon (:), followed by
a value. Around each of these there may be <a
href="syndata.html#whitespace">white space</a>.
</p>
<p>Because of the way selectors work, multiple declarations for the
same selector may be organized into semicolon (;) separated
groups.</p>
<div class="example"><P style="display:none">Example(s):</P><p>
Thus, the following rules:</p>
<pre><code class="css">
h1 { font-weight: bold }
h1 { font-size: 12px }
h1 { line-height: 14px }
h1 { font-family: Helvetica }
h1 { font-variant: normal }
h1 { font-style: normal }
</code></pre>
<p>are equivalent to:</p>
<pre><code class="css">
h1 {
font-weight: bold;
font-size: 12px;
line-height: 14px;
font-family: Helvetica;
font-variant: normal;
font-style: normal
}
</code></pre>
</div>
<p>A property name is an <a
href="syndata.html#value-def-identifier">identifier</a>. Any token may occur
in the value. Parentheses ("( )"), brackets ("[ ]"),
braces ("{ }"), single
quotes (') and double quotes (") must come in matching
pairs, and semicolons not in strings must be <a
href="syndata.html#escaped-characters">escaped</a>. Parentheses, brackets, and
braces may be nested. Inside the quotes, characters are parsed as a
string.
</p>
<p>The syntax of <a name="x21"><span class="index-def" title="value">values</span></a>
is specified separately for each property, but in any case, values are
built from identifiers, strings, numbers, lengths, percentages, URIs,
colors, etc.
</p>
<p>A user agent must <span class="index-inst" title="ignore"><a name="x22"
href="syndata.html#ignore">ignore</a></span> a declaration with an invalid property
name or an invalid value. Every CSS 2.1 property has its own syntactic
and semantic restrictions on the values it accepts.
</p>
<div class="illegal-example"><P style="display:none">Illegal example(s):</P><p>
For example, assume a CSS 2.1 parser encounters this style sheet:
</p>
<pre><code>
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 }
</code></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 CSS 2.1 parser will <span
class="index-inst" title="ignore"><a name="x23" href="syndata.html#ignore">ignore</a></span> these
declarations, effectively reducing the style sheet to:
</p>
<pre class="example"><code class="css">
h1 { color: red; }
p { color: blue; font-variant: small-caps }
em em { font-style: normal }
</code></pre>
</div>
<h3>4.1.9 <a name="comments">Comments</a></h3>
<p><a name="x24"><span class="index-inst" title="comments">Comments </span></a> begin
with the characters "/*" and end with the characters "*/". They may
occur anywhere between tokens,
and their contents have no influence on the rendering. Comments may
not be nested.
</p>
<p>CSS also allows the SGML comment delimiters ("<!--" and
"-->") in certain places defined by the grammar, 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-HTML 3.2
user agents. See the HTML 4 specification (<a href="refs.html#ref-HTML4" rel="biblioentry" class="noxref"><span class="informref">[HTML4]</span></a>) for more information.
</p>
<h2>4.2 <a name="parsing-errors">Rules for handling parsing
errors</a></h2>
<p>In some cases, user agents must ignore part of an illegal style
sheet. This specification defines <span class="index-def"
title="ignore"><a name="ignore"><dfn>ignore</dfn></a></span> to mean
that the user agent parses the illegal part (in order to find its
beginning and end), but otherwise acts as if it had not been there.
CSS 2.1 reserves for future updates of CSS all property:value combinations
and @-keywords that do not contain an identifier beginning with dash or
underscore. Implementations must ignore such combinations (other than those
introduced by future updates of CSS).
</p>
<p>To ensure that new properties and new values for existing
properties can be added in the future, user agents are required to
obey the following rules when they encounter the following
scenarios:</p>
<ul>
<li><strong>Unknown properties.</strong> User agents must <span
class="index-inst" title="ignore"><a name="x26" href="syndata.html#ignore">ignore</a></span> a <a
href="syndata.html#declaration">declaration</a> with an unknown
property. For example, if the style sheet is:
<pre class="illegal-example">
h1 { color: red; rotation: 70minutes }
</pre>
<p> the user agent will treat this as if the style sheet had been
</p>
<pre class="example"><code class="css">
h1 { color: red }
</code></pre>
</li>
<li id="illegalvalues"><strong>Illegal values.</strong> User agents must ignore a
declaration with an illegal value. For example:
<pre class="illegal-example"><code>
img { float: left } /* correct CSS 2.1 */
img { float: left here } /* "here" is not a value of 'float' */
img { background: "red" } /* keywords cannot be quoted */
img { border-width: 3 } /* a unit must be specified for length values */
</code></pre>
A CSS 2.1 parser would honor the first rule and
<span class="index-inst" title="ignore"><a name="x27" href="syndata.html#ignore">ignore</a></span>
the rest, as if the style sheet had been:
<pre class="example"><code class="css">
img { float: left }
img { }
img { }
img { }
</code></pre>
<p>A user agent conforming to a future CSS specification may accept one or
more of the other rules as well.</p>
</li>
<li><strong>Malformed declarations.</strong> User agents must handle
unexpected tokens encountered while parsing a declaration by reading
until the end of the declaration, while observing the rules for matching
pairs of (), [], {}, "", and '', and correctly handling escapes. For
example, a malformed declaration may be missing a property, colon (:) or
value. The following are all equivalent:
<pre class="example"><code>
p { color:green }
p { color:green; color } /* malformed declaration missing ':', value */
p { color:red; color; color:green } /* same with expected recovery */
p { color:green; color: } /* malformed declaration missing value */
p { color:red; color:; color:green } /* same with expected recovery */
p { color:green; color{;color:maroon} } /* unexpected tokens { } */
p { color:red; color{;color:maroon}; color:green } /* same with recovery */
</code></pre>
</li>
<li><strong>Malformed statements.</strong> User agents must handle
unexpected tokens encountered while parsing a statement by reading
until the end of the statement, while observing the rules for matching
pairs of (), [], {}, "", and '', and correctly handling escapes. For
example, a malformed statement may contain an unexpected closing brace
or at-keyword. E.g., the following lines are all ignored:
<pre>
p @here {color: red} /* ruleset with unexpected at-keyword "@here" */
@foo @bar; /* at-rule with unexpected at-keyword "@bar" */
}} {{ - }} /* ruleset with unexpected right brace */
) ( {} ) p {color: red } /* ruleset with unexpected right parenthesis */
</pre>
<li><strong>Invalid at-keywords.</strong> User agents must <span
class="index-inst" title="ignore"><a name="x28" href="syndata.html#ignore">ignore</a></span>
an invalid at-keyword together with everything following it, up to and
including the next semicolon (;), the next block ({...}), or the end
of the block (}) that contains the invalid at-keyword, whichever
comes first. For example, consider the following:
<pre class="illegal-example"><code>
@three-dee {
@background-lighting {
azimuth: 30deg;
elevation: 190deg;
}
h1 { color: red }
}
h1 { color: blue }
</code></pre>
<p> The '@three-dee' at-rule is not part of CSS 2.1. Therefore, the whole
at-rule (up to, and including, the third right curly brace) is <span
class="index-inst" title="ignore"><a name="x29" href="syndata.html#ignore">ignored.</a></span> A
CSS 2.1 user agent <span class="index-inst" title="ignore"><a name="x30"
href="syndata.html#ignore">ignores</a></span> it, effectively reducing the style sheet
to:</p>
<pre class="example"><code class="css">
h1 { color: blue }
</code></pre>
<p>Something inside an at-rule that is ignored because it is invalid,
such as an invalid declaration within an @media-rule, does not make
the entire at-rule invalid.
</p>
</li>
<li><strong>Unexpected end of style sheet.</strong>
<p>
User agents must close all open constructs (for example: blocks, parentheses, brackets, rules, strings, and comments) at the end of the
style sheet. For example:
</p>
<pre class="illegal-example"><code>
@media screen {
p:before { content: 'Hello
</code></pre>
<p>
would be treated the same as:
</p>
<pre class="example"><code class="css">
@media screen {
p:before { content: 'Hello'; }
}
</code></pre>
<p>
in a conformant UA.
</p>
</li>
<li><strong>Unexpected end of string.</strong>
<p>
User agents must close strings upon reaching the end of a line, but
then drop the construct (declaration or rule) in which the string
was found. For example:
</p>
<pre><code>
p {
color: green;
font-family: 'Courier New Times
color: red;
color: green;
}
</code></pre>
<p>
...would be treated the same as:
</p>
<pre><code class="css">
p { color: green; color: green; }
</code></pre>
<p>
...because the second declaration (from 'font-family' to the
semicolon after 'color: red') is invalid and is dropped.
</p>
</li>
<li>See also <a href="syndata.html#rule-sets">Rule sets, declaration blocks, and
selectors</a> for parsing rules for declaration blocks.
</li>
</ul>
<h2>4.3 <a name="values">Values</a></h2>
<h3>4.3.1 <a name="numbers">Integers and real numbers</a></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>)
or real number values (denoted by <span class="index-def"
title="<number>::definition of"><a name="value-def-number"
class="value-def"><number></a></span>). Real 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 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.
-0 is equivalent to 0 and is not a negative number.</p>
<p>Note that many properties that allow an integer or real number as a
value actually restrict the value to some range, often to a
non-negative value.
</p>
<h3>4.3.2 <a name="length-units">Lengths</a></h3>
<p>Lengths refer to horizontal or vertical measurements.</p>
<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
a <a href="syndata.html#value-def-number" class="noxref"><span
class="value-inst-number"><number></span></a> (with or without a
decimal point) immediately followed by a unit identifier (e.g., px,
em, etc.). After a zero length, the unit identifier is optional.
</p>
<p> Some properties allow negative length values, 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>
<p>If a negative length value is set on a property that does not allow
negative length values, the declaration is ignored.
</p>
<p><a name="absrel-units">There are two types of length units:
relative and absolute.</a> <a name="x34"><span class="index-def" title="relative
units"><em>Relative length</em></span></a> 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>
<p>Relative units are:</p>
<ul>
<li><strong>em</strong>: the <a href="fonts.html#propdef-font-size" class="noxref"><span class="propinst-font-size">'font-size'</span></a> of the relevant font</li>
<li><strong>ex</strong>: the <span class="descinst">'x-height'</span> of the relevant font</li>
<li><strong>px</strong>: pixels, relative to the viewing device</li>
</ul>
<div class="example"><P style="display:none">Example(s):</P>
<pre><code class="css">
h1 { margin: 0.5em } /* em */
h1 { margin: 1ex } /* ex */
p { font-size: 12px } /* px */
</code></pre>
</div>
<p>The <span class="index-def" title="em (unit)|quad width"><a
name="em-width">'em'</a></span> unit is equal to the computed value of
the <a href="fonts.html#propdef-font-size" class="noxref"><span class="propinst-font-size">'font-size'</span></a> 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. It may be used for vertical or
horizontal measurement. (This unit is also sometimes called the
quad-width in typographic texts.)
</p>
<p>The <span class="index-def" title="x-height|ex (unit)"><a
name="ex">'ex'</a></span> unit is defined by the element's first available
font. The <span class="descinst-x-height">'x-height'</span> is so called
because it is often equal to the height of the lowercase "x". However,
an 'ex' is defined even for fonts that don't contain an "x".</p>
<p>The x-height of a font can be found in different ways. Some fonts
contain reliable metrics for the x-height. If reliable font metrics are
not available, UAs may determine the x-height from the height of a
lowercase glyph. One possible heuristics is to look at how far the glyph
for the lowercase "o" extends below the baseline, and subtract that value
from the top of its bounding box. In the cases where it is impossible or
impractical to determine the x-height, a value of 0.5em should be used.</p>
<div class="example"><P style="display:none">Example(s):</P>
<p>The rule:
</p>
<pre><code class="css">
h1 { line-height: 1.2em }
</code></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:
</p>
<pre><code class="css">
h1 { font-size: 1.2em }
</code></pre>
<p>means that the font-size of "h1" elements will be 20% greater than
the font size inherited by "h1" elements.</p>
</div>
<p>When specified for the root of the <a href="conform.html#doctree">
document tree</a> (e.g., "HTML" in HTML), 'em' and 'ex' refer to
the property's <a href="about.html#initial-value">initial value</a>.
</p>
<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 user agent should rescale
pixel values. It is recommended that the pixel unit refer to the whole
number of device pixels that best approximates the reference pixel. It
is recommended that the <a name="x39"><span class="index-def"
title="reference pixel|pixel"><em>reference pixel</em></span></a> 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.26 mm
(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.20 mm. 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 71 cm (28 inch) results
in a px of 0.26 mm, while a reading distance of 3.5 m
(12 feet) requires a px of 1.3 mm.
</p>
<div class="figure">
<p><img src="images/pixel1.png" alt="Showing that pixels must become
larger if the viewing distance increases"><SPAN class="dlink"> <A name="img-pixel1" href="images/longdesc/pixel1-desc.html" title="Long description for the illustration of a pixel's definition">[D]</A></SPAN> </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="images/pixel2.png" 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"><SPAN class="dlink"> <A name="img-pixel2" href="images/longdesc/pixel2-desc.html" title="Long description for the illustration of reference
vs. device pixel">[D]</A></SPAN></p>
</div>
<p>Child elements do not inherit the relative values specified for
their parent; they inherit the <a
href="cascade.html#computed-value">computed values</a>.</p>
<div class="example"><P style="display:none">Example(s):</P><p>
In the following rules, the computed <a href="text.html#propdef-text-indent" class="noxref"><span
class="propinst-text-indent">'text-indent'</span></a> value of "h1" elements
will be 36px, not 45px, if "h1" is a child of the "body" element.
</p>
<pre><code class="css">
body {
font-size: 12px;
text-indent: 3em; /* i.e., 36px */
}
h1 { font-size: 15px }
</code></pre>
</div>
<p><a name="x41"><span class="index-def" title="absolute length"><em> Absolute
length</em></span></a> units are only useful when the physical properties
of the output medium are known. The absolute units are:
</p>
<ul>
<li><strong>in</strong>: inches — 1 inch is equal to 2.54 centimeters.</li>
<li><strong>cm</strong>: centimeters</li>
<li><strong>mm</strong>: millimeters</li>
<li><strong>pt</strong>: points — the points used by CSS 2.1 are equal to 1/72nd of an inch. </li>
<li><strong>pc</strong>: picas — 1 pica is equal to 12 points.</li>
</ul>
<div class="example"><P style="display:none">Example(s):</P>
<pre><code class="css">
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 */
</code></pre>
</div>
<p>In cases where the <a href="cascade.html#usedValue">used</a> length cannot be supported, user agents must approximate it in the <a
href="cascade.html#actual-value">actual value.</a>
</p>
<h3>4.3.3 <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 a <span class="index-inst"
title="<number>"><a name="x43" href="syndata.html#value-def-number" class="noxref"><span
class="value-inst-number"><number></span></a></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 <a
href="visuren.html#containing-block">containing block</a>). When a
percentage value is set for a property of the <a
href="conform.html#root">root</a> element and the percentage is
defined as referring to the inherited value of some property, the
resultant value is the percentage times the <a
href="about.html#initial-value">initial value</a> of that property.
</p>
<div class="example"><P style="display:none">Example(s):</P><p>
Since child elements (generally) inherit the <a
href="cascade.html#computed-value">computed values</a> of their parent, in
the following example, the children of the P element will inherit a
value of 12px for <a href="visudet.html#propdef-line-height" class="noxref"><span
class="propinst-line-height">'line-height'</span></a>, not the percentage
value (120%):
</p>
<pre><code class="css">
p { font-size: 10px }
p { line-height: 120% } /* 120% of 'font-size' */
</code></pre>
</div>
<h3>4.3.4 <a name="uri">URLs and URIs</a></h3>
<p>URI values (Uniform Resource Identifiers, see <a href="refs.html#ref-RFC3986" rel="biblioentry" class="noxref"><span class="normref">[RFC3986]</span></a>, which
includes URLs, URNs, etc) in this specification are denoted by <span
class="index-def" title="<uri>::definition of"><a
name="value-def-uri" class="value-def"><uri></a></span>. The
functional notation used to designate URIs in property values is
"url()", as in:
</p>
<div class="example"><P style="display:none">Example(s):</P>
<pre><code class="css">
body { background: url("http://www.example.com/pinkish.png") }
</code></pre>
</div>
<p> The format of a URI value is 'url(' followed by optional <a
href="syndata.html#whitespace">white space</a> followed by an optional single quote
(') or double quote (") character followed by the URI
itself, followed by an optional single quote (') or double quote (")
character followed by optional white space followed by
')'. The two quote characters must be the same.
</p>
<div class="example"><P style="display:none">Example(s):</P><p>An example without quotes:
</p>
<pre><code>
li { list-style: url(http://www.example.com/redball.png) disc }
</code></pre>
</div>
<p>
Some characters appearing in an unquoted URI, such as parentheses,
commas, white space characters, single quotes (') and double quotes
("), must be escaped with a backslash so that the resulting URI value
is a URI token: '\(', '\)', '\,'.
</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 <a href="refs.html#ref-RFC3986" rel="biblioentry" class="noxref"><span class="normref">[RFC3986]</span></a>.
</p>
<p> In order to create modular style sheets that are not dependent on
the absolute location of a resource, authors may use relative URIs.
Relative URIs (as defined in <a href="refs.html#ref-RFC3986" rel="biblioentry" class="noxref"><span class="normref">[RFC3986]</span></a>) are resolved to full URIs
using a base URI. RFC 3986, section 5, 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 style="display:none">Example(s):</P>
<p>For example, suppose the following rule:</p>
<pre><code class="css">
body { background: url("yellow") }
</code></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 invalid URIs or URIs that
designate
unavailable or inapplicable resources.
</p>
<h3>4.3.5 <a name="counter">Counters</a></h3>
<p><span class="index-def" title="<counter>, definition of"><a
name="value-def-counter">Counters</a></span> are denoted by
case-sensitive identifiers (see the <a href="generate.html#propdef-counter-increment" class="noxref"><span
class="propinst-counter-increment">'counter-increment'</span></a> and
<a href="generate.html#propdef-counter-reset" class="noxref"><span class="propinst-counter-reset">'counter-reset'</span></a>
properties). To refer to the value of a counter, the notation
<a name="x46"><span class="index-def" title="counter()">
'counter(<identifier>)'</span></a> or 'counter(<identifier>,
<'list-style-type'>)', with optional white space separating the tokens,
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'>)'
with optional white space separating the tokens.
</p>
<p>See <a href="generate.html#scope">"Nested counters and scope"</a>
in the chapter on <a href="generate.html">generated content</a> for
how user agents must determine the value or values of the counter. See
the definition of counter values of the <a href="generate.html#propdef-content" class="noxref"><span
class="propinst-content">'content'</span></a> property for how it must
convert these values to a string.
</p>
<p>In CSS 2.1, the values of counters can
only be referred to from the <a href="generate.html#propdef-content" class="noxref"><span
class="propinst-content">'content'</span></a> 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>
<p>Here is a style sheet that numbers paragraphs (p) for each chapter
(h1). The paragraphs are numbered with roman numerals, followed by a
period and a space:
</p>
<pre><code class="css">
p {counter-increment: par-num}
h1 {counter-reset: par-num}
p:before {content: counter(par-num, upper-roman) ". "}
</code></pre>
</div>
<h3>4.3.6 <a name="color-units">Colors</a></h3>
<p>
A <span class="index-def" title="<color>::definition of"><a
name="value-def-color" class="value-def"><color></a></span>
is either a keyword or a numerical RGB specification.
</p>
<p> The list of color keywords is: aqua, black, blue, fuchsia,
gray, green, lime, maroon, navy, olive, orange, purple, red, silver, teal,
white, and yellow. These 17 colors have the following values:
</p>
<div class="colordiagram" id="TanteksColorDiagram20020613">
<div class="diagramrow">
<span class="colorsquare" style="background:maroon;color:white"><span class="colorname">maroon</span> #800000
</span><span class="colorsquare" style="background:red"><span class="colorname">red</span> #ff0000
</span><span class="colorsquare" style="background:orange"><span class="colorname">orange</span> #ffA500
</span><span class="colorsquare" style="background:yellow"><span class="colorname">yellow</span> #ffff00
</span><span class="colorsquare" style="background:olive;color:white"><span class="colorname">olive</span> #808000</span>
</div>
<div class="diagramrow">
<span class="colorsquare" style="background:purple;color:white"><span class="colorname">purple</span> #800080</span>
<span class="colorsquare" style="background:fuchsia"><span class="colorname">fuchsia</span> #ff00ff</span>
<span class="colorsquare" style="background:white"><span class="colorname">white</span> #ffffff</span>
<span class="colorsquare" style="background:lime"><span class="colorname">lime</span> #00ff00</span>
<span class="colorsquare" style="background:green;color:white"><span class="colorname">green</span> #008000</span>
</div>
<div class="diagramrow" style="padding:0 2.5em">
<span class="colorsquare" style="background:navy;color:white"><span class="colorname">navy</span> #000080</span>
<span class="colorsquare" style="background:blue"><span class="colorname">blue</span> #0000ff</span>
<span class="colorsquare" style="background:aqua"><span class="colorname">aqua</span> #00ffff</span>
<span class="colorsquare" style="background:teal;color:white"><span class="colorname">teal</span> #008080</span>
</div>
<div class="diagramrow" style="padding:0 5em">
<span class="colorsquare" style="background:black;color:white"><span class="colorname">black</span> #000000</span>
<span class="colorsquare" style="background:silver"><span class="colorname">silver</span> #c0c0c0</span>
<span class="colorsquare" style="background:gray;color:white"><span class="colorname">gray</span> #808080</span>
</div>
</div>
<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>
<div class="example"><P style="display:none">Example(s):</P>
<pre><code class="css">
body {color: black; background: white }
h1 { color: maroon }
h2 { color: olive }
</code></pre>
</div>
<p>The RGB color model is used in numerical color
specifications. These examples all specify the same color:
</p>
<div class="example"><P style="display:none">Example(s):</P>
<pre><code class="css">
em { color: #f00 } /* #rgb */
em { color: #ff0000 } /* #rrggbb */
em { color: rgb(255,0,0) }
em { color: rgb(100%, 0%, 0%) }
</code></pre>
</div>
<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 digits, not by adding
zeros. For example, #fb0 expands to #ffbb00. This ensures that
white (#ffffff) can be specified with the short notation (#fff) and
removes any dependencies on the color depth of the display.
</p>
<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 or three percentage values) followed by ')'.
The integer value 255 corresponds to 100%, and to F or FF in the
hexadecimal notation: rgb(255,255,255) = rgb(100%,100%,100%) =
#FFF. <a href="syndata.html#whitespace">White space</a> characters are allowed
around the numerical values.
</p>
<p>All RGB colors are specified in the sRGB color space (see
<a href="refs.html#ref-SRGB" rel="biblioentry" class="noxref"><span class="normref">[SRGB]</span></a>). User agents 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 href="refs.html#ref-COLORIMETRY" rel="biblioentry" class="noxref"><span class="normref">[COLORIMETRY]</span></a>).
</p>
<p><a href="conform.html#conformance">Conforming user agents</a> 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. User agents 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="colors.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.
</p>
<p>Values outside the device gamut should be clipped or
mapped into the gamut when the gamut is known: the red, green,
and blue values must be changed to fall within the range supported by
the device. Users agents may perform higher quality mapping of colors
from one gamut to another. For a typical CRT monitor, whose device
gamut is the same as sRGB, the four rules below are equivalent:
</p>
<div class="example"><P style="display:none">Example(s):</P>
<pre><code class="css">
em { color: rgb(255,0,0) } /* integer range 0 - 255 */
em { color: rgb(300,0,0) } /* clipped to rgb(255,0,0) */
em { color: rgb(255,-10,0) } /* clipped to rgb(255,0,0) */
em { color: rgb(110%, 0%, 0%) } /* clipped to rgb(100%,0%,0%) */
</code></pre>
</div>
<p>Other devices, such as printers, have different gamuts than sRGB;
some colors outside the 0..255 sRGB range will be representable
(inside the device gamut), while other colors inside the 0..255 sRGB
range will be outside the device gamut and will thus be mapped.
</p>
<div class=note><p><em><strong>Note.</strong> Mapping or clipping of
color values should be done to the actual device gamut if known (which
may be larger or smaller than 0..255).</em>
</div>
<h3>4.3.7 <a name="strings">Strings</a></h3>
<p><span class="index-def" title="<string>, definition of"><a
name="value-def-string">Strings</a></span> can either be written
with double quotes or with single quotes. Double quotes cannot occur
inside double quotes, unless escaped (e.g., as '\"' or as
'\22'). Analogously for single quotes (e.g., "\'" or "\27").
</p>
<div class="example"><P style="display:none">Example(s):</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 <a name="x49"><span class="index-inst"
title="newline">newline</span></a>.
To include a newline in a string, use an escape representing the line feed
character in ISO-10646 (U+000A), such as "\A" or "\00000a".
This character represents the generic notion of "newline" in CSS.
See the <a href="generate.html#propdef-content" class="noxref"><span
class="propinst-content">'content'</span></a> property for an example.
</p>
<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 (\). For instance, the following two
selectors are exactly the same:
</p>
<div class="example"><P style="display:none">Example(s):</P>
<pre><code class="css">
a[title="a not s\
o very long title"] {/*...*/}
a[title="a not so very long title"] {/*...*/}
</code></pre>
</div>
<h3>4.3.8 <a name="unsupported-values">Unsupported Values</a></h3>
<p>If a UA does not support a particular value, it should <em>ignore</em> that
value when parsing style sheets, as if that value was an
<a href="syndata.html#illegalvalues">illegal value</a>. For example:
</p>
<div class="example"><P style="display:none">Example(s):</P>
<pre><code class="css">
h3 {
display: inline;
display: run-in;
}
</code></pre>
</div>
<p>
A UA that supports the 'run-in' value for the 'display' property will
accept the first display declaration and then "write over" that value with
the second display declaration. A UA that does not support the 'run-in'
value will process the first display declaration and ignore the second
display declaration.
</p>
<h2>4.4 <a name="charset">CSS style sheet representation</a></h2>
<p>A CSS style sheet is a sequence of characters from the Universal
Character Set (see <a href="refs.html#ref-ISO10646" rel="biblioentry" class="noxref"><span class="normref">[ISO10646]</span></a>). For transmission and
storage, these characters must be <a name="x50"><span class="index-def"
title="character encoding">encoded</span></a> by a character encoding that
supports the set of characters available in US-ASCII (e.g., UTF-8, ISO
8859-x, SHIFT JIS, etc.). For a good introduction to character sets
and character encodings, please consult the HTML 4
specification (<a href="refs.html#ref-HTML4" rel="biblioentry" class="noxref"><span class="informref">[HTML4]</span></a>, chapter 5). See also the XML 1.0
specification (<a href="refs.html#ref-XML10" rel="biblioentry" class="noxref"><span class="informref">[XML10]</span></a>, sections 2.2 and 4.3.3, and Appendix F).
</p>
<p>When a style sheet is embedded in another document, such as in the
STYLE element or "style" attribute of HTML, the style sheet shares the
character encoding of the whole document.
</p>
<p>When a style sheet resides in a separate file, user agents must
observe the following <a name="x51"><span class="index-inst" title="character
encoding::user agent's determination of">priorities</span></a> when
determining a style sheet's <a name="x52"><span class="index-inst" title="character
encoding::default|default::character encoding">character
encoding</span></a> (from highest priority to lowest):
</p>
<ol>
<li>An HTTP "charset" parameter in a "Content-Type" field
(or similar parameters in other protocols)</li>
<li><a name="x54"><span class="index-inst">BOM</span></a> and/or <a name="x55"><span
class="index-inst">@charset</span></a> (see below)</li>
<li><code><link charset=""></code> or other metadata from the linking mechanism (if any)</li>
<li>charset of referring style sheet or document (if any)</li>
<li>Assume UTF-8</li>
</ol>
<p>Authors using an <a name="x56"><span class="index-inst">@charset</span></a> rule must
place the rule at the very beginning of the style sheet, preceded by
no characters. (If a byte order mark is appropriate for the encoding
used, it may precede the @charset rule.)
</p>
<p>After <a name="x57"><span class="index-def">"@charset"</span></a>, authors specify
the name of a character encoding (in quotes). For example:
</p>
<pre class="example"><code class="css">@charset "ISO-8859-1";</code></pre>
<p>@charset must be written literally, i.e., the 10 characters
'@charset "' (lowercase, no backslash escapes), followed by the
encoding name, followed by '";'.
</p>
<p>The name must be a charset name as described in the IANA registry.
See <a href="refs.html#ref-CHARSETS" rel="biblioentry" class="noxref"><span class="informref">[CHARSETS]</span></a> for a complete list of charsets. Authors should use
the charset names marked as "preferred MIME name" in the IANA
registry.
</p>
<p>User agents must support at least the <a name="x58"><span
class="index-inst">UTF-8</span></a> encoding.
</p>
<p>User agents must ignore any @charset rule not at the beginning of the
style sheet. When user agents detect the character encoding using the
BOM and/or the @charset rule, they should follow the following rules:
</p>
<ul>
<li>Except as specified in these rules, all @charset rules are ignored.</li>
<li>The encoding is detected based on the stream of bytes that begins
the style sheet. The following table gives a set of possibilities for
initial byte sequences (written in hexadecimal). The first row that
matches the beginning of the style sheet gives the result of encoding
detection based on the BOM and/or @charset rule. If no rows match, the
encoding cannot be detected based on the BOM and/or @charset rule. The
notation (...)* refers to repetition for which the best match is the one
that repeats as few times as possible. The bytes marked "XX" are those
used to determine the name of the encoding, by treating them, in the
order given, as a sequence of ASCII characters. Bytes marked "YY" are
similar, but need to be transcoded into ASCII as noted. User agents may
ignore entries in the table if they do not support any encodings
relevant to the entry.
<table border="1"
summary="Relationship between initial bytes of sheet and chosen encoding">
<tr><th scope="col">Initial Bytes</th><th scope="col">Result</th></tr>
<tr><td>EF BB BF 40 63 68 61 72 73 65 74 20 22 (XX)* 22 3B</td><td>as specified</td></tr>
<tr><td>EF BB BF</td><td>UTF-8</td></tr>
<tr><td>40 63 68 61 72 73 65 74 20 22 (XX)* 22 3B</td><td>as specified</td></tr>
<tr><td>FE FF 00 40 00 63 00 68 00 61 00 72 00 73 00 65 00 74 00 20 00 22 (00 XX)* 00 22 00 3B</td><td>as specified (with BE endianness if not specified)</td></tr>
<tr><td>00 40 00 63 00 68 00 61 00 72 00 73 00 65 00 74 00 20 00 22 (00 XX)* 00 22 00 3B</td><td>as specified (with BE endianness if not specified)</td></tr>
<tr><td>FF FE 40 00 63 00 68 00 61 00 72 00 73 00 65 00 74 00 20 00 22 00 (XX 00)* 22 00 3B 00</td><td>as specified (with LE endianness if not specified)</td></tr>
<tr><td>40 00 63 00 68 00 61 00 72 00 73 00 65 00 74 00 20 00 22 00 (XX 00)* 22 00 3B 00</td><td>as specified (with LE endianness if not specified)</td></tr>
<tr><td>00 00 FE FF 00 00 00 40 00 00 00 63 00 00 00 68 00 00 00 61 00 00 00 72 00 00 00 73 00 00 00 65 00 00 00 74 00 00 00 20 00 00 00 22 (00 00 00 XX)* 00 00 00 22 00 00 00 3B</td><td>as specified (with BE endianness if not specified)</td></tr>
<tr><td>00 00 00 40 00 00 00 63 00 00 00 68 00 00 00 61 00 00 00 72 00 00 00 73 00 00 00 65 00 00 00 74 00 00 00 20 00 00 00 22 (00 00 00 XX)* 00 00 00 22 00 00 00 3B</td><td>as specified (with BE endianness if not specified)</td></tr>
<tr><td>00 00 FF FE 00 00 40 00 00 00 63 00 00 00 68 00 00 00 61 00 00 00 72 00 00 00 73 00 00 00 65 00 00 00 74 00 00 00 20 00 00 00 22 00 (00 00 XX 00)* 00 00 22 00 00 00 3B 00</td><td>as specified (with 2143 endianness if not specified)</td></tr>
<tr><td>00 00 40 00 00 00 63 00 00 00 68 00 00 00 61 00 00 00 72 00 00 00 73 00 00 00 65 00 00 00 74 00 00 00 20 00 00 00 22 00 (00 00 XX 00)* 00 00 22 00 00 00 3B 00</td><td>as specified (with 2143 endianness if not specified)</td></tr>
<tr><td>FE FF 00 00 00 40 00 00 00 63 00 00 00 68 00 00 00 61 00 00 00 72 00 00 00 73 00 00 00 65 00 00 00 74 00 00 00 20 00 00 00 22 00 00 (00 XX 00 00)* 00 22 00 00 00 3B 00 00</td><td>as specified (with 3412 endianness if not specified)</td></tr>
<tr><td>00 40 00 00 00 63 00 00 00 68 00 00 00 61 00 00 00 72 00 00 00 73 00 00 00 65 00 00 00 74 00 00 00 20 00 00 00 22 00 00 (00 XX 00 00)* 00 22 00 00 00 3B 00 00</td><td>as specified (with 3412 endianness if not specified)</td></tr>
<tr><td>FF FE 00 00 40 00 00 00 63 00 00 00 68 00 00 00 61 00 00 00 72 00 00 00 73 00 00 00 65 00 00 00 74 00 00 00 20 00 00 00 22 00 00 00 (XX 00 00 00)* 22 00 00 00 3B 00 00 00</td><td>as specified (with LE endianness if not specified)</td></tr>
<tr><td>40 00 00 00 63 00 00 00 68 00 00 00 61 00 00 00 72 00 00 00 73 00 00 00 65 00 00 00 74 00 00 00 20 00 00 00 22 00 00 00 (XX 00 00 00)* 22 00 00 00 3B 00 00 00</td><td>as specified (with LE endianness if not specified)</td></tr>
<tr><td>00 00 FE FF</td><td>UTF-32-BE</td></tr>
<tr><td>FF FE 00 00</td><td>UTF-32-LE</td></tr>
<tr><td>00 00 FF FE</td><td>UTF-32-2143</td></tr>
<tr><td>FE FF 00 00</td><td>UTF-32-3412</td></tr>
<tr><td>FE FF</td><td>UTF-16-BE</td></tr>
<tr><td>FF FE</td><td>UTF-16-LE</td></tr>
<tr><td>7C 83 88 81 99 A2 85 A3 40 7F (YY)* 7F 5E</td><td>as specified, transcoded from EBCDIC to ASCII</td></tr>
<tr><td>AE 83 88 81 99 A2 85 A3 40 FC (YY)* FC 5E</td><td>as specified, transcoded from IBM1026 to ASCII</td></tr>
<tr><td>00 63 68 61 72 73 65 74 20 22 (YY)* 22 3B</td><td>as specified, transcoded from GSM 03.38 to ASCII</td></tr>
<tr><td>analogous patterns</td><td>User agents may
support additional, analogous, patterns if they support encodings
that are not handled by the patterns here</td></tr>
</table>
</li>
<li>If the encoding is detected based on one of the entries in the table
above marked "as specified", the user agent ignores the style sheet if it
does not parse an appropriate @charset rule at the beginning of the
stream of characters resulting from decoding in the chosen @charset.
This ensures that:
<ul>
<li>@charset rules should only function if they are in the
encoding of the style sheet,</li>
<li>byte order marks are ignored only
in encodings that support a byte order mark, and</li>
<li>encoding names cannot contain newlines.</li>
</ul>
</li>
</ul>
<p>User agents must ignore style sheets in unknown encodings.</p>
<h3>4.4.1 <a name="escaping">Referring to characters not represented in a character encoding</a></h3>
<p>A style sheet may have to refer to characters that cannot be
represented in the current character encoding. These characters must
be written as <a href="syndata.html#escaped-characters">escaped</a> references to
ISO 10646 characters. These escapes serve the same purpose as numeric
character references in HTML or XML documents (see <a href="refs.html#ref-HTML4" rel="biblioentry" class="noxref"><span class="normref">[HTML4]</span></a>,
chapters 5 and 25).
</p>
<p>The character escape mechanism should be used when only a few
characters must be represented this way. If most of a style sheet
requires escaping, authors should encode it with a more appropriate
encoding (e.g., if the style sheet contains a lot of Greek characters,
authors might use "ISO-8859-7" or "UTF-8").
</p>
<p>Intermediate processors using a different character encoding may
translate these escaped sequences into byte sequences of that
encoding. Intermediate processors must not, on
the other hand, alter escape sequences that cancel the special meaning
of an ASCII character.
</p>
<p><a href="conform.html#conformance">Conforming user agents</a> must
correctly map to ISO-10646 all characters in any character encodings
that they recognize (or they must behave as if they did).
</p>
<p>For example, a style sheet 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".
</p>
<div class="note"><p>
<em><strong>Note.</strong>
In HTML 4,
numeric character references are interpreted in "style" attribute
values but not in the content of the STYLE element. Because of this
asymmetry, we recommend that authors use the CSS character
escape mechanism rather than numeric character references
for both the "style" attribute and the STYLE element.
For example, we recommend:</em></p>
<pre class="html-example"><code class="html">
<SPAN style="font-family: L\FC beck">...</SPAN>
</code></pre>
<p><em>rather than:</em></p>
<pre class="html-example"><code class="html">
<SPAN style="font-family: L&#252;beck">...</SPAN>
</code></pre>
</div>
<hr class="navbar">
<div class="navbar">
<p><a href="conform.html">previous</a>
<a href="selector.html">next</a>
<a href="cover.html#minitoc">contents</a>
<a href="propidx.html">properties</a>
<a href="indexlist.html">index</a>
</div>
</body>
</html>
|