common-microsyntaxes.html
118 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
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
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html lang="en-US-x-Hixie" ><head><title>2.5 Common microsyntaxes — HTML5 </title><style type="text/css">
pre { margin-left: 2em; white-space: pre-wrap; }
h2 { margin: 3em 0 1em 0; }
h3 { margin: 2.5em 0 1em 0; }
h4 { margin: 2.5em 0 0.75em 0; }
h5, h6 { margin: 2.5em 0 1em; }
h1 + h2, h1 + h2 + h2 { margin: 0.75em 0 0.75em; }
h2 + h3, h3 + h4, h4 + h5, h5 + h6 { margin-top: 0.5em; }
p { margin: 1em 0; }
hr:not(.top) { display: block; background: none; border: none; padding: 0; margin: 2em 0; height: auto; }
dl, dd { margin-top: 0; margin-bottom: 0; }
dt { margin-top: 0.75em; margin-bottom: 0.25em; clear: left; }
dt + dt { margin-top: 0; }
dd dt { margin-top: 0.25em; margin-bottom: 0; }
dd p { margin-top: 0; }
dd dl + p { margin-top: 1em; }
dd table + p { margin-top: 1em; }
p + * > li, dd li { margin: 1em 0; }
dt, dfn { font-weight: bold; font-style: normal; }
dt dfn { font-style: italic; }
pre, code { font-size: inherit; font-family: monospace; font-variant: normal; }
pre strong { color: black; font: inherit; font-weight: bold; background: yellow; }
pre em { font-weight: bolder; font-style: normal; }
@media screen { code { color: orangered; } code :link, code :visited { color: inherit; } }
var sub { vertical-align: bottom; font-size: smaller; position: relative; top: 0.1em; }
table { border-collapse: collapse; border-style: hidden hidden none hidden; }
table thead, table tbody { border-bottom: solid; }
table tbody th:first-child { border-left: solid; }
table tbody th { text-align: left; }
table td, table th { border-left: solid; border-right: solid; border-bottom: solid thin; vertical-align: top; padding: 0.2em; }
blockquote { margin: 0 0 0 2em; border: 0; padding: 0; font-style: italic; }
.bad, .bad *:not(.XXX) { color: gray; border-color: gray; background: transparent; }
.matrix, .matrix td { border: none; text-align: right; }
.matrix { margin-left: 2em; }
.dice-example { border-collapse: collapse; border-style: hidden solid solid hidden; border-width: thin; margin-left: 3em; }
.dice-example caption { width: 30em; font-size: smaller; font-style: italic; padding: 0.75em 0; text-align: left; }
.dice-example td, .dice-example th { border: solid thin; width: 1.35em; height: 1.05em; text-align: center; padding: 0; }
.toc dfn, h1 dfn, h2 dfn, h3 dfn, h4 dfn, h5 dfn, h6 dfn { font: inherit; }
img.extra { float: right; }
pre.idl { border: solid thin; background: #EEEEEE; color: black; padding: 0.5em 1em; }
pre.idl :link, pre.idl :visited { color: inherit; background: transparent; }
pre.css { border: solid thin; background: #FFFFEE; color: black; padding: 0.5em 1em; }
pre.css:first-line { color: #AAAA50; }
dl.domintro { color: green; margin: 2em 0 2em 2em; padding: 0.5em 1em; border: none; background: #DDFFDD; }
hr + dl.domintro, div.impl + dl.domintro { margin-top: 2.5em; margin-bottom: 1.5em; }
dl.domintro dt, dl.domintro dt * { color: black; text-decoration: none; }
dl.domintro dd { margin: 0.5em 0 1em 2em; padding: 0; }
dl.domintro dd p { margin: 0.5em 0; }
dl.switch { padding-left: 2em; }
dl.switch > dt { text-indent: -1.5em; }
dl.switch > dt:before { content: '\21AA'; padding: 0 0.5em 0 0; display: inline-block; width: 1em; text-align: right; line-height: 0.5em; }
dl.triple { padding: 0 0 0 1em; }
dl.triple dt, dl.triple dd { margin: 0; display: inline }
dl.triple dt:after { content: ':'; }
dl.triple dd:after { content: '\A'; white-space: pre; }
.diff-old { text-decoration: line-through; color: silver; background: transparent; }
.diff-chg, .diff-new { text-decoration: underline; color: green; background: transparent; }
a .diff-new { border-bottom: 1px blue solid; }
h2 { page-break-before: always; }
h1, h2, h3, h4, h5, h6 { page-break-after: avoid; }
h1 + h2, hr + h2.no-toc { page-break-before: auto; }
p > span:not([title=""]):not([class="XXX"]):not([class="impl"]):not([class="note"]),
li > span:not([title=""]):not([class="XXX"]):not([class="impl"]):not([class="note"]), { border-bottom: solid #9999CC; }
div.head { margin: 0 0 1em; padding: 1em 0 0 0; }
div.head p { margin: 0; }
div.head h1 { margin: 0; }
div.head .logo { float: right; margin: 0 1em; }
div.head .logo img { border: none } /* remove border from top image */
div.head dl { margin: 1em 0; }
div.head p.copyright, div.head p.alt { font-size: x-small; font-style: oblique; margin: 0; }
body > .toc > li { margin-top: 1em; margin-bottom: 1em; }
body > .toc.brief > li { margin-top: 0.35em; margin-bottom: 0.35em; }
body > .toc > li > * { margin-bottom: 0.5em; }
body > .toc > li > * > li > * { margin-bottom: 0.25em; }
.toc, .toc li { list-style: none; }
.brief { margin-top: 1em; margin-bottom: 1em; line-height: 1.1; }
.brief li { margin: 0; padding: 0; }
.brief li p { margin: 0; padding: 0; }
.category-list { margin-top: -0.75em; margin-bottom: 1em; line-height: 1.5; }
.category-list::before { content: '\21D2\A0'; font-size: 1.2em; font-weight: 900; }
.category-list li { display: inline; }
.category-list li:not(:last-child)::after { content: ', '; }
.category-list li > span, .category-list li > a { text-transform: lowercase; }
.category-list li * { text-transform: none; } /* don't affect <code> nested in <a> */
.XXX { color: #E50000; background: white; border: solid red; padding: 0.5em; margin: 1em 0; }
.XXX > :first-child { margin-top: 0; }
p .XXX { line-height: 3em; }
.annotation { border: solid thin black; background: #0C479D; color: white; position: relative; margin: 8px 0 20px 0; }
.annotation:before { position: absolute; left: 0; top: 0; width: 100%; height: 100%; margin: 6px -6px -6px 6px; background: #333333; z-index: -1; content: ''; }
.annotation :link, .annotation :visited { color: inherit; }
.annotation :link:hover, .annotation :visited:hover { background: transparent; }
.annotation span { border: none ! important; }
.note { color: green; background: transparent; font-family: sans-serif; }
.warning { color: red; background: transparent; }
.note, .warning { font-weight: bolder; font-style: italic; }
p.note, div.note { padding: 0.5em 2em; }
span.note { padding: 0 2em; }
.note p:first-child, .warning p:first-child { margin-top: 0; }
.note p:last-child, .warning p:last-child { margin-bottom: 0; }
.warning:before { font-style: normal; }
p.note:before { content: 'Note: '; }
p.warning:before { content: '\26A0 Warning! '; }
.bookkeeping:before { display: block; content: 'Bookkeeping details'; font-weight: bolder; font-style: italic; }
.bookkeeping { font-size: 0.8em; margin: 2em 0; }
.bookkeeping p { margin: 0.5em 2em; display: list-item; list-style: square; }
.bookkeeping dt { margin: 0.5em 2em 0; }
.bookkeeping dd { margin: 0 3em 0.5em; }
h4 { position: relative; z-index: 3; }
h4 + .element, h4 + div + .element { margin-top: -2.5em; padding-top: 2em; }
.element {
background: #EEEEFF;
color: black;
margin: 0 0 1em 0.15em;
padding: 0 1em 0.25em 0.75em;
border-left: solid #9999FF 0.25em;
position: relative;
z-index: 1;
}
.element:before {
position: absolute;
z-index: 2;
top: 0;
left: -1.15em;
height: 2em;
width: 0.9em;
background: #EEEEFF;
content: ' ';
border-style: none none solid solid;
border-color: #9999FF;
border-width: 0.25em;
}
.example { display: block; color: #222222; background: #FCFCFC; border-left: double; margin-left: 2em; padding-left: 1em; }
td > .example:only-child { margin: 0 0 0 0.1em; }
ul.domTree, ul.domTree ul { padding: 0 0 0 1em; margin: 0; }
ul.domTree li { padding: 0; margin: 0; list-style: none; position: relative; }
ul.domTree li li { list-style: none; }
ul.domTree li:first-child::before { position: absolute; top: 0; height: 0.6em; left: -0.75em; width: 0.5em; border-style: none none solid solid; content: ''; border-width: 0.1em; }
ul.domTree li:not(:last-child)::after { position: absolute; top: 0; bottom: -0.6em; left: -0.75em; width: 0.5em; border-style: none none solid solid; content: ''; border-width: 0.1em; }
ul.domTree span { font-style: italic; font-family: serif; }
ul.domTree .t1 code { color: purple; font-weight: bold; }
ul.domTree .t2 { font-style: normal; font-family: monospace; }
ul.domTree .t2 .name { color: black; font-weight: bold; }
ul.domTree .t2 .value { color: blue; font-weight: normal; }
ul.domTree .t3 code, .domTree .t4 code, .domTree .t5 code { color: gray; }
ul.domTree .t7 code, .domTree .t8 code { color: green; }
ul.domTree .t10 code { color: teal; }
body.dfnEnabled dfn { cursor: pointer; }
.dfnPanel {
display: inline;
position: absolute;
z-index: 10;
height: auto;
width: auto;
padding: 0.5em 0.75em;
font: small sans-serif, Droid Sans Fallback;
background: #DDDDDD;
color: black;
border: outset 0.2em;
}
.dfnPanel * { margin: 0; padding: 0; font: inherit; text-indent: 0; }
.dfnPanel :link, .dfnPanel :visited { color: black; }
.dfnPanel p { font-weight: bolder; }
.dfnPanel * + p { margin-top: 0.25em; }
.dfnPanel li { list-style-position: inside; }
#configUI { position: absolute; z-index: 20; top: 10em; right: 1em; width: 11em; font-size: small; }
#configUI p { margin: 0.5em 0; padding: 0.3em; background: #EEEEEE; color: black; border: inset thin; }
#configUI p label { display: block; }
#configUI #updateUI, #configUI .loginUI { text-align: center; }
#configUI input[type=button] { display: block; margin: auto; }
fieldset { margin: 1em; padding: 0.5em 1em; }
fieldset > legend + * { margin-top: 0; }
fieldset > :last-child { margin-bottom: 0; }
fieldset p { margin: 0.5em 0; }
.stability {
position: fixed;
bottom: 0;
left: 0; right: 0;
margin: 0 auto 0 auto !important;
z-index: 1000;
width: 50%;
background: maroon; color: yellow;
-webkit-border-radius: 1em 1em 0 0;
-moz-border-radius: 1em 1em 0 0;
border-radius: 1em 1em 0 0;
-moz-box-shadow: 0 0 1em #500;
-webkit-box-shadow: 0 0 1em #500;
box-shadow: 0 0 1em red;
padding: 0.5em 1em;
text-align: center;
}
.stability strong {
display: block;
}
.stability input {
appearance: none; margin: 0; border: 0; padding: 0.25em 0.5em; background: transparent; color: black;
position: absolute; top: -0.5em; right: 0; font: 1.25em sans-serif; text-align: center;
}
.stability input:hover {
color: white;
text-shadow: 0 0 2px black;
}
.stability input:active {
padding: 0.3em 0.45em 0.2em 0.55em;
}
.stability :link, .stability :visited,
.stability :link:hover, .stability :visited:hover {
background: transparent;
color: white;
}
</style><link href="data:text/css,.impl%20%7B%20display:%20none;%20%7D%0Ahtml%20%7B%20border:%20solid%20yellow;%20%7D%20.domintro:before%20%7B%20display:%20none;%20%7D" id="author" rel="alternate stylesheet" title="Author documentation only"><link href="data:text/css,.impl%20%7B%20background:%20%23FFEEEE;%20%7D%20.domintro:before%20%7B%20background:%20%23FFEEEE;%20%7D" id="highlight" rel="alternate stylesheet" title="Highlight implementation
requirements"><link href="http://www.w3.org/StyleSheets/TR/W3C-WD" rel="stylesheet" type="text/css"><style type="text/css">
.applies thead th > * { display: block; }
.applies thead code { display: block; }
.applies tbody th { whitespace: nowrap; }
.applies td { text-align: center; }
.applies .yes { background: yellow; }
.matrix, .matrix td { border: hidden; text-align: right; }
.matrix { margin-left: 2em; }
.dice-example { border-collapse: collapse; border-style: hidden solid solid hidden; border-width: thin; margin-left: 3em; }
.dice-example caption { width: 30em; font-size: smaller; font-style: italic; padding: 0.75em 0; text-align: left; }
.dice-example td, .dice-example th { border: solid thin; width: 1.35em; height: 1.05em; text-align: center; padding: 0; }
td.eg { border-width: thin; text-align: center; }
#table-example-1 { border: solid thin; border-collapse: collapse; margin-left: 3em; }
#table-example-1 * { font-family: "Essays1743", serif; line-height: 1.01em; }
#table-example-1 caption { padding-bottom: 0.5em; }
#table-example-1 thead, #table-example-1 tbody { border: none; }
#table-example-1 th, #table-example-1 td { border: solid thin; }
#table-example-1 th { font-weight: normal; }
#table-example-1 td { border-style: none solid; vertical-align: top; }
#table-example-1 th { padding: 0.5em; vertical-align: middle; text-align: center; }
#table-example-1 tbody tr:first-child td { padding-top: 0.5em; }
#table-example-1 tbody tr:last-child td { padding-bottom: 1.5em; }
#table-example-1 tbody td:first-child { padding-left: 2.5em; padding-right: 0; width: 9em; }
#table-example-1 tbody td:first-child::after { content: leader(". "); }
#table-example-1 tbody td { padding-left: 2em; padding-right: 2em; }
#table-example-1 tbody td:first-child + td { width: 10em; }
#table-example-1 tbody td:first-child + td ~ td { width: 2.5em; }
#table-example-1 tbody td:first-child + td + td + td ~ td { width: 1.25em; }
.apple-table-examples { border: none; border-collapse: separate; border-spacing: 1.5em 0em; width: 40em; margin-left: 3em; }
.apple-table-examples * { font-family: "Times", serif; }
.apple-table-examples td, .apple-table-examples th { border: none; white-space: nowrap; padding-top: 0; padding-bottom: 0; }
.apple-table-examples tbody th:first-child { border-left: none; width: 100%; }
.apple-table-examples thead th:first-child ~ th { font-size: smaller; font-weight: bolder; border-bottom: solid 2px; text-align: center; }
.apple-table-examples tbody th::after, .apple-table-examples tfoot th::after { content: leader(". ") }
.apple-table-examples tbody th, .apple-table-examples tfoot th { font: inherit; text-align: left; }
.apple-table-examples td { text-align: right; vertical-align: top; }
.apple-table-examples.e1 tbody tr:last-child td { border-bottom: solid 1px; }
.apple-table-examples.e1 tbody + tbody tr:last-child td { border-bottom: double 3px; }
.apple-table-examples.e2 th[scope=row] { padding-left: 1em; }
.apple-table-examples sup { line-height: 0; }
.details-example img { vertical-align: top; }
#base64-table {
white-space: nowrap;
font-size: 0.6em;
column-width: 6em;
column-count: 5;
column-gap: 1em;
-moz-column-width: 6em;
-moz-column-count: 5;
-moz-column-gap: 1em;
-webkit-column-width: 6em;
-webkit-column-count: 5;
-webkit-column-gap: 1em;
}
#base64-table thead { display: none; }
#base64-table * { border: none; }
#base64-table tbody td:first-child:after { content: ':'; }
#base64-table tbody td:last-child { text-align: right; }
#named-character-references-table {
white-space: nowrap;
font-size: 0.6em;
column-width: 30em;
column-gap: 1em;
-moz-column-width: 30em;
-moz-column-gap: 1em;
-webkit-column-width: 30em;
-webkit-column-gap: 1em;
}
#named-character-references-table > table > tbody > tr > td:first-child + td,
#named-character-references-table > table > tbody > tr > td:last-child { text-align: center; }
#named-character-references-table > table > tbody > tr > td:last-child:hover > span { position: absolute; top: auto; left: auto; margin-left: 0.5em; line-height: 1.2; font-size: 5em; border: outset; padding: 0.25em 0.5em; background: white; width: 1.25em; height: auto; text-align: center; }
#named-character-references-table > table > tbody > tr#entity-CounterClockwiseContourIntegral > td:first-child { font-size: 0.5em; }
.glyph.control { color: red; }
@font-face {
font-family: 'Essays1743';
src: url('http://www.whatwg.org/specs/web-apps/current-work/fonts/Essays1743.ttf');
}
@font-face {
font-family: 'Essays1743';
font-weight: bold;
src: url('http://www.whatwg.org/specs/web-apps/current-work/fonts/Essays1743-Bold.ttf');
}
@font-face {
font-family: 'Essays1743';
font-style: italic;
src: url('http://www.whatwg.org/specs/web-apps/current-work/fonts/Essays1743-Italic.ttf');
}
@font-face {
font-family: 'Essays1743';
font-style: italic;
font-weight: bold;
src: url('http://www.whatwg.org/specs/web-apps/current-work/fonts/Essays1743-BoldItalic.ttf');
}
</style><style type="text/css">
.domintro:before { display: table; margin: -1em -0.5em -0.5em auto; width: auto; content: 'This box is non-normative. Implementation requirements are given below this box.'; color: black; font-style: italic; border: solid 2px; background: white; padding: 0 0.25em; }
</style><script type="text/javascript">
function getCookie(name) {
var params = location.search.substr(1).split("&");
for (var index = 0; index < params.length; index++) {
if (params[index] == name)
return "1";
var data = params[index].split("=");
if (data[0] == name)
return unescape(data[1]);
}
var cookies = document.cookie.split("; ");
for (var index = 0; index < cookies.length; index++) {
var data = cookies[index].split("=");
if (data[0] == name)
return unescape(data[1]);
}
return null;
}
</script>
<script src="link-fixup.js" type="text/javascript"></script>
<link href="style.css" rel="stylesheet"><link href="infrastructure.html" title="2 Common infrastructure" rel="prev">
<link href="spec.html#contents" title="Table of contents" rel="index">
<link href="urls.html" title="2.6 URLs" rel="next">
</head><body><div class="head" id="head">
<div id="multipage-common">
<p class="stability" id="wip"><strong>This is a work in
progress!</strong> For the latest updates from the HTML WG, possibly
including important bug fixes, please look at the <a href="http://dev.w3.org/html5/spec/Overview.html">editor's draft</a> instead.
There may also be a more
<a href="http://www.w3.org/TR/html5">up-to-date Working Draft</a>
with changes based on resolution of Last Call issues.
<input onclick="closeWarning(this.parentNode)" type="button" value="╳⃝"></p>
<script type="text/javascript">
function closeWarning(element) {
element.parentNode.removeChild(element);
var date = new Date();
date.setDate(date.getDate()+4);
document.cookie = 'hide-obsolescence-warning=1; expires=' + date.toGMTString();
}
if (getCookie('hide-obsolescence-warning') == '1')
setTimeout(function () { document.getElementById('wip').parentNode.removeChild(document.getElementById('wip')); }, 2000);
</script></div>
<p><a href="http://www.w3.org/"><img alt="W3C" height="48" src="http://www.w3.org/Icons/w3c_home" width="72"></a></p>
<h1>HTML5</h1>
</div><div>
<a href="infrastructure.html" class="prev">2 Common infrastructure</a> –
<a href="spec.html#contents">Table of contents</a> –
<a href="urls.html" class="next">2.6 URLs</a>
<ol class="toc"><li><ol><li><a href="common-microsyntaxes.html#common-microsyntaxes"><span class="secno">2.5 </span>Common microsyntaxes</a>
<ol><li><a href="common-microsyntaxes.html#common-parser-idioms"><span class="secno">2.5.1 </span>Common parser idioms</a></li><li><a href="common-microsyntaxes.html#boolean-attributes"><span class="secno">2.5.2 </span>Boolean attributes</a></li><li><a href="common-microsyntaxes.html#keywords-and-enumerated-attributes"><span class="secno">2.5.3 </span>Keywords and enumerated attributes</a></li><li><a href="common-microsyntaxes.html#numbers"><span class="secno">2.5.4 </span>Numbers</a>
<ol><li><a href="common-microsyntaxes.html#non-negative-integers"><span class="secno">2.5.4.1 </span>Non-negative integers</a></li><li><a href="common-microsyntaxes.html#signed-integers"><span class="secno">2.5.4.2 </span>Signed integers</a></li><li><a href="common-microsyntaxes.html#real-numbers"><span class="secno">2.5.4.3 </span>Real numbers</a></li><li><a href="common-microsyntaxes.html#percentages-and-dimensions"><span class="secno">2.5.4.4 </span>Percentages and lengths</a></li><li><a href="common-microsyntaxes.html#lists-of-integers"><span class="secno">2.5.4.5 </span>Lists of integers</a></li><li><a href="common-microsyntaxes.html#lists-of-dimensions"><span class="secno">2.5.4.6 </span>Lists of dimensions</a></li></ol></li><li><a href="common-microsyntaxes.html#dates-and-times"><span class="secno">2.5.5 </span>Dates and times</a>
<ol><li><a href="common-microsyntaxes.html#months"><span class="secno">2.5.5.1 </span>Months</a></li><li><a href="common-microsyntaxes.html#dates"><span class="secno">2.5.5.2 </span>Dates</a></li><li><a href="common-microsyntaxes.html#times"><span class="secno">2.5.5.3 </span>Times</a></li><li><a href="common-microsyntaxes.html#local-dates-and-times"><span class="secno">2.5.5.4 </span>Local dates and times</a></li><li><a href="common-microsyntaxes.html#global-dates-and-times"><span class="secno">2.5.5.5 </span>Global dates and times</a></li><li><a href="common-microsyntaxes.html#weeks"><span class="secno">2.5.5.6 </span>Weeks</a></li><li><a href="common-microsyntaxes.html#vaguer-moments-in-time"><span class="secno">2.5.5.7 </span>Vaguer moments in time</a></li></ol></li><li><a href="common-microsyntaxes.html#colors"><span class="secno">2.5.6 </span>Colors</a></li><li><a href="common-microsyntaxes.html#space-separated-tokens"><span class="secno">2.5.7 </span>Space-separated tokens</a></li><li><a href="common-microsyntaxes.html#comma-separated-tokens"><span class="secno">2.5.8 </span>Comma-separated tokens</a></li><li><a href="common-microsyntaxes.html#syntax-references"><span class="secno">2.5.9 </span>References</a></li><li><a href="common-microsyntaxes.html#mq"><span class="secno">2.5.10 </span>Media queries</a></li></ol></li></ol></li></ol></div>
<h3 id="common-microsyntaxes"><span class="secno">2.5 </span>Common microsyntaxes</h3><p>There are various places in HTML that accept particular data
types, such as dates or numbers. This section describes what the
conformance criteria for content in those formats is, and how to
parse them.</p><div class="impl">
<p class="note">Implementors are strongly urged to carefully examine
any third-party libraries they might consider using to implement the
parsing of syntaxes described below. For example, date libraries are
likely to implement error handling behavior that differs from what
is required in this specification, since error-handling behavior is
often not defined in specifications that describe date syntaxes
similar to those used in this specification, and thus
implementations tend to vary greatly in how they handle errors.</p>
</div><div class="impl">
<h4 id="common-parser-idioms"><span class="secno">2.5.1 </span>Common parser idioms</h4>
<p>The <dfn id="space-character" title="space character">space characters</dfn>, for the
purposes of this specification, are U+0020 SPACE, U+0009 CHARACTER
TABULATION (tab), U+000A LINE FEED (LF), U+000C FORM FEED (FF), and
U+000D CARRIAGE RETURN (CR).</p>
<p>The <dfn id="white_space" title="White_Space">White_Space characters</dfn> are
those that have the Unicode property "White_Space" in the Unicode
<code title="">PropList.txt</code> data file. <a href="references.html#refsUNICODE">[UNICODE]</a></p>
<p class="note">This should not be confused with the "White_Space"
value (abbreviated "WS") of the "Bidi_Class" property in the <code title="">Unicode.txt</code> data file.</p>
<p>The <dfn id="alphanumeric-ascii-characters">alphanumeric ASCII characters</dfn> are those in the
ranges U+0030 DIGIT ZERO (0) to U+0039 DIGIT NINE (9), U+0041 LATIN
CAPITAL LETTER A to U+005A LATIN CAPITAL LETTER Z, U+0061 LATIN
SMALL LETTER A to U+007A LATIN SMALL LETTER Z.</p>
<p>Some of the micro-parsers described below follow the pattern of
having an <var title="">input</var> variable that holds the string
being parsed, and having a <var title="">position</var> variable
pointing at the next character to parse in <var title="">input</var>.</p>
<p>For parsers based on this pattern, a step that requires the user
agent to <dfn id="collect-a-sequence-of-characters">collect a sequence of characters</dfn> means that the
following algorithm must be run, with <var title="">characters</var>
being the set of characters that can be collected:</p>
<ol><li><p>Let <var title="">input</var> and <var title="">position</var> be the same variables as those of the same
name in the algorithm that invoked these steps.</p></li>
<li><p>Let <var title="">result</var> be the empty string.</p></li>
<li><p>While <var title="">position</var> doesn't point past the
end of <var title="">input</var> and the character at <var title="">position</var> is one of the <var title="">characters</var>, append that character to the end of <var title="">result</var> and advance <var title="">position</var> to
the next character in <var title="">input</var>.</p></li>
<li><p>Return <var title="">result</var>.</p></li>
</ol><p>The step <dfn id="skip-whitespace">skip whitespace</dfn> means that the user agent
must <a href="#collect-a-sequence-of-characters">collect a sequence of characters</a> that are <a href="#space-character" title="space character">space characters</a>. The step <dfn id="skip-white_space-characters">skip
White_Space characters</dfn> means that the user agent must
<a href="#collect-a-sequence-of-characters">collect a sequence of characters</a> that are
<a href="#white_space">White_Space</a> characters. In both cases, the collected
characters are not used. <a href="references.html#refsUNICODE">[UNICODE]</a></p>
<p>When a user agent is to <dfn id="strip-line-breaks">strip line breaks</dfn> from a
string, the user agent must remove any U+000A LINE FEED (LF) and
U+000D CARRIAGE RETURN (CR) characters from that string.</p>
<p>When a user agent is to <dfn id="strip-leading-and-trailing-whitespace">strip leading and trailing
whitespace</dfn> from a string, the user agent must remove all <a href="#space-character" title="space character">space characters</a> that are at the
start or end of the string.</p>
<p>The <dfn id="code-point-length">code-point length</dfn> of a string is the number of
Unicode code points in that string.</p>
</div><h4 id="boolean-attributes"><span class="secno">2.5.2 </span>Boolean attributes</h4><p>A number of attributes are <dfn id="boolean-attribute" title="boolean attribute">boolean
attributes</dfn>. The presence of a boolean attribute on an element
represents the true value, and the absence of the attribute
represents the false value.</p><p>If the attribute is present, its value must either be the empty
string or a value that is an <a href="infrastructure.html#ascii-case-insensitive">ASCII case-insensitive</a>
match for the attribute's canonical name, with no leading or
trailing whitespace.</p><p class="note">The values "true" and "false" are not allowed on
boolean attributes. To represent a false value, the attribute has to
be omitted altogether.</p><div class="example">
<p>Here is an example of a checkbox that is checked and disabled.
The <code title="attr-input-checked"><a href="the-input-element.html#attr-input-checked">checked</a></code> and <code title="attr-fe-disabled"><a href="association-of-controls-and-forms.html#attr-fe-disabled">disabled</a></code> attributes are the
boolean attributes.</p>
<pre><label><input type=checkbox checked name=cheese disabled> Cheese</label></pre>
<p>This could be equivalently written as this:
</p><pre><label><input type=checkbox checked=checked name=cheese disabled=disabled> Cheese</label></pre>
<p>You can also mix styles; the following is still equivalent:</p>
<pre><label><input type='checkbox' checked name=cheese disabled=""> Cheese</label></pre>
</div><h4 id="keywords-and-enumerated-attributes"><span class="secno">2.5.3 </span>Keywords and enumerated attributes</h4><p>Some attributes are defined as taking one of a finite set of
keywords. Such attributes are called <dfn id="enumerated-attribute" title="enumerated
attribute">enumerated attributes</dfn>. The keywords are each
defined to map to a particular <em>state</em> (several keywords
might map to the same state, in which case some of the keywords are
synonyms of each other; additionally, some of the keywords can be
said to be non-conforming, and are only in the specification for
historical reasons). In addition, two default states can be
given. The first is the <i>invalid value default</i>, the second
is the <i>missing value default</i>.</p><p>If an enumerated attribute is specified, the attribute's value
must be an <a href="infrastructure.html#ascii-case-insensitive">ASCII case-insensitive</a> match for one of the
given keywords that are not said to be non-conforming, with no
leading or trailing whitespace.</p><p>When the attribute is specified, if its value is an <a href="infrastructure.html#ascii-case-insensitive">ASCII
case-insensitive</a> match for one of the given keywords then
that keyword's state is the state that the attribute represents. If
the attribute value matches none of the given keywords, but the
attribute has an <i>invalid value default</i>, then the attribute
represents that state. Otherwise, if the attribute value matches
none of the keywords but there is a <i>missing value default</i>
state defined, then <em>that</em> is the state represented by the
attribute. Otherwise, there is no default, and invalid values must
be ignored.</p><p>When the attribute is <em>not</em> specified, if there is a
<i>missing value default</i> state defined, then that is the state
represented by the (missing) attribute. Otherwise, the absence of
the attribute means that there is no state represented.</p><p class="note">The empty string can be a valid keyword.</p><h4 id="numbers"><span class="secno">2.5.4 </span>Numbers</h4><h5 id="non-negative-integers"><span class="secno">2.5.4.1 </span>Non-negative integers</h5><p>A string is a <dfn id="valid-non-negative-integer">valid non-negative integer</dfn> if it
consists of one or more characters in the range U+0030 DIGIT ZERO
(0) to U+0039 DIGIT NINE (9).</p><p>A <a href="#valid-non-negative-integer">valid non-negative integer</a> represents the number
that is represented in base ten by that string of digits.</p><div class="impl">
<p>The <dfn id="rules-for-parsing-non-negative-integers">rules for parsing non-negative integers</dfn> are as
given in the following algorithm. When invoked, the steps must be
followed in the order given, aborting at the first step that returns
a value. This algorithm will return either zero, a positive integer,
or an error.</p>
<ol><li><p>Let <var title="">input</var> be the string being
parsed.</p></li>
<li><p>Let <var title="">position</var> be a pointer into <var title="">input</var>, initially pointing at the start of the
string.</p></li>
<li><p><a href="#skip-whitespace">Skip whitespace</a>.</p></li>
<li><p>If <var title="">position</var> is past the end of <var title="">input</var>, return an error.</p></li>
<li><p>If the character indicated by <var title="">position</var>
is a U+002B PLUS SIGN character (+), advance <var title="">position</var> to the next character. (The "<code title="">+</code>" is ignored, but it is not conforming.)</p></li>
<li><p>If <var title="">position</var> is past the end of <var title="">input</var>, return an error.</p></li>
<li><p>If the character indicated by <var title="">position</var>
is not one of U+0030 DIGIT ZERO (0) to U+0039 DIGIT NINE (9), then
return an error.</p></li>
<li><p><a href="#collect-a-sequence-of-characters">Collect a sequence of characters</a> in the range
U+0030 DIGIT ZERO (0) to U+0039 DIGIT NINE (9), and interpret the
resulting sequence as a base-ten integer. Let <var title="">value</var> be that integer.</p></li>
<li><p>Return <var title="">value</var>.</p></li>
</ol></div><h5 id="signed-integers"><span class="secno">2.5.4.2 </span>Signed integers</h5><p>A string is a <dfn id="valid-integer">valid integer</dfn> if it consists of one or
more characters in the range U+0030 DIGIT ZERO (0) to U+0039 DIGIT
NINE (9), optionally prefixed with a U+002D HYPHEN-MINUS character
(-).</p><p>A <a href="#valid-integer">valid integer</a> without a U+002D HYPHEN-MINUS (-)
prefix represents the number that is represented in base ten by that
string of digits. A <a href="#valid-integer">valid integer</a> <em>with</em> a
U+002D HYPHEN-MINUS (-) prefix represents the number represented in
base ten by the string of digits that follows the U+002D
HYPHEN-MINUS, subtracted from zero.</p><div class="impl">
<p>The <dfn id="rules-for-parsing-integers">rules for parsing integers</dfn> are similar to the
<a href="#rules-for-parsing-non-negative-integers" title="rules for parsing non-negative integers">rules for
non-negative integers</a>, and are as given in the following
algorithm. When invoked, the steps must be followed in the order
given, aborting at the first step that returns a value. This
algorithm will return either an integer or an error.</p>
<ol><li><p>Let <var title="">input</var> be the string being
parsed.</p></li>
<li><p>Let <var title="">position</var> be a pointer into <var title="">input</var>, initially pointing at the start of the
string.</p></li>
<li><p>Let <var title="">sign</var> have the value
"positive".</p></li>
<li><p><a href="#skip-whitespace">Skip whitespace</a>.</p></li>
<li><p>If <var title="">position</var> is past the end of <var title="">input</var>, return an error.</p></li>
<li>
<p>If the character indicated by <var title="">position</var> (the
first character) is a U+002D HYPHEN-MINUS character (-):</p>
<ol><li>Let <var title="">sign</var> be "negative".</li>
<li>Advance <var title="">position</var> to the next
character.</li>
<li>If <var title="">position</var> is past the end of <var title="">input</var>, return an error.</li>
</ol><p>Otherwise, if the character indicated by <var title="">position</var> (the first character) is a U+002B PLUS
SIGN character (+):</p>
<ol><li>Advance <var title="">position</var> to the next
character. (The "<code title="">+</code>" is ignored, but it is
not conforming.)</li>
<li>If <var title="">position</var> is past the end of <var title="">input</var>, return an error.</li>
</ol></li>
<li><p>If the character indicated by <var title="">position</var>
is not one of U+0030 DIGIT ZERO (0) to U+0039 DIGIT NINE (9), then
return an error.</p></li>
<li><p><a href="#collect-a-sequence-of-characters">Collect a sequence of characters</a> in the range
U+0030 DIGIT ZERO (0) to U+0039 DIGIT NINE (9), and interpret the
resulting sequence as a base-ten integer. Let <var title="">value</var> be that integer.</p></li>
<li><p>If <var title="">sign</var> is "positive", return <var title="">value</var>, otherwise return the result of subtracting
<var title="">value</var> from zero.</p></li>
</ol></div><h5 id="real-numbers"><span class="secno">2.5.4.3 </span>Real numbers</h5><p>A string is a <dfn id="valid-floating-point-number">valid floating point number</dfn> if it
consists of:</p><ol class="brief"><li>Optionally, a U+002D HYPHEN-MINUS character (-).</li>
<li>A series of one or more characters in the range U+0030 DIGIT
ZERO (0) to U+0039 DIGIT NINE (9).</li>
<li>Optionally:
<ol><li>A single U+002E FULL STOP character (.).</li>
<li>A series of one or more characters in the range U+0030 DIGIT
ZERO (0) to U+0039 DIGIT NINE (9).</li>
</ol></li>
<li>Optionally:
<ol><li>Either a U+0065 LATIN SMALL LETTER E character (e) or a
U+0045 LATIN CAPITAL LETTER E character (E).</li>
<li>Optionally, a U+002D HYPHEN-MINUS character (-) or U+002B
PLUS SIGN character (+).</li>
<li>A series of one or more characters in the range U+0030 DIGIT
ZERO (0) to U+0039 DIGIT NINE (9).</li>
</ol></li>
</ol><p>A <a href="#valid-floating-point-number">valid floating point number</a> represents the number
obtained by multiplying the significand by ten raised to the power
of the exponent, where the significand is the first number,
interpreted as base ten (including the decimal point and the number
after the decimal point, if any, and interpreting the significand as
a negative number if the whole string starts with a U+002D
HYPHEN-MINUS character (-) and the number is not zero), and where
the exponent is the number after the E, if any (interpreted as a
negative number if there is a U+002D HYPHEN-MINUS character (-)
between the E and the number and the number is not zero, or else
ignoring a U+002B PLUS SIGN character (+) between the E and the
number if there is one). If there is no E, then the exponent is
treated as zero.</p><p class="note">The Infinity and Not-a-Number (NaN) values are not
<a href="#valid-floating-point-number" title="valid floating point number">valid floating point
numbers</a>.</p><div class="impl">
<p>The <dfn id="best-representation-of-the-number-as-a-floating-point-number" title="best representation of the number as a floating
point number">best representation of the number <var title="">n</var> as a floating point number</dfn> is the string
obtained from applying the JavaScript operator ToString to <var title="">n</var>. The JavaScript operator ToString is not uniquely
determined. When there are multiple possible strings that could be
obtained from the JavaScript operator ToString for a particular
value, the user agent must always return the same string for that
value (though it may differ from the value used by other user
agents).</p>
<p>The <dfn id="rules-for-parsing-floating-point-number-values">rules for parsing floating point number values</dfn> are
as given in the following algorithm. This algorithm must be aborted
at the first step that returns something. This algorithm will return
either a number or an error.</p>
<ol><li><p>Let <var title="">input</var> be the string being
parsed.</p></li>
<li><p>Let <var title="">position</var> be a pointer into <var title="">input</var>, initially pointing at the start of the
string.</p></li>
<li><p>Let <var title="">value</var> have the value 1.</p></li>
<li><p>Let <var title="">divisor</var> have the value 1.</p></li>
<li><p>Let <var title="">exponent</var> have the value 1.</p></li>
<li><p><a href="#skip-whitespace">Skip whitespace</a>.</p></li>
<li><p>If <var title="">position</var> is past the end of <var title="">input</var>, return an error.</p></li>
<li>
<p>If the character indicated by <var title="">position</var> is a
U+002D HYPHEN-MINUS character (-):</p>
<ol><li>Change <var title="">value</var> and <var title="">divisor</var> to −1.</li>
<li>Advance <var title="">position</var> to the next
character.</li>
<li>If <var title="">position</var> is past the end of <var title="">input</var>, return an error.</li>
</ol><p>Otherwise, if the character indicated by <var title="">position</var> (the first character) is a U+002B PLUS
SIGN character (+):</p>
<ol><li>Advance <var title="">position</var> to the next
character. (The "<code title="">+</code>" is ignored, but it is
not conforming.)</li>
<li>If <var title="">position</var> is past the end of <var title="">input</var>, return an error.</li>
</ol></li>
<li><p>If the character indicated by <var title="">position</var>
is not one of U+0030 DIGIT ZERO (0) to U+0039 DIGIT NINE (9), then
return an error.</p></li>
<li><p><a href="#collect-a-sequence-of-characters">Collect a sequence of characters</a> in the range
U+0030 DIGIT ZERO (0) to U+0039 DIGIT NINE (9), and interpret the
resulting sequence as a base-ten integer. Multiply <var title="">value</var> by that integer.</p></li>
<li>If <var title="">position</var> is past the end of <var title="">input</var>, jump to the step labeled
<i>conversion</i>.</li>
<li><p>If the character indicated by <var title="">position</var>
is a U+002E FULL STOP (.), run these substeps:</p>
<ol><li><p>Advance <var title="">position</var> to the next
character.</p></li>
<li><p>If <var title="">position</var> is past the end of <var title="">input</var>, or if the character indicated by <var title="">position</var> is not one of U+0030 DIGIT ZERO (0) to
U+0039 DIGIT NINE (9), U+0065 LATIN SMALL LETTER E (e), or U+0045
LATIN CAPITAL LETTER E (E), then jump to the step labeled
<i>conversion</i>.</p></li>
<li><p>If the character indicated by <var title="">position</var>
is a U+0065 LATIN SMALL LETTER E character (e) or a U+0045 LATIN
CAPITAL LETTER E character (E), skip the remainder of these
substeps.</p>
</li><li><p><i>Fraction loop</i>: Multiply <var title="">divisor</var>
by ten.</p></li>
<li>Add the value of the character indicated by <var title="">position</var>, interpreted as a base-ten digit (0..9)
and divided by <var title="">divisor</var>, to <var title="">value</var>.</li>
<li><p>Advance <var title="">position</var> to the next
character.</p></li>
<li><p>If <var title="">position</var> is past the end of <var title="">input</var>, then jump to the step labeled
<i>conversion</i>.</p></li>
<li><p>If the character indicated by <var title="">position</var>
is one of U+0030 DIGIT ZERO (0) to U+0039 DIGIT NINE (9), jump
back to the step labeled <i>fraction loop</i> in these
substeps.</p></li>
</ol></li>
<li><p>If the character indicated by <var title="">position</var>
is a U+0065 LATIN SMALL LETTER E character (e) or a U+0045 LATIN
CAPITAL LETTER E character (E), run these substeps:</p>
<ol><li><p>Advance <var title="">position</var> to the next
character.</p></li>
<li><p>If <var title="">position</var> is past the end of <var title="">input</var>, then jump to the step labeled
<i>conversion</i>.</p></li>
<li>
<p>If the character indicated by <var title="">position</var> is
a U+002D HYPHEN-MINUS character (-):</p>
<ol><li>Change <var title="">exponent</var> to −1.</li>
<li>Advance <var title="">position</var> to the next
character.</li>
<li><p>If <var title="">position</var> is past the end of <var title="">input</var>, then jump to the step labeled
<i>conversion</i>.</p></li>
</ol><p>Otherwise, if the character indicated by <var title="">position</var> is a U+002B PLUS SIGN character (+):</p>
<ol><li>Advance <var title="">position</var> to the next
character.</li>
<li><p>If <var title="">position</var> is past the end of <var title="">input</var>, then jump to the step labeled
<i>conversion</i>.</p></li>
</ol></li>
<li><p>If the character indicated by <var title="">position</var>
is not one of U+0030 DIGIT ZERO (0) to U+0039 DIGIT NINE (9),
then jump to the step labeled <i>conversion</i>.</p></li>
<li><p><a href="#collect-a-sequence-of-characters">Collect a sequence of characters</a> in the range
U+0030 DIGIT ZERO (0) to U+0039 DIGIT NINE (9), and interpret the
resulting sequence as a base-ten integer. Multiply <var title="">exponent</var> by that integer.</p></li>
<li><p>Multiply <var title="">value</var> by ten raised to the
<var title="">exponent</var>th power.</p></li>
</ol></li>
<li><p><i>Conversion</i>: Let <var title="">S</var> be the set of
finite IEEE 754 double-precision floating point values except
−0, but with two special values added: 2<sup title="">1024</sup> and −2<sup title="">1024</sup>.</p></li>
<li><p>Let <var title="">rounded-value</var> be the number in <var title="">S</var> that is closest to <var title="">value</var>,
selecting the number with an even significand if there are two
equally close values. (The two special values 2<sup title="">1024</sup> and −2<sup title="">1024</sup> are
considered to have even significands for this purpose.)</p></li>
<li><p>If <var title="">rounded-value</var> is 2<sup title="">1024</sup> or −2<sup title="">1024</sup>, return an
error.</p></li>
<li><p>Return <var title="">rounded-value</var>.</p></li>
</ol></div><div class="impl">
<h5 id="percentages-and-dimensions"><span class="secno">2.5.4.4 </span>Percentages and lengths</h5>
<p>The <dfn id="rules-for-parsing-dimension-values">rules for parsing dimension values</dfn> are as given in
the following algorithm. When invoked, the steps must be followed in
the order given, aborting at the first step that returns a
value. This algorithm will return either a number greater than or
equal to 1.0, or an error; if a number is returned, then it is
further categorized as either a percentage or a length.</p>
<ol><li><p>Let <var title="">input</var> be the string being
parsed.</p></li>
<li><p>Let <var title="">position</var> be a pointer into <var title="">input</var>, initially pointing at the start of the
string.</p></li>
<li><p><a href="#skip-whitespace">Skip whitespace</a>.</p></li>
<li><p>If <var title="">position</var> is past the end of <var title="">input</var>, return an error.</p></li>
<li><p>If the character indicated by <var title="">position</var>
is a U+002B PLUS SIGN character (+), advance <var title="">position</var> to the next character.</p></li>
<li><p><a href="#collect-a-sequence-of-characters">Collect a sequence of characters</a> that are
U+0030 DIGIT ZERO (0) characters, and discard them.</p></li>
<li><p>If <var title="">position</var> is past the end of <var title="">input</var>, return an error.</p></li>
<li><p>If the character indicated by <var title="">position</var>
is not one of U+0031 DIGIT ONE (1) to U+0039 DIGIT NINE (9), then
return an error.</p></li>
<li><p><a href="#collect-a-sequence-of-characters">Collect a sequence of characters</a> in the range
U+0030 DIGIT ZERO (0) to U+0039 DIGIT NINE (9), and interpret the
resulting sequence as a base-ten integer. Let <var title="">value</var> be that number.</p></li>
<li><p>If <var title="">position</var> is past the end of <var title="">input</var>, return <var title="">value</var> as a
length.</p></li>
<li>
<p>If the character indicated by <var title="">position</var> is a
U+002E FULL STOP character (.):</p>
<ol><li><p>Advance <var title="">position</var> to the next
character.</p></li>
<li><p>If <var title="">position</var> is past the end of <var title="">input</var>, or if the character indicated by <var title="">position</var> is not one of U+0030 DIGIT ZERO (0) to
U+0039 DIGIT NINE (9), then return <var title="">value</var> as a
length.</p></li>
<li><p>Let <var title="">divisor</var> have the value 1.</p></li>
<li><p><i>Fraction loop</i>: Multiply <var title="">divisor</var>
by ten.</p></li>
<li>Add the value of the character indicated by <var title="">position</var>, interpreted as a base-ten digit (0..9)
and divided by <var title="">divisor</var>, to <var title="">value</var>.</li>
<li><p>Advance <var title="">position</var> to the next
character.</p></li>
<li><p>If <var title="">position</var> is past the end of <var title="">input</var>, then return <var title="">value</var> as a
length.</p></li>
<li><p>If the character indicated by <var title="">position</var>
is one of U+0030 DIGIT ZERO (0) to U+0039 DIGIT NINE (9), return
to the step labeled <i>fraction loop</i> in these
substeps.</p></li>
</ol></li>
<li><p>If <var title="">position</var> is past the end of <var title="">input</var>, return <var title="">value</var> as a
length.</p></li>
<li><p>If the character indicated by <var title="">position</var>
is a U+0025 PERCENT SIGN character (%), return <var title="">value</var> as a percentage.</p></li>
<li><p>Return <var title="">value</var> as a length.</p></li>
</ol></div><h5 id="lists-of-integers"><span class="secno">2.5.4.5 </span>Lists of integers</h5><p>A <dfn id="valid-list-of-integers">valid list of integers</dfn> is a number of <a href="#valid-integer" title="valid integer">valid integers</a> separated by U+002C
COMMA characters, with no other characters (e.g. no <a href="#space-character" title="space character">space characters</a>). In addition, there
might be restrictions on the number of integers that can be given,
or on the range of values allowed.</p><div class="impl">
<p>The <dfn id="rules-for-parsing-a-list-of-integers">rules for parsing a list of integers</dfn> are as
follows:</p>
<ol><li><p>Let <var title="">input</var> be the string being
parsed.</p></li>
<li><p>Let <var title="">position</var> be a pointer into <var title="">input</var>, initially pointing at the start of the
string.</p></li>
<li><p>Let <var title="">numbers</var> be an initially empty list
of integers. This list will be the result of this
algorithm.</p></li>
<li><p>If there is a character in the string <var title="">input</var> at position <var title="">position</var>, and
it is either a U+0020 SPACE, U+002C COMMA, or U+003B SEMICOLON
character, then advance <var title="">position</var> to the next
character in <var title="">input</var>, or to beyond the end of the
string if there are no more characters.</p></li>
<li><p>If <var title="">position</var> points to beyond the end of
<var title="">input</var>, return <var title="">numbers</var> and
abort.</p></li>
<li><p>If the character in the string <var title="">input</var> at
position <var title="">position</var> is a U+0020 SPACE, U+002C
COMMA, or U+003B SEMICOLON character, then return to step 4.</p></li>
<li><p>Let <var title="">negated</var> be false.</p></li>
<li><p>Let <var title="">value</var> be 0.</p></li>
<li><p>Let <var title="">started</var> be false. This variable is
set to true when the parser sees a number or a U+002D HYPHEN-MINUS
character (-).</p></li>
<li><p>Let <var title="">got number</var> be false. This variable
is set to true when the parser sees a number.</p></li>
<li><p>Let <var title="">finished</var> be false. This variable is
set to true to switch parser into a mode where it ignores
characters until the next separator.</p></li>
<li><p>Let <var title="">bogus</var> be false.</p></li>
<li><p><i>Parser</i>: If the character in the string <var title="">input</var> at position <var title="">position</var>
is:</p>
<dl class="switch"><dt>A U+002D HYPHEN-MINUS character</dt>
<dd>
<p>Follow these substeps:</p>
<ol><li>If <var title="">got number</var> is true, let <var title="">finished</var> be true.</li>
<li>If <var title="">finished</var> is true, skip to the next
step in the overall set of steps.</li>
<li>If <var title="">started</var> is true, let <var title="">negated</var> be false.</li>
<li>Otherwise, if <var title="">started</var> is false and if <var title="">bogus</var> is false, let <var title="">negated</var>
be true.</li>
<li>Let <var title="">started</var> be true.</li>
</ol></dd>
<dt>A character in the range U+0030 DIGIT ZERO (0) to U+0039 DIGIT
NINE (9)</dt>
<dd>
<p>Follow these substeps:</p>
<ol><li>If <var title="">finished</var> is true, skip to the next
step in the overall set of steps.</li>
<li>Multiply <var title="">value</var> by ten.</li>
<li>Add the value of the digit, interpreted in base ten, to
<var title="">value</var>.</li>
<li>Let <var title="">started</var> be true.</li>
<li>Let <var title="">got number</var> be true.</li>
</ol></dd>
<dt>A U+0020 SPACE character</dt>
<dt>A U+002C COMMA character</dt>
<dt>A U+003B SEMICOLON character</dt>
<dd>
<p>Follow these substeps:</p>
<ol><li>If <var title="">got number</var> is false, return the <var title="">numbers</var> list and abort. This happens if an entry
in the list has no digits, as in "<code title="">1,2,x,4</code>".</li>
<li>If <var title="">negated</var> is true, then negate <var title="">value</var>.</li>
<li>Append <var title="">value</var> to the <var title="">numbers</var> list.</li>
<li>Jump to step 4 in the overall set of steps.</li>
</ol></dd>
<dt>A character in the range U+0001 to U+001F, U+0021 to U+002B, U+002D to U+002F, U+003A, U+003C to U+0040, U+005B to U+0060, <!-- A-Z --> U+007b to U+007F
(i.e. any other non-alphabetic ASCII character)</dt>
<dd>
<p>Follow these substeps:</p>
<ol><li>If <var title="">got number</var> is true, let <var title="">finished</var> be true.</li>
<li>If <var title="">finished</var> is true, skip to the next
step in the overall set of steps.</li>
<li>Let <var title="">negated</var> be false.</li>
</ol></dd>
<dt>Any other character</dt>
<dd>
<p>Follow these substeps:</p>
<ol><li>If <var title="">finished</var> is true, skip to the next
step in the overall set of steps.</li>
<li>Let <var title="">negated</var> be false.</li>
<li>Let <var title="">bogus</var> be true.</li>
<li>If <var title="">started</var> is true, then return the
<var title="">numbers</var> list, and abort. (The value in <var title="">value</var> is not appended to the list first; it is
dropped.)</li>
</ol></dd>
</dl></li>
<li><p>Advance <var title="">position</var> to the next character
in <var title="">input</var>, or to beyond the end of the string if
there are no more characters.</p></li>
<li><p>If <var title="">position</var> points to a character (and
not to beyond the end of <var title="">input</var>), jump to the
big <i>Parser</i> step above.</p></li>
<li><p>If <var title="">negated</var> is true, then negate <var title="">value</var>.</p></li>
<li><p>If <var title="">got number</var> is true, then append <var title="">value</var> to the <var title="">numbers</var> list.</p></li>
<li><p>Return the <var title="">numbers</var> list and
abort.</p></li>
</ol></div><div class="impl">
<h5 id="lists-of-dimensions"><span class="secno">2.5.4.6 </span>Lists of dimensions</h5>
<p>The <dfn id="rules-for-parsing-a-list-of-dimensions">rules for parsing a list of dimensions</dfn> are as
follows. These rules return a list of zero or more pairs consisting
of a number and a unit, the unit being one of <i>percentage</i>,
<i>relative</i>, and <i>absolute</i>.</p>
<ol><li><p>Let <var title="">raw input</var> be the string being
parsed.</p></li>
<li><p>If the last character in <var title="">raw input</var> is a
U+002C COMMA character (,), then remove that character from <var title="">raw input</var>.</p></li>
<li><p><a href="#split-a-string-on-commas" title="split a string on commas">Split the string <var title="">raw input</var> on commas</a>. Let <var title="">raw
tokens</var> be the resulting list of tokens.</p></li>
<li><p>Let <var title="">result</var> be an empty list of
number/unit pairs.</p></li>
<li>
<p>For each token in <var title="">raw tokens</var>, run the
following substeps:</p>
<ol><li><p>Let <var title="">input</var> be the token.</p></li>
<li><p>Let <var title="">position</var> be a pointer into <var title="">input</var>, initially pointing at the start of the
string.</p></li>
<li><p>Let <var title="">value</var> be the number 0.</p></li>
<li><p>Let <var title="">unit</var> be <i>absolute</i>.</p></li>
<li><p>If <var title="">position</var> is past the end of <var title="">input</var>, set <var title="">unit</var> to
<i>relative</i> and jump to the last substep.</p></li>
<li><p>If the character at <var title="">position</var> is a
character in the range U+0030 DIGIT ZERO (0) to U+0039 DIGIT NINE
(9), <a href="#collect-a-sequence-of-characters">collect a sequence of characters</a> in the range
U+0030 DIGIT ZERO (0) to U+0039 DIGIT NINE (9), interpret the
resulting sequence as an integer in base ten, and increment <var title="">value</var> by that integer.</p></li>
<li>
<p>If the character at <var title="">position</var> is a U+002E
FULL STOP character (.), run these substeps:</p>
<ol><li><p><a href="#collect-a-sequence-of-characters">Collect a sequence of characters</a> consisting
of <a href="#space-character" title="space character">space characters</a> and
characters in the range U+0030 DIGIT ZERO (0) to U+0039 DIGIT
NINE (9). Let <var title="">s</var> be the resulting
sequence.</p></li>
<li><p>Remove all <a href="#space-character" title="space character">space
characters</a> in <var title="">s</var>.</p></li>
<li>
<p>If <var title="">s</var> is not the empty string, run these
subsubsteps:</p>
<ol><li><p>Let <var title="">length</var> be the number of
characters in <var title="">s</var> (after the spaces were
removed).</p></li>
<li><p>Let <var title="">fraction</var> be the result of
interpreting <var title="">s</var> as a base-ten integer, and
then dividing that number by <span title="">10<sup title=""><var title="">length</var></sup></span>.</p></li>
<li><p>Increment <var title="">value</var> by <var title="">fraction</var>.</p></li>
</ol></li>
</ol></li>
<li><p><a href="#skip-whitespace">Skip whitespace</a>.</p></li>
<li>
<p>If the character at <var title="">position</var> is a U+0025
PERCENT SIGN character (%), then set <var title="">unit</var> to
<i>percentage</i>.</p>
<p>Otherwise, if the character at <var title="">position</var>
is a U+002A ASTERISK character (*), then set <var title="">unit</var> to <i>relative</i>.</p>
</li>
<li><p>Add an entry to <var title="">result</var> consisting of
the number given by <var title="">value</var> and the unit given
by <var title="">unit</var>.</p></li>
</ol></li>
<li><p>Return the list <var title="">result</var>.</p></li>
</ol></div><h4 id="dates-and-times"><span class="secno">2.5.5 </span>Dates and times</h4><p>In the algorithms below, the <dfn id="number-of-days-in-month-month-of-year-year">number of days in month <var title="">month</var> of year <var title="">year</var></dfn> is:
<em>31</em> if <var title="">month</var> is 1, 3, 5, 7, 8, 10, or
12; <em>30</em> if <var title="">month</var> is 4, 6, 9, or 11;
<em>29</em> if <var title="">month</var> is 2 and <var title="">year</var> is a number divisible by 400, or if <var title="">year</var> is a number divisible by 4 but not by 100; and
<em>28</em> otherwise. This takes into account leap years in the
Gregorian calendar. <a href="references.html#refsGREGORIAN">[GREGORIAN]</a></p><p>The <dfn id="concept-datetime-digit" title="concept-datetime-digit">digits</dfn> in the date
and time syntaxes defined in this section must be characters in the
range U+0030 DIGIT ZERO (0) to U+0039 DIGIT NINE (9), used to
express numbers in base ten.</p><div class="impl">
<p class="note">While the formats described here are intended to be
subsets of the corresponding ISO8601 formats, this specification
defines parsing rules in much more detail than ISO8601.
Implementors are therefore encouraged to carefully examine any date
parsing libraries before using them to implement the parsing rules
described below; ISO8601 libraries might not parse dates and times
in exactly the same manner. <a href="references.html#refsISO8601">[ISO8601]</a></p>
</div><h5 id="months"><span class="secno">2.5.5.1 </span>Months</h5><p>A <dfn id="concept-month" title="concept-month">month</dfn> consists of a specific
proleptic Gregorian date with no time-zone information and no date
information beyond a year and a month. <a href="references.html#refsGREGORIAN">[GREGORIAN]</a></p><p>A string is a <dfn id="valid-month-string">valid month string</dfn> representing a year
<var title="">year</var> and month <var title="">month</var> if it
consists of the following components in the given order:</p><ol><li>Four or more <a href="#concept-datetime-digit" title="concept-datetime-digit">digits</a>, representing <var title="">year</var>, where <var title="">year</var> > 0</li>
<li>A U+002D HYPHEN-MINUS character (-)</li>
<li>Two <a href="#concept-datetime-digit" title="concept-datetime-digit">digits</a>,
representing the month <var title="">month</var>, in the range
1 ≤ <var title="">month</var> ≤ 12</li>
</ol><div class="impl">
<p>The rules to <dfn id="parse-a-month-string">parse a month string</dfn> are as follows. This
will return either a year and month, or nothing. If at any point the
algorithm says that it "fails", this means that it is aborted at
that point and returns nothing.</p>
<ol><li><p>Let <var title="">input</var> be the string being
parsed.</p></li>
<li><p>Let <var title="">position</var> be a pointer into <var title="">input</var>, initially pointing at the start of the
string.</p></li>
<li><p><a href="#parse-a-month-component">Parse a month component</a> to obtain <var title="">year</var> and <var title="">month</var>. If this returns
nothing, then fail.</p>
</li><li><p>If <var title="">position</var> is <em>not</em> beyond the
end of <var title="">input</var>, then fail.</p></li>
<li><p>Return <var title="">year</var> and <var title="">month</var>.</p></li>
</ol><p>The rules to <dfn id="parse-a-month-component">parse a month component</dfn>, given an <var title="">input</var> string and a <var title="">position</var>, are
as follows. This will return either a year and a month, or
nothing. If at any point the algorithm says that it "fails", this
means that it is aborted at that point and returns nothing.</p>
<ol><li><p><a href="#collect-a-sequence-of-characters">Collect a sequence of characters</a> in the range
U+0030 DIGIT ZERO (0) to U+0039 DIGIT NINE (9). If the collected
sequence is not at least four characters long, then
fail. Otherwise, interpret the resulting sequence as a base-ten
integer. Let that number be the <var title="">year</var>.</p></li>
<li><p>If <var title="">year</var> is not a number greater than
zero, then fail.</p></li>
<li><p>If <var title="">position</var> is beyond the end of <var title="">input</var> or if the character at <var title="">position</var> is not a U+002D HYPHEN-MINUS character,
then fail. Otherwise, move <var title="">position</var> forwards
one character.</p></li>
<li><p><a href="#collect-a-sequence-of-characters">Collect a sequence of characters</a> in the range
U+0030 DIGIT ZERO (0) to U+0039 DIGIT NINE (9). If the collected
sequence is not exactly two characters long, then fail. Otherwise,
interpret the resulting sequence as a base-ten integer. Let that
number be the <var title="">month</var>.</p></li>
<li><p>If <var title="">month</var> is not a number in the range
1 ≤ <var title="">month</var> ≤ 12, then
fail.</p></li>
<li><p>Return <var title="">year</var> and <var title="">month</var>.</p></li>
</ol></div><h5 id="dates"><span class="secno">2.5.5.2 </span>Dates</h5><p>A <dfn id="concept-date" title="concept-date">date</dfn> consists of a specific
proleptic Gregorian date with no time-zone information, consisting
of a year, a month, and a day. <a href="references.html#refsGREGORIAN">[GREGORIAN]</a></p><p>A string is a <dfn id="valid-date-string">valid date string</dfn> representing a year
<var title="">year</var>, month <var title="">month</var>, and day
<var title="">day</var> if it consists of the following components
in the given order:</p><ol><li>A <a href="#valid-month-string">valid month string</a>, representing <var title="">year</var> and <var title="">month</var></li>
<li>A U+002D HYPHEN-MINUS character (-)</li>
<li>Two <a href="#concept-datetime-digit" title="concept-datetime-digit">digits</a>,
representing <var title="">day</var>, in the range
1 ≤ <var title="">day</var> ≤ <var title="">maxday</var> where <var title="">maxday</var> is the <a href="#number-of-days-in-month-month-of-year-year" title="number of days in month month of year year">number of days
in the month <var title="">month</var> and year <var title="">year</var></a></li>
</ol><div class="impl">
<p>The rules to <dfn id="parse-a-date-string">parse a date string</dfn> are as follows. This
will return either a date, or nothing. If at any point the algorithm
says that it "fails", this means that it is aborted at that point
and returns nothing.</p>
<ol><li><p>Let <var title="">input</var> be the string being
parsed.</p></li>
<li><p>Let <var title="">position</var> be a pointer into <var title="">input</var>, initially pointing at the start of the
string.</p></li>
<li><p><a href="#parse-a-date-component">Parse a date component</a> to obtain <var title="">year</var>, <var title="">month</var>, and <var title="">day</var>. If this returns nothing, then fail.</p>
</li><li><p>If <var title="">position</var> is <em>not</em> beyond the
end of <var title="">input</var>, then fail.</p></li>
<li><p>Let <var title="">date</var> be the date with year <var title="">year</var>, month <var title="">month</var>, and day <var title="">day</var>.</p></li>
<li><p>Return <var title="">date</var>.</p></li>
</ol><p>The rules to <dfn id="parse-a-date-component">parse a date component</dfn>, given an <var title="">input</var> string and a <var title="">position</var>, are
as follows. This will return either a year, a month, and a day, or
nothing. If at any point the algorithm says that it "fails", this
means that it is aborted at that point and returns nothing.</p>
<ol><li><p><a href="#parse-a-month-component">Parse a month component</a> to obtain <var title="">year</var> and <var title="">month</var>. If this returns
nothing, then fail.</p></li>
<li><p>Let <var title="">maxday</var> be the <a href="#number-of-days-in-month-month-of-year-year">number of days
in month <var title="">month</var> of year <var title="">year</var></a>.</p></li>
<li><p>If <var title="">position</var> is beyond the end of <var title="">input</var> or if the character at <var title="">position</var> is not a U+002D HYPHEN-MINUS character,
then fail. Otherwise, move <var title="">position</var> forwards
one character.</p></li>
<li><p><a href="#collect-a-sequence-of-characters">Collect a sequence of characters</a> in the range
U+0030 DIGIT ZERO (0) to U+0039 DIGIT NINE (9). If the collected
sequence is not exactly two characters long, then fail. Otherwise,
interpret the resulting sequence as a base-ten integer. Let that
number be the <var title="">day</var>.</p></li>
<li><p>If <var title="">day</var> is not a number in the range
1 ≤ <var title="">day</var> ≤ <var title="">maxday</var>, then fail.</p></li>
<li><p>Return <var title="">year</var>, <var title="">month</var>,
and <var title="">day</var>.</p></li>
</ol></div><h5 id="times"><span class="secno">2.5.5.3 </span>Times</h5><p>A <dfn id="concept-time" title="concept-time">time</dfn> consists of a specific
time with no time-zone information, consisting of an hour, a minute,
a second, and a fraction of a second.</p><p>A string is a <dfn id="valid-time-string">valid time string</dfn> representing an hour
<var title="">hour</var>, a minute <var title="">minute</var>, and a
second <var title="">second</var> if it consists of the following
components in the given order:</p><ol><li>Two <a href="#concept-datetime-digit" title="concept-datetime-digit">digits</a>,
representing <var title="">hour</var>, in the range
0 ≤ <var title="">hour</var> ≤ 23</li>
<li>A U+003A COLON character (:)</li>
<li>Two <a href="#concept-datetime-digit" title="concept-datetime-digit">digits</a>,
representing <var title="">minute</var>, in the range
0 ≤ <var title="">minute</var> ≤ 59</li>
<li>Optionally (required if <var title="">second</var> is
non-zero):
<ol><li>A U+003A COLON character (:)</li>
<li>Two <a href="#concept-datetime-digit" title="concept-datetime-digit">digits</a>,
representing the integer part of <var title="">second</var>, in
the range 0 ≤ <var title="">s</var> ≤ 59</li>
<li>Optionally (required if <var title="">second</var> is not an
integer):
<ol><li>A 002E FULL STOP character (.)</li>
<li>One or more <a href="#concept-datetime-digit" title="concept-datetime-digit">digits</a>, representing the
fractional part of <var title="">second</var></li>
</ol></li>
</ol></li>
</ol><p class="note">The <var title="">second</var> component cannot be
60 or 61; leap seconds cannot be represented.</p><div class="impl">
<p>The rules to <dfn id="parse-a-time-string">parse a time string</dfn> are as follows. This
will return either a time, or nothing. If at any point the algorithm
says that it "fails", this means that it is aborted at that point
and returns nothing.</p>
<ol><li><p>Let <var title="">input</var> be the string being
parsed.</p></li>
<li><p>Let <var title="">position</var> be a pointer into <var title="">input</var>, initially pointing at the start of the
string.</p></li>
<li><p><a href="#parse-a-time-component">Parse a time component</a> to obtain <var title="">hour</var>, <var title="">minute</var>, and <var title="">second</var>. If this returns nothing, then fail.</p>
</li><li><p>If <var title="">position</var> is <em>not</em> beyond the
end of <var title="">input</var>, then fail.</p></li>
<li><p>Let <var title="">time</var> be the time with hour <var title="">hour</var>, minute <var title="">minute</var>, and second
<var title="">second</var>.</p></li>
<li><p>Return <var title="">time</var>.</p></li>
</ol><p>The rules to <dfn id="parse-a-time-component">parse a time component</dfn>, given an <var title="">input</var> string and a <var title="">position</var>, are
as follows. This will return either an hour, a minute, and a second,
or nothing. If at any point the algorithm says that it "fails", this
means that it is aborted at that point and returns nothing.</p>
<ol><li><p><a href="#collect-a-sequence-of-characters">Collect a sequence of characters</a> in the range
U+0030 DIGIT ZERO (0) to U+0039 DIGIT NINE (9). If the collected
sequence is not exactly two characters long, then fail. Otherwise,
interpret the resulting sequence as a base-ten integer. Let that
number be the <var title="">hour</var>.</p></li>
<li>If <var title="">hour</var> is not a number in the range
0 ≤ <var title="">hour</var> ≤ 23, then
fail.</li>
<li><p>If <var title="">position</var> is beyond the end of <var title="">input</var> or if the character at <var title="">position</var> is not a U+003A COLON character, then
fail. Otherwise, move <var title="">position</var> forwards one
character.</p></li>
<li><p><a href="#collect-a-sequence-of-characters">Collect a sequence of characters</a> in the range
U+0030 DIGIT ZERO (0) to U+0039 DIGIT NINE (9). If the collected
sequence is not exactly two characters long, then fail. Otherwise,
interpret the resulting sequence as a base-ten integer. Let that
number be the <var title="">minute</var>.</p></li>
<li>If <var title="">minute</var> is not a number in the range
0 ≤ <var title="">minute</var> ≤ 59, then
fail.</li>
<li><p>Let <var title="">second</var> be a string with the value
"0".</p></li>
<li>
<p>If <var title="">position</var> is not beyond the end of
<var title="">input</var> and the character at <var title="">position</var> is a U+003A COLON, then run these
substeps:</p>
<ol><li><p>Advance <var title="">position</var> to the next character
in <var title="">input</var>.</p></li>
<li><p>If <var title="">position</var> is beyond the end of <var title="">input</var>, or at the last character in <var title="">input</var>, or if the next <em>two</em> characters in
<var title="">input</var> starting at <var title="">position</var> are not two characters both in the range
U+0030 DIGIT ZERO (0) to U+0039 DIGIT NINE (9), then
fail.</p></li>
<li><p><a href="#collect-a-sequence-of-characters">Collect a sequence of characters</a> that are
either characters in the range U+0030 DIGIT ZERO (0) to U+0039
DIGIT NINE (9) or U+002E FULL STOP characters. If the collected
sequence has more than one U+002E FULL STOP characters, or if the
last character in the sequence is a U+002E FULL STOP character,
then fail. Otherwise, let the collected string be <var title="">second</var> instead of its previous value.</p></li>
</ol></li>
<li><p>Interpret <var title="">second</var> as a base-ten number
(possibly with a fractional part). Let <var title="">second</var>
be that number instead of the string version.</p></li>
<li><p>If <var title="">second</var> is not a number in the range
0 ≤ <var title="">second</var> < 60, then
fail.</p></li>
<li><p>Return <var title="">hour</var>, <var title="">minute</var>,
and <var title="">second</var>.</p></li>
</ol></div><h5 id="local-dates-and-times"><span class="secno">2.5.5.4 </span>Local dates and times</h5><p>A <dfn id="concept-datetime-local" title="concept-datetime-local">local date and time</dfn>
consists of a specific proleptic Gregorian date, consisting of a
year, a month, and a day, and a time, consisting of an hour, a
minute, a second, and a fraction of a second, but expressed without
a time zone. <a href="references.html#refsGREGORIAN">[GREGORIAN]</a></p><p>A string is a <dfn id="valid-local-date-and-time-string">valid local date and time string</dfn>
representing a date and time if it consists of the following
components in the given order:</p><ol><li>A <a href="#valid-date-string">valid date string</a> representing the date.</li>
<li>A U+0054 LATIN CAPITAL LETTER T character (T).</li>
<li>A <a href="#valid-time-string">valid time string</a> representing the time.</li>
</ol><div class="impl">
<p>The rules to <dfn id="parse-a-local-date-and-time-string">parse a local date and time string</dfn> are as
follows. This will return either a date and time, or nothing. If at
any point the algorithm says that it "fails", this means that it is
aborted at that point and returns nothing.</p>
<ol><li><p>Let <var title="">input</var> be the string being
parsed.</p></li>
<li><p>Let <var title="">position</var> be a pointer into <var title="">input</var>, initially pointing at the start of the
string.</p></li>
<li><p><a href="#parse-a-date-component">Parse a date component</a> to obtain <var title="">year</var>, <var title="">month</var>, and <var title="">day</var>. If this returns nothing, then fail.</p>
</li><li><p>If <var title="">position</var> is beyond the end of <var title="">input</var> or if the character at <var title="">position</var> is not a U+0054 LATIN CAPITAL LETTER T
character (T) then fail. Otherwise, move <var title="">position</var> forwards one character.</p></li>
<li><p><a href="#parse-a-time-component">Parse a time component</a> to obtain <var title="">hour</var>, <var title="">minute</var>, and <var title="">second</var>. If this returns nothing, then fail.</p>
</li><li><p>If <var title="">position</var> is <em>not</em> beyond the
end of <var title="">input</var>, then fail.</p></li>
<li><p>Let <var title="">date</var> be the date with year <var title="">year</var>, month <var title="">month</var>, and day <var title="">day</var>.</p></li>
<li><p>Let <var title="">time</var> be the time with hour <var title="">hour</var>, minute <var title="">minute</var>, and second
<var title="">second</var>.</p></li>
<li><p>Return <var title="">date</var> and <var title="">time</var>.</p></li>
</ol></div><h5 id="global-dates-and-times"><span class="secno">2.5.5.5 </span>Global dates and times</h5><p>A <dfn id="concept-datetime" title="concept-datetime">global date and time</dfn>
consists of a specific proleptic Gregorian date, consisting of a
year, a month, and a day, and a time, consisting of an hour, a
minute, a second, and a fraction of a second, expressed with a
time-zone offset, consisting of a signed number of hours and
minutes. <a href="references.html#refsGREGORIAN">[GREGORIAN]</a></p><p>A string is a <dfn id="valid-global-date-and-time-string">valid global date and time string</dfn>
representing a date, time, and a time-zone offset if it consists of
the following components in the given order:</p><ol><li>A <a href="#valid-date-string">valid date string</a> representing the date</li>
<li>A U+0054 LATIN CAPITAL LETTER T character (T)</li>
<li>A <a href="#valid-time-string">valid time string</a> representing the time</li>
<li>Either:
<ul><li>A U+005A LATIN CAPITAL LETTER Z character (Z), allowed only
if the time zone is UTC</li>
<li>Or:
<ol><li>Either a U+002B PLUS SIGN character (+) or, if the
time-zone offset is not zero, a U+002D HYPHEN-MINUS character
(-), representing the sign of the time-zone offset</li>
<li>Two <a href="#concept-datetime-digit" title="concept-datetime-digit">digits</a>,
representing the hours component <var title="">hour</var> of
the time-zone offset, in the range 0 ≤ <var title="">hour</var> ≤ 23</li>
<li>A U+003A COLON character (:)</li>
<li>Two <a href="#concept-datetime-digit" title="concept-datetime-digit">digits</a>,
representing the minutes component <var title="">minute</var>
of the time-zone offset, in the range 0 ≤ <var title="">minute</var> ≤ 59</li>
</ol></li>
</ul></li>
</ol><p class="note">This format allows for time-zone offsets from -23:59
to +23:59. In practice, however, the range of offsets of actual time
zones is -12:00 to +14:00, and the minutes component of offsets of
actual time zones is always either 00, 30, or 45.</p><p>Times in dates before the formation of UTC in the mid twentieth
century must be expressed and interpreted in terms of UT1
(contemporary Earth solar time at the 0° longitude), not UTC
(the approximation of UT1 that ticks in SI seconds). Time before the
formation of time zones must be expressed and interpeted as UT1
times with explicit time zones that approximate the contemporary
difference between the appropriate local time and the time observed
at the location of Greenwich, London.</p><div class="example">
<p>The following are some examples of dates written as <a href="#valid-global-date-and-time-string" title="valid global date and time string">valid global date and
time strings</a>.</p>
<dl><dt>"<code>0037-12-13T00:00Z</code>"</dt>
<dd>Midnight in areas using London time on the birthday of Nero
(the Roman Emperor). See below for further discussion on which
date this actually corresponds to.</dd>
<dt>"<code>1979-10-14T12:00:00.001-04:00</code>"</dt>
<dd>One millisecond after noon on October 14th 1979, in the time
zone in use on the east coast of the USA during daylight saving
time.</dd>
<dt>"<code>8592-01-01T02:09+02:09</code>"</dt>
<dd>Midnight UTC on the 1st of January, 8592. The time zone
associated with that time is two hours and nine minutes ahead of
UTC, which is not currently a real time zone, but is nonetheless
allowed.</dd>
</dl><p>Several things are notable about these dates:</p>
<ul><li>Years with fewer than four digits have to be
zero-padded. The date "37-12-13" would not be a valid date.</li>
<li>To unambiguously identify a moment in time prior to the
introduction of the Gregorian calendar (insofar as moments in time
before the formation of UTC can be unambiguously identified), the
date has to be first converted to the Gregorian calendar from the
calendar in use at the time (e.g. from the Julian calendar). The
date of Nero's birth is the 15th of December 37, in the Julian
Calendar, which is the 13th of December 37 in the proleptic
Gregorian Calendar.</li>
<li>The time and time-zone offset components are not optional.</li>
<li>Dates before the year one can't be represented as a datetime
in this version of HTML.</li>
<li>Times of specific events in ancient times are, at best,
approximations, since time was not well coordinated or measured
until relatively recent decades.</li>
<li>Time-zone offsets differ based on daylight savings time.</li>
</ul></div><div class="impl">
<p>The <dfn id="best-representation-of-the-global-date-and-time-string">best representation of the global date and time
string</dfn> <var title="">datetime</var> is the <a href="#valid-global-date-and-time-string">valid global
date and time string</a> representing <var title="">datetime</var>, with the <a href="#valid-time-string">valid time string</a>
component being given in its shortest possible form, with the last
character of the string not being a U+005A LATIN CAPITAL LETTER Z
character (Z), even if the time zone is UTC, and with a U+002B PLUS
SIGN character (+) representing the sign of the time-zone offset
when the time zone is UTC.</p>
<p>The rules to <dfn id="parse-a-global-date-and-time-string">parse a global date and time string</dfn> are
as follows. This will return either a time in UTC, with associated
time-zone offset information for round-tripping or display purposes,
or nothing. If at any point the algorithm says that it "fails", this
means that it is aborted at that point and returns nothing.</p>
<ol><li><p>Let <var title="">input</var> be the string being
parsed.</p></li>
<li><p>Let <var title="">position</var> be a pointer into <var title="">input</var>, initially pointing at the start of the
string.</p></li>
<li><p><a href="#parse-a-date-component">Parse a date component</a> to obtain <var title="">year</var>, <var title="">month</var>, and <var title="">day</var>. If this returns nothing, then fail.</p>
</li><li><p>If <var title="">position</var> is beyond the end of <var title="">input</var> or if the character at <var title="">position</var> is not a U+0054 LATIN CAPITAL LETTER T
character (T) then fail. Otherwise, move <var title="">position</var> forwards one character.</p></li>
<li><p><a href="#parse-a-time-component">Parse a time component</a> to obtain <var title="">hour</var>, <var title="">minute</var>, and <var title="">second</var>. If this returns nothing, then fail.</p>
</li><li><p>If <var title="">position</var> is beyond the end of <var title="">input</var>, then fail.</p></li>
<li><p><a href="#parse-a-time-zone-offset-component">Parse a time-zone offset component</a> to obtain
<var title="">timezone<sub title="">hours</sub></var> and <var title="">timezone<sub title="">minutes</sub></var>. If this returns
nothing, then fail.</p>
</li><li><p>If <var title="">position</var> is <em>not</em> beyond the
end of <var title="">input</var>, then fail.</p></li>
<li><p>Let <var title="">time</var> be the moment in time at year
<var title="">year</var>, month <var title="">month</var>, day <var title="">day</var>, hours <var title="">hour</var>, minute <var title="">minute</var>, second <var title="">second</var>,
subtracting <var title="">timezone<sub title="">hours</sub></var>
hours and <var title="">timezone<sub title="">minutes</sub></var>
minutes. That moment in time is a moment in the UTC
time zone.</p></li>
<li><p>Let <var title="">timezone</var> be <var title="">timezone<sub title="">hours</sub></var> hours and <var title="">timezone<sub title="">minutes</sub></var> minutes from
UTC.</p></li>
<li><p>Return <var title="">time</var> and <var title="">timezone</var>.</p></li>
</ol><p>The rules to <dfn id="parse-a-time-zone-offset-component">parse a time-zone offset component</dfn>, given
an <var title="">input</var> string and a <var title="">position</var>, are as follows. This will return either
time-zone hours and time-zone minutes, or nothing. If at any point
the algorithm says that it "fails", this means that it is aborted at
that point and returns nothing.</p>
<ol><li>
<p>If the character at <var title="">position</var> is a U+005A
LATIN CAPITAL LETTER Z character (Z), then:</p>
<ol><li><p>Let <var title="">timezone<sub title="">hours</sub></var>
be 0.</p></li>
<li><p>Let <var title="">timezone<sub title="">minutes</sub></var> be 0.</p></li>
<li><p>Advance <var title="">position</var> to the next character
in <var title="">input</var>.</p></li>
</ol><p>Otherwise, if the character at <var title="">position</var> is
either a U+002B PLUS SIGN (+) or a U+002D HYPHEN-MINUS (-),
then:</p>
<ol><li><p>If the character at <var title="">position</var> is a
U+002B PLUS SIGN (+), let <var title="">sign</var> be
"positive". Otherwise, it's a U+002D HYPHEN-MINUS (-); let <var title="">sign</var> be "negative".</p></li>
<li><p>Advance <var title="">position</var> to the next character
in <var title="">input</var>.</p></li>
<li><p><a href="#collect-a-sequence-of-characters">Collect a sequence of characters</a> in the range
U+0030 DIGIT ZERO (0) to U+0039 DIGIT NINE (9). If the collected
sequence is not exactly two characters long, then
fail. Otherwise, interpret the resulting sequence as a base-ten
integer. Let that number be the <var title="">timezone<sub title="">hours</sub></var>.</p></li>
<li>If <var title="">timezone<sub title="">hours</sub></var> is
not a number in the range 0 ≤ <var title="">timezone<sub title="">hours</sub></var> ≤ 23, then fail.</li>
<li>If <var title="">sign</var> is "negative", then negate <var title="">timezone<sub title="">hours</sub></var>.</li>
<li><p>If <var title="">position</var> is beyond the end of <var title="">input</var> or if the character at <var title="">position</var> is not a U+003A COLON character, then
fail. Otherwise, move <var title="">position</var> forwards one
character.</p></li>
<li><p><a href="#collect-a-sequence-of-characters">Collect a sequence of characters</a> in the range
U+0030 DIGIT ZERO (0) to U+0039 DIGIT NINE (9). If the collected
sequence is not exactly two characters long, then
fail. Otherwise, interpret the resulting sequence as a base-ten
integer. Let that number be the <var title="">timezone<sub title="">minutes</sub></var>.</p></li>
<li>If <var title="">timezone<sub title="">minutes</sub></var> is
not a number in the range 0 ≤ <var title="">timezone<sub title="">minutes</sub></var> ≤ 59, then fail.</li>
<li>If <var title="">sign</var> is "negative", then negate <var title="">timezone<sub title="">minutes</sub></var>.</li>
</ol><p>Otherwise, fail.</p>
</li>
<li><p>Return <var title="">timezone<sub title="">hours</sub></var>
and <var title="">timezone<sub title="">minutes</sub></var>.</p></li>
</ol></div><h5 id="weeks"><span class="secno">2.5.5.6 </span>Weeks</h5><p>A <dfn id="concept-week" title="concept-week">week</dfn> consists of a week-year
number and a week number representing a seven-day period starting on
a Monday. Each week-year in this calendaring system has either 52 or
53 such seven-day periods, as defined below. The seven-day period
starting on the Gregorian date Monday December 29th 1969
(1969-12-29) is defined as week number 1 in week-year
1970. Consecutive weeks are numbered sequentially. The week before
the number 1 week in a week-year is the last week in the previous
week-year, and vice versa. <a href="references.html#refsGREGORIAN">[GREGORIAN]</a></p><p>A week-year with a number <var title="">year</var> has 53 weeks
if it corresponds to either a year <var title="">year</var> in the
proleptic Gregorian calendar that has a Thursday as its first day
(January 1st), or a year <var title="">year</var> in the proleptic
Gregorian calendar that has a Wednesday as its first day (January
1st) and where <var title="">year</var> is a number divisible by
400, or a number divisible by 4 but not by 100. All other week-years
have 52 weeks.</p><p>The <dfn id="week-number-of-the-last-day">week number of the last day</dfn> of a week-year with 53
weeks is 53; the week number of the last day of a week-year with 52
weeks is 52.</p><p class="note">The week-year number of a particular day can be
different than the number of the year that contains that day in the
proleptic Gregorian calendar. The first week in a week-year <var title="">y</var> is the week that contains the first Thursday of
the Gregorian year <var title="">y</var>.</p><p>A string is a <dfn id="valid-week-string">valid week string</dfn> representing a
week-year <var title="">year</var> and week <var title="">week</var>
if it consists of the following components in the given order:</p><ol><li>Four or more <a href="#concept-datetime-digit" title="concept-datetime-digit">digits</a>, representing <var title="">year</var>, where <var title="">year</var> > 0</li>
<li>A U+002D HYPHEN-MINUS character (-)</li>
<li>A U+0057 LATIN CAPITAL LETTER W character (W)</li>
<li>Two <a href="#concept-datetime-digit" title="concept-datetime-digit">digits</a>,
representing the week <var title="">week</var>, in the range
1 ≤ <var title="">week</var> ≤ <var title="">maxweek</var>, where <var title="">maxweek</var> is the
<a href="#week-number-of-the-last-day">week number of the last day</a> of week-year <var title="">year</var></li>
</ol><div class="impl">
<p>The rules to <dfn id="parse-a-week-string">parse a week string</dfn> are as follows. This
will return either a week-year number and week number, or
nothing. If at any point the algorithm says that it "fails", this
means that it is aborted at that point and returns nothing.</p>
<ol><li><p>Let <var title="">input</var> be the string being
parsed.</p></li>
<li><p>Let <var title="">position</var> be a pointer into <var title="">input</var>, initially pointing at the start of the
string.</p></li>
<li><p><a href="#collect-a-sequence-of-characters">Collect a sequence of characters</a> in the range
U+0030 DIGIT ZERO (0) to U+0039 DIGIT NINE (9). If the collected
sequence is not at least four characters long, then
fail. Otherwise, interpret the resulting sequence as a base-ten
integer. Let that number be the <var title="">year</var>.</p></li>
<li><p>If <var title="">year</var> is not a number greater than
zero, then fail.</p></li>
<li><p>If <var title="">position</var> is beyond the end of <var title="">input</var> or if the character at <var title="">position</var> is not a U+002D HYPHEN-MINUS character,
then fail. Otherwise, move <var title="">position</var> forwards
one character.</p></li>
<li><p>If <var title="">position</var> is beyond the end of <var title="">input</var> or if the character at <var title="">position</var> is not a U+0057 LATIN CAPITAL LETTER W
character (W), then fail. Otherwise, move <var title="">position</var> forwards one character.</p></li>
<li><p><a href="#collect-a-sequence-of-characters">Collect a sequence of characters</a> in the range
U+0030 DIGIT ZERO (0) to U+0039 DIGIT NINE (9). If the collected
sequence is not exactly two characters long, then fail. Otherwise,
interpret the resulting sequence as a base-ten integer. Let that
number be the <var title="">week</var>.</p></li>
<li><p>Let <var title="">maxweek</var> be the <a href="#week-number-of-the-last-day">week number of
the last day</a> of year <var title="">year</var>.</p></li>
<li><p>If <var title="">week</var> is not a number in the range
1 ≤ <var title="">week</var> ≤ <var title="">maxweek</var>, then fail.</p></li>
<li><p>If <var title="">position</var> is <em>not</em> beyond the
end of <var title="">input</var>, then fail.</p></li>
<li><p>Return the week-year number <var title="">year</var> and the
week number <var title="">week</var>.</p></li>
</ol></div><h5 id="vaguer-moments-in-time"><span class="secno">2.5.5.7 </span>Vaguer moments in time</h5><p>A string is a <dfn id="valid-date-or-time-string">valid date or time string</dfn> if it is also
one of the following:</p><ul><li>A <a href="#valid-date-string">valid date string</a>.</li>
<li>A <a href="#valid-time-string">valid time string</a>.</li>
<li>A <a href="#valid-global-date-and-time-string">valid global date and time string</a>.</li>
</ul><p>A string is a <dfn id="valid-date-or-time-string-in-content">valid date or time string in content</dfn> if
it consists of zero or more <a href="#white_space">White_Space</a> characters,
followed by a <a href="#valid-date-or-time-string">valid date or time string</a>, followed by
zero or more further <a href="#white_space">White_Space</a> characters.</p><hr><p>A string is a <dfn id="valid-date-string-with-optional-time">valid date string with optional time</dfn> if
it is also one of the following:</p><ul><li>A <a href="#valid-date-string">valid date string</a>.</li>
<li>A <a href="#valid-global-date-and-time-string">valid global date and time string</a>.</li>
</ul><p>A string is a <dfn id="valid-date-string-in-content-with-optional-time">valid date string in content with optional
time</dfn> if it consists of zero or more <a href="#white_space">White_Space</a>
characters, followed by a <a href="#valid-date-string-with-optional-time">valid date string with optional
time</a>, followed by zero or more further
<a href="#white_space">White_Space</a> characters.</p><div class="impl">
<hr><p>The rules to <dfn id="parse-a-date-or-time-string">parse a date or time string</dfn> are as
follows. The algorithm is invoked with a flag indicating if the
<i>in attribute</i> variant or the <i>in content</i> variant is to
be used. The algorithm will return either a <a href="#concept-date" title="concept-date">date</a>, a <a href="#concept-time" title="concept-time">time</a>, a <a href="#concept-datetime" title="concept-datetime">global date and time</a>, or nothing. If
at any point the algorithm says that it "fails", this means that it
is aborted at that point and returns nothing.</p>
<ol><li><p>Let <var title="">input</var> be the string being
parsed.</p></li>
<li><p>Let <var title="">position</var> be a pointer into <var title="">input</var>, initially pointing at the start of the
string.</p></li>
<li><p>For the <i>in content</i> variant: <a href="#skip-white_space-characters">skip White_Space
characters</a>.</p></li>
<li><p>Set <var title="">start position</var> to the same position
as <var title="">position</var>.</p></li>
<li><p>Set the <var title="">date present</var> and <var title="">time present</var> flags to true.</p></li>
<li><p><a href="#parse-a-date-component">Parse a date component</a> to obtain <var title="">year</var>, <var title="">month</var>, and <var title="">day</var>. If this fails, then set the <var title="">date
present</var> flag to false.</p>
</li><li>
<p>If <var title="">date present</var> is true, and <var title="">position</var> is not beyond the end of <var title="">input</var>, and the character at <var title="">position</var> is a U+0054 LATIN CAPITAL LETTER T
character (T), then advance <var title="">position</var> to the
next character in <var title="">input</var>.</p>
<p>Otherwise, if <var title="">date present</var> is true, and
either <var title="">position</var> is beyond the end of <var title="">input</var> or the character at <var title="">position</var> is not a U+0054 LATIN CAPITAL LETTER T
character (T), then set <var title="">time present</var> to
false.</p>
<p>Otherwise, if <var title="">date present</var> is false, set
<var title="">position</var> back to the same position as <var title="">start position</var>.</p>
</li>
<li><p>If the <var title="">time present</var> flag is true, then
<a href="#parse-a-time-component">parse a time component</a> to obtain <var title="">hour</var>, <var title="">minute</var>, and <var title="">second</var>. If this returns nothing, then fail.</p></li>
<li><p>If the <var title="">date present</var> and <var title="">time present</var> flags are both true, but <var title="">position</var> is beyond the end of <var title="">input</var>, then fail.</p></li>
<li><p>If the <var title="">date present</var> and <var title="">time present</var> flags are both true, <a href="#parse-a-time-zone-offset-component">parse a
time-zone offset component</a> to obtain <var title="">timezone<sub title="">hours</sub></var> and <var title="">timezone<sub title="">minutes</sub></var>. If this returns
nothing, then fail.</p>
</li><li><p>For the <i>in content</i> variant: <a href="#skip-white_space-characters">skip White_Space
characters</a>.</p></li>
<li><p>If <var title="">position</var> is <em>not</em> beyond the
end of <var title="">input</var>, then fail.</p></li>
<li>
<p>If the <var title="">date present</var> flag is true and the
<var title="">time present</var> flag is false, then let <var title="">date</var> be the date with year <var title="">year</var>, month <var title="">month</var>, and day <var title="">day</var>, and return <var title="">date</var>.</p>
<p>Otherwise, if the <var title="">time present</var> flag is true
and the <var title="">date present</var> flag is false, then let
<var title="">time</var> be the time with hour <var title="">hour</var>, minute <var title="">minute</var>, and second
<var title="">second</var>, and return <var title="">time</var>.</p>
<p>Otherwise, let <var title="">time</var> be the moment in time
at year <var title="">year</var>, month <var title="">month</var>,
day <var title="">day</var>, hours <var title="">hour</var>,
minute <var title="">minute</var>, second <var title="">second</var>, subtracting <var title="">timezone<sub title="">hours</sub></var> hours and <var title="">timezone<sub title="">minutes</sub></var> minutes, that moment in time being a
moment in the UTC time zone; let <var title="">timezone</var> be
<var title="">timezone<sub title="">hours</sub></var> hours and
<var title="">timezone<sub title="">minutes</sub></var> minutes
from UTC; and return <var title="">time</var> and <var title="">timezone</var>.</p>
</li>
</ol></div><h4 id="colors"><span class="secno">2.5.6 </span>Colors</h4><p>A <dfn id="simple-color">simple color</dfn> consists of three 8-bit numbers in the
range 0..255, representing the red, green, and blue components of
the color respectively, in the sRGB color space. <a href="references.html#refsSRGB">[SRGB]</a></p><p>A string is a <dfn id="valid-simple-color">valid simple color</dfn> if it is exactly
seven characters long, and the first character is a U+0023 NUMBER
SIGN character (#), and the remaining six characters are all in the
range U+0030 DIGIT ZERO (0) to U+0039 DIGIT NINE (9), U+0041 LATIN
CAPITAL LETTER A to U+0046 LATIN CAPITAL LETTER F, U+0061 LATIN
SMALL LETTER A to U+0066 LATIN SMALL LETTER F, with the first two
digits representing the red component, the middle two digits
representing the green component, and the last two digits
representing the blue component, in hexadecimal.</p><p>A string is a <dfn id="valid-lowercase-simple-color">valid lowercase simple color</dfn> if it is a
<a href="#valid-simple-color">valid simple color</a> and doesn't use any characters in
the range U+0041 LATIN CAPITAL LETTER A to U+0046 LATIN CAPITAL
LETTER F.</p><div class="impl">
<p>The <dfn id="rules-for-parsing-simple-color-values">rules for parsing simple color values</dfn> are as given
in the following algorithm. When invoked, the steps must be followed
in the order given, aborting at the first step that returns a
value. This algorithm will return either a <a href="#simple-color">simple color</a>
or an error.</p>
<ol><li><p>Let <var title="">input</var> be the string being
parsed.</p></li>
<li><p>If <var title="">input</var> is not exactly seven characters
long, then return an error.</p></li>
<li><p>If the first character in <var title="">input</var> is not a
U+0023 NUMBER SIGN character (#), then return an error.</p></li>
<li><p>If the last six characters of <var title="">input</var> are
not all in the range U+0030 DIGIT ZERO (0) to U+0039 DIGIT NINE
(9), U+0041 LATIN CAPITAL LETTER A to U+0046 LATIN CAPITAL LETTER
F, U+0061 LATIN SMALL LETTER A to U+0066 LATIN SMALL LETTER F, then
return an error.</p></li>
<li><p>Let <var title="">result</var> be a <a href="#simple-color">simple
color</a>.</p>
</li><li><p>Interpret the second and third characters as a hexadecimal
number and let the result be the red component of <var title="">result</var>.</p>
</li><li><p>Interpret the fourth and fifth characters as a hexadecimal
number and let the result be the green component of <var title="">result</var>.</p>
</li><li><p>Interpret the sixth and seventh characters as a hexadecimal
number and let the result be the blue component of <var title="">result</var>.</p>
</li><li><p>Return <var title="">result</var>.</p>
</li></ol><p>The <dfn id="rules-for-serializing-simple-color-values">rules for serializing simple color values</dfn> given a
<a href="#simple-color">simple color</a> are as given in the following
algorithm:</p>
<ol><li><p>Let <var title="">result</var> be a string consisting of a
single U+0023 NUMBER SIGN character (#).</p></li>
<li><p>Convert the red, green, and blue components in turn to
two-digit hexadecimal numbers using the digits U+0030 DIGIT ZERO
(0) to U+0039 DIGIT NINE (9) and U+0061 LATIN SMALL LETTER A
to U+0066 LATIN SMALL LETTER F, zero-padding if necessary, and
append these numbers to <var title="">result</var>, in the order
red, green, blue.</p>
</li><li><p>Return <var title="">result</var>, which will be a
<a href="#valid-lowercase-simple-color">valid lowercase simple color</a>.</p></li>
</ol><hr><p>Some obsolete legacy attributes parse colors in a more
complicated manner, using the <dfn id="rules-for-parsing-a-legacy-color-value">rules for parsing a legacy color
value</dfn>, which are given in the following algorithm. When
invoked, the steps must be followed in the order given, aborting at
the first step that returns a value. This algorithm will return
either a <a href="#simple-color">simple color</a> or an error.</p>
<ol><li><p>Let <var title="">input</var> be the string being
parsed.</p></li>
<li><p>If <var title="">input</var> is the empty string, then
return an error.</p></li>
<li><p><a href="#strip-leading-and-trailing-whitespace">Strip leading and trailing whitespace</a> from <var title="">input</var>.</p></li>
<li><p>If <var title="">input</var> is an <a href="infrastructure.html#ascii-case-insensitive">ASCII
case-insensitive</a> match for the string "<code title="">transparent</code>", then return an error.</p></li>
<li>
<p>If <var title="">input</var> is an <a href="infrastructure.html#ascii-case-insensitive">ASCII
case-insensitive</a> match for one of the keywords listed in
the <a href="http://www.w3.org/TR/css3-color/#svg-color">SVG color
keywords</a> section of the CSS3 Color specification,
then return the <a href="#simple-color">simple color</a> corresponding to that
keyword. <a href="references.html#refsCSSCOLOR">[CSSCOLOR]</a></p>
<p class="note"><a href="http://www.w3.org/TR/css3-color/#css2-system">CSS2 System
Colors</a> are not recognised.</p>
</li>
<li>
<p>If <var title="">input</var> is four characters long, and the
first character in <var title="">input</var> is a U+0023 NUMBER
SIGN character (#), and the last three characters of <var title="">input</var> are all in the range U+0030 DIGIT ZERO (0)
to U+0039 DIGIT NINE (9), U+0041 LATIN CAPITAL LETTER A to U+0046
LATIN CAPITAL LETTER F, and U+0061 LATIN SMALL LETTER A to U+0066
LATIN SMALL LETTER F, then run these substeps:</p>
<ol><li><p>Let <var title="">result</var> be a <a href="#simple-color">simple
color</a>.</p>
</li><li><p>Interpret the second character of <var title="">input</var> as a hexadecimal digit; let the red
component of <var title="">result</var> be the resulting number
multiplied by 17.</p>
</li><li><p>Interpret the third character of <var title="">input</var>
as a hexadecimal digit; let the green component of <var title="">result</var> be the resulting number multiplied by
17.</p>
</li><li><p>Interpret the fourth character of <var title="">input</var> as a hexadecimal digit; let the blue
component of <var title="">result</var> be the resulting number
multiplied by 17.</p>
</li><li><p>Return <var title="">result</var>.</p>
</li></ol></li>
<li><p>Replace any characters in <var title="">input</var> that
have a Unicode code point greater than U+FFFF (i.e. any characters
that are not in the basic multilingual plane) with the
two-character string "<code title="">00</code>".</p></li>
<li><p>If <var title="">input</var> is longer than 128 characters,
truncate <var title="">input</var>, leaving only the first 128
characters.</p></li>
<li><p>If the first character in <var title="">input</var> is a
U+0023 NUMBER SIGN character (#), remove it.</p></li>
<li><p>Replace any character in <var title="">input</var> that is
not in the range U+0030 DIGIT ZERO (0) to U+0039 DIGIT NINE (9),
U+0041 LATIN CAPITAL LETTER A to U+0046 LATIN CAPITAL LETTER F, and
U+0061 LATIN SMALL LETTER A to U+0066 LATIN SMALL LETTER F with the
character U+0030 DIGIT ZERO (0).</p></li>
<li><p>While <var title="">input</var>'s length is zero or not a
multiple of three, append a U+0030 DIGIT ZERO (0) character to <var title="">input</var>.</p></li>
<li><p>Split <var title="">input</var> into three strings of equal
length, to obtain three components. Let <var title="">length</var>
be the length of those components (one third the length of <var title="">input</var>).</p></li>
<li><p>If <var title="">length</var> is greater than 8, then remove
the leading <span title=""><var title="">length</var>-8</span>
characters in each component, and let <var title="">length</var> be
8.</p></li>
<li><p>While <var title="">length</var> is greater than two and the
first character in each component is a U+0030 DIGIT ZERO (0)
character, remove that character and reduce <var title="">length</var> by one.</p></li>
<li><p>If <var title="">length</var> is <em>still</em> greater than
two, truncate each component, leaving only the first two
characters in each.</p></li>
<li><p>Let <var title="">result</var> be a <a href="#simple-color">simple
color</a>.</p>
</li><li><p>Interpret the first component as a hexadecimal number; let
the red component of <var title="">result</var> be the resulting
number.</p></li>
<li><p>Interpret the second component as a hexadecimal number; let
the green component of <var title="">result</var> be the resulting
number.</p></li>
<li><p>Interpret the third component as a hexadecimal number; let
the blue component of <var title="">result</var> be the resulting
number.</p></li>
<li><p>Return <var title="">result</var>.</p>
</li></ol></div><hr><h4 id="space-separated-tokens"><span class="secno">2.5.7 </span>Space-separated tokens</h4><p>A <dfn id="set-of-space-separated-tokens">set of space-separated tokens</dfn> is a string containing
zero or more words (known as tokens) separated by one or more <a href="#space-character" title="space character">space characters</a>, where words consist
of any string of one or more characters, none of which are <a href="#space-character" title="space character">space characters</a>.</p><p>A string containing a <a href="#set-of-space-separated-tokens">set of space-separated tokens</a>
may have leading or trailing <a href="#space-character" title="space character">space
characters</a>.</p><p>An <dfn id="unordered-set-of-unique-space-separated-tokens">unordered set of unique space-separated tokens</dfn> is a
<a href="#set-of-space-separated-tokens">set of space-separated tokens</a> where none of the tokens
are duplicated.</p><p>An <dfn id="ordered-set-of-unique-space-separated-tokens">ordered set of unique space-separated tokens</dfn> is a
<a href="#set-of-space-separated-tokens">set of space-separated tokens</a> where none of the tokens
are duplicated but where the order of the tokens is meaningful.</p><p><a href="#set-of-space-separated-tokens" title="set of space-separated tokens">Sets of
space-separated tokens</a> sometimes have a defined set of
allowed values. When a set of allowed values is defined, the tokens
must all be from that list of allowed values; other values are
non-conforming. If no such set of allowed values is provided, then
all values are conforming.</p><p class="note">How tokens in a <a href="#set-of-space-separated-tokens">set of space-separated
tokens</a> are to be compared (e.g. case-sensitively or not) is
defined on a per-set basis.</p><div class="impl">
<p>When a user agent has to <dfn id="split-a-string-on-spaces">split a string on spaces</dfn>, it
must use the following algorithm:</p>
<ol><li><p>Let <var title="">input</var> be the string being
parsed.</p></li>
<li><p>Let <var title="">position</var> be a pointer into <var title="">input</var>, initially pointing at the start of the
string.</p></li>
<li><p>Let <var title="">tokens</var> be a list of tokens,
initially empty.</p></li>
<li><p><a href="#skip-whitespace">Skip whitespace</a></p></li>
<li><p>While <var title="">position</var> is not past the end of
<var title="">input</var>:</p>
<ol><li><p><a href="#collect-a-sequence-of-characters">Collect a sequence of characters</a> that are not
<a href="#space-character" title="space character">space characters</a>.</p></li>
<li><p>Add the string collected in the previous step to <var title="">tokens</var>.</p></li>
<li><p><a href="#skip-whitespace">Skip whitespace</a></p></li>
</ol></li>
<li><p>Return <var title="">tokens</var>.</p></li>
</ol><p>When a user agent has to <dfn id="remove-a-token-from-a-string">remove a token from a string</dfn>,
it must use the following algorithm:</p>
<ol><li><p>Let <var title="">input</var> be the string being
modified.</p></li>
<li><p>Let <var title="">token</var> be the token being removed. It
will not contain any <a href="#space-character" title="space character">space
characters</a>.</p></li>
<li><p>Let <var title="">output</var> be the output string,
initially empty.</p></li>
<li><p>Let <var title="">position</var> be a pointer into <var title="">input</var>, initially pointing at the start of the
string.</p></li>
<li><p><i>Loop</i>: If <var title="">position</var> is beyond the
end of <var title="">input</var>, abort these steps.</p></li>
<li><p>If the character at <var title="">position</var> is a
<a href="#space-character">space character</a>:</p>
<ol><li><p>Append the character at <var title="">position</var> to
the end of <var title="">output</var>.</p></li>
<li><p>Advance <var title="">position</var> so it points at the
next character in <var title="">input</var>.</p></li>
<li><p>Return to the step labeled <i>loop</i>.</p></li>
</ol></li>
<li><p>Otherwise, the character at <var title="">position</var> is
the first character of a token. <a href="#collect-a-sequence-of-characters">Collect a sequence of
characters</a> that are not <a href="#space-character" title="space character">space
characters</a>, and let that be <var title="">s</var>.</p></li>
<li><p>If <var title="">s</var> is exactly equal to <var title="">token</var> (this is a <a href="infrastructure.html#case-sensitive">case-sensitive</a>
comparison), then:</p>
<ol><li><p><a href="#skip-whitespace">Skip whitespace</a> (in <var title="">input</var>).</p></li>
<li><p>Remove any <a href="#space-character" title="space character">space
characters</a> currently at the end of <var title="">output</var>.</p></li>
<li><p>If <var title="">position</var> is not past the end of
<var title="">input</var>, and <var title="">output</var> is not
the empty string, append a single U+0020 SPACE character at the
end of <var title="">output</var>.</p></li>
</ol></li>
<li><p>Otherwise, append <var title="">s</var> to the end of <var title="">output</var>.</p></li>
<li><p>Return to the step labeled <i>loop</i>.</p></li>
</ol><p class="note">This causes any occurrences of the token to be
removed from the string, and any spaces that were surrounding the
token to be collapsed to a single space, except at the start and end
of the string, where such spaces are removed.</p>
</div><h4 id="comma-separated-tokens"><span class="secno">2.5.8 </span>Comma-separated tokens</h4><p>A <dfn id="set-of-comma-separated-tokens">set of comma-separated tokens</dfn> is a string containing
zero or more tokens each separated from the next by a single U+002C
COMMA character (,), where tokens consist of any string of zero or
more characters, neither beginning nor ending with <a href="#space-character" title="space character">space characters</a>, nor containing any
U+002C COMMA characters (,), and optionally surrounded by <a href="#space-character" title="space character">space characters</a>.</p><p class="example">For instance, the string "<code title=""> a ,b,,d d </code>" consists of four
tokens: "a", "b", the empty string, and "d d". Leading and
trailing whitespace around each token doesn't count as part of the
token, and the empty string can be a token.</p><p><a href="#set-of-comma-separated-tokens" title="set of comma-separated tokens">Sets of
comma-separated tokens</a> sometimes have further restrictions on
what consists a valid token. When such restrictions are defined, the
tokens must all fit within those restrictions; other values are
non-conforming. If no such restrictions are specified, then all
values are conforming.</p><div class="impl">
<p>When a user agent has to <dfn id="split-a-string-on-commas">split a string on commas</dfn>, it
must use the following algorithm:</p>
<ol><li><p>Let <var title="">input</var> be the string being
parsed.</p></li>
<li><p>Let <var title="">position</var> be a pointer into <var title="">input</var>, initially pointing at the start of the
string.</p></li>
<li><p>Let <var title="">tokens</var> be a list of tokens,
initially empty.</p></li>
<li><p><i>Token</i>: If <var title="">position</var> is past the
end of <var title="">input</var>, jump to the last step.</p></li>
<li><p><a href="#collect-a-sequence-of-characters">Collect a sequence of characters</a> that are not
U+002C COMMA characters (,). Let <var title="">s</var> be the resulting sequence (which might be the
empty string).</p></li>
<li><p>Remove any leading or trailing sequence of <a href="#space-character" title="space character">space characters</a> from <var title="">s</var>.</p></li>
<li><p>Add <var title="">s</var> to <var title="">tokens</var>.</p></li>
<li><p>If <var title="">position</var> is not past the end of <var title="">input</var>, then the character at <var title="">position</var> is a U+002C COMMA character (,); advance
<var title="">position</var> past that character.</p></li>
<li><p>Jump back to the step labeled <i>token</i>.</p></li>
<li><p>Return <var title="">tokens</var>.</p></li>
</ol></div><h4 id="syntax-references"><span class="secno">2.5.9 </span>References</h4><p>A <dfn id="valid-hash-name-reference">valid hash-name reference</dfn> to an element of type <var title="">type</var> is a string consisting of a U+0023 NUMBER SIGN
character (#) followed by a string which exactly matches the value
of the <code title="">name</code> attribute of an element with type
<var title="">type</var> in the document.</p><div class="impl">
<p>The <dfn id="rules-for-parsing-a-hash-name-reference">rules for parsing a hash-name reference</dfn> to an
element of type <var title="">type</var> are as follows:</p>
<ol><li><p>If the string being parsed does not contain a U+0023 NUMBER
SIGN character, or if the first such character in the string is the
last character in the string, then return null and abort these
steps.</p></li>
<li><p>Let <var title="">s</var> be the string from the character
immediately after the first U+0023 NUMBER SIGN character in the
string being parsed up to the end of that string.</p></li>
<li><p>Return the first element of type <var title="">type</var>
that has an <code title="attr-id"><a href="elements.html#the-id-attribute">id</a></code> attribute whose value
is a <a href="infrastructure.html#case-sensitive">case-sensitive</a> match for <var title="">s</var> or
a <code title="">name</code> attribute whose value is a
<a href="infrastructure.html#compatibility-caseless">compatibility caseless</a> match for <var title="">s</var>.</p></li>
</ol></div><h4 id="mq"><span class="secno">2.5.10 </span>Media queries</h4><p>A string is a <dfn id="valid-media-query">valid media query</dfn> if it matches the
<code title="">media_query_list</code> production of the Media
Queries specification. <a href="references.html#refsMQ">[MQ]</a></p><p>A string <dfn id="matches-the-environment">matches the environment</dfn> of the user if it is
the empty string, a string consisting of only <a href="#space-character" title="space
character">space characters</a>, or is a media query that matches
the user's environment according to the definitions given in the
Media Queries specification. <a href="references.html#refsMQ">[MQ]</a></p></body></html>