tabular-data.html
150 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
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
<!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>4.9 Tabular data — 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="the-map-element.html" title="4.8.12 The map element" rel="prev">
<link href="spec.html#contents" title="Table of contents" rel="index">
<link href="forms.html" title="4.10 Forms" 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="the-map-element.html" class="prev">4.8.12 The map element</a> –
<a href="spec.html#contents">Table of contents</a> –
<a href="forms.html" class="next">4.10 Forms</a>
<ol class="toc"><li><ol><li><a href="tabular-data.html#tabular-data"><span class="secno">4.9 </span>Tabular data</a>
<ol><li><a href="tabular-data.html#the-table-element"><span class="secno">4.9.1 </span>The <code>table</code> element</a>
<ol><li><a href="tabular-data.html#table-descriptions-techniques"><span class="secno">4.9.1.1 </span>Techniques for describing tables</a></li><li><a href="tabular-data.html#table-layout-techniques"><span class="secno">4.9.1.2 </span>Techniques for table layout</a></li></ol></li><li><a href="tabular-data.html#the-caption-element"><span class="secno">4.9.2 </span>The <code>caption</code> element</a></li><li><a href="tabular-data.html#the-colgroup-element"><span class="secno">4.9.3 </span>The <code>colgroup</code> element</a></li><li><a href="tabular-data.html#the-col-element"><span class="secno">4.9.4 </span>The <code>col</code> element</a></li><li><a href="tabular-data.html#the-tbody-element"><span class="secno">4.9.5 </span>The <code>tbody</code> element</a></li><li><a href="tabular-data.html#the-thead-element"><span class="secno">4.9.6 </span>The <code>thead</code> element</a></li><li><a href="tabular-data.html#the-tfoot-element"><span class="secno">4.9.7 </span>The <code>tfoot</code> element</a></li><li><a href="tabular-data.html#the-tr-element"><span class="secno">4.9.8 </span>The <code>tr</code> element</a></li><li><a href="tabular-data.html#the-td-element"><span class="secno">4.9.9 </span>The <code>td</code> element</a></li><li><a href="tabular-data.html#the-th-element"><span class="secno">4.9.10 </span>The <code>th</code> element</a></li><li><a href="tabular-data.html#attributes-common-to-td-and-th-elements"><span class="secno">4.9.11 </span>Attributes common to <code>td</code> and <code>th</code> elements</a></li><li><a href="tabular-data.html#processing-model-0"><span class="secno">4.9.12 </span>Processing model</a>
<ol><li><a href="tabular-data.html#forming-a-table"><span class="secno">4.9.12.1 </span>Forming a table</a></li><li><a href="tabular-data.html#header-and-data-cell-semantics"><span class="secno">4.9.12.2 </span>Forming relationships between data cells and header cells</a></li></ol></li><li><a href="tabular-data.html#examples"><span class="secno">4.9.13 </span>Examples</a></li></ol></li></ol></li></ol></div>
<h3 id="tabular-data"><span class="secno">4.9 </span>Tabular data</h3><h4 id="the-table-element"><span class="secno">4.9.1 </span>The <dfn><code>table</code></dfn> element</h4><dl class="element"><dt>Categories</dt>
<dd><a href="content-models.html#flow-content">Flow content</a>.</dd>
<dt>Contexts in which this element can be used:</dt>
<dd>Where <a href="content-models.html#flow-content">flow content</a> is expected.</dd>
<dt>Content model:</dt>
<dd>In this order: optionally a <code><a href="#the-caption-element">caption</a></code> element,
followed by zero or more <code><a href="#the-colgroup-element">colgroup</a></code> elements, followed
optionally by a <code><a href="#the-thead-element">thead</a></code> element, followed optionally by
a <code><a href="#the-tfoot-element">tfoot</a></code> element, followed by either zero or more
<code><a href="#the-tbody-element">tbody</a></code> elements or one or more <code><a href="#the-tr-element">tr</a></code>
elements, followed optionally by a <code><a href="#the-tfoot-element">tfoot</a></code> element (but
there can only be one <code><a href="#the-tfoot-element">tfoot</a></code> element child in
total).</dd>
<dt>Content attributes:</dt>
<dd><a href="elements.html#global-attributes">Global attributes</a></dd>
<dd><code title="attr-table-border"><a href="#attr-table-border">border</a></code></dd>
<dt>DOM interface:</dt>
<dd>
<pre class="idl">interface <dfn id="htmltableelement">HTMLTableElement</dfn> : <a href="elements.html#htmlelement">HTMLElement</a> {
attribute <a href="#htmltablecaptionelement">HTMLTableCaptionElement</a> <a href="#dom-table-caption" title="dom-table-caption">caption</a>;
<a href="elements.html#htmlelement">HTMLElement</a> <a href="#dom-table-createcaption" title="dom-table-createCaption">createCaption</a>();
void <a href="#dom-table-deletecaption" title="dom-table-deleteCaption">deleteCaption</a>();
attribute <a href="#htmltablesectionelement">HTMLTableSectionElement</a> <a href="#dom-table-thead" title="dom-table-tHead">tHead</a>;
<a href="elements.html#htmlelement">HTMLElement</a> <a href="#dom-table-createthead" title="dom-table-createTHead">createTHead</a>();
void <a href="#dom-table-deletethead" title="dom-table-deleteTHead">deleteTHead</a>();
attribute <a href="#htmltablesectionelement">HTMLTableSectionElement</a> <a href="#dom-table-tfoot" title="dom-table-tFoot">tFoot</a>;
<a href="elements.html#htmlelement">HTMLElement</a> <a href="#dom-table-createtfoot" title="dom-table-createTFoot">createTFoot</a>();
void <a href="#dom-table-deletetfoot" title="dom-table-deleteTFoot">deleteTFoot</a>();
readonly attribute <a href="common-dom-interfaces.html#htmlcollection">HTMLCollection</a> <a href="#dom-table-tbodies" title="dom-table-tBodies">tBodies</a>;
<a href="elements.html#htmlelement">HTMLElement</a> <a href="#dom-table-createtbody" title="dom-table-createTBody">createTBody</a>();
readonly attribute <a href="common-dom-interfaces.html#htmlcollection">HTMLCollection</a> <a href="#dom-table-rows" title="dom-table-rows">rows</a>;
<a href="elements.html#htmlelement">HTMLElement</a> <a href="#dom-table-insertrow" title="dom-table-insertRow">insertRow</a>(in optional long index);
void <a href="#dom-table-deleterow" title="dom-table-deleteRow">deleteRow</a>(in long index);
attribute DOMString <a href="#dom-table-border" title="dom-table-border">border</a>;
};</pre>
</dd>
</dl><p>The <code><a href="#the-table-element">table</a></code> element <a href="rendering.html#represents">represents</a> data with
more than one dimension, in the form of a <a href="#concept-table" title="concept-table">table</a>.</p><div class="impl">
<p>The <code><a href="#the-table-element">table</a></code> element takes part in the <a href="#table-model">table
model</a>.</p>
</div><p>Tables have rows, columns, and cells given by their descendants.
The rows and columns form a grid; a table's cells must completely
cover that grid without overlap.</p><div class="impl">
<p class="note">Precise rules for determining whether this
conformance requirement is met are described in the description of
the <a href="#table-model">table model</a>.</p>
</div><hr><p>Authors are encouraged to provide information describing how to
interpret complex tables. Guidance on how <a href="#table-descriptions-techniques">provide such information</a>
is given below.</p><div class="impl">
<p>If a <code><a href="#the-table-element">table</a></code> element has a <code title="attr-table-summary"><a href="obsolete.html#attr-table-summary">summary</a></code> attribute, and the user
agent has not classified the table as a layout table, the user agent
may report the contents of that attribute to the user.</p>
</div><hr><p>Tables should not be used as layout aids.
Historically, many Web authors have tables in HTML as a way to
control their page layout making it difficult to extract tabular
data from such documents.
In particular, users of accessibility tools, like screen readers,
are likely to find it very difficult to navigate pages with tables
used for layout.
If a table is to be used for layout it must be marked with the
attribute role="presentation" for a user agent to properly represent
the table to an assistive technology and to properly convey the
intent of the author to tools that wish to extract tabular data from
the document.</p><p class="note">There are a variety of alternatives to using HTML
tables for layout, primarily using CSS positioning and the CSS table
model.</p><p>The <dfn id="attr-table-border" title="attr-table-border"><code>border</code></dfn>
attribute may be specified on a <code><a href="#the-table-element">table</a></code> element to
explicitly indicate that the <code><a href="#the-table-element">table</a></code> element is not being
used for layout purposes. If specified, the attribute's value must
either be the empty string or the value "<code title="">1</code>".
The attribute is used by certain user agents as an indication that
borders should be drawn around cells of the table.</p><div class="impl">
<p>Tables can be complicated to understand and navigate. To help
users with this, user agents should clearly dilineate cells in a
table from each other, unless the user agent has classified the
table as a
layout table.</p>
</div><p class="note">Authors <span class="impl">and implementors</span>
are encouraged to consider using some of the <a href="#table-layout-techniques">table layout techniques</a>
described below to make tables easier to navigate for users.</p><div class="impl">
<p>User agents, especially those that do table analysis on arbitrary
content, are encouraged to find heuristics to determine which tables
actually contain data and which are merely being used for layout.
This specification does not define a precise heuristic, but the
following are suggested as possible indicators:</p>
<table><thead><tr><th>Feature
</th><th>Indication
</th></tr></thead><tbody><tr><td>The use of the <code title="attr-aria-role">role</code> attribute with the value <code title="attr-aria-role-presentation">presentation</code>
</td><td>Probably a layout table
</td></tr><tr><td>The use of the <code title="attr-table-border"><a href="#attr-table-border">border</a></code> attribute with the non-conforming value 0
</td><td>Probably a layout table
</td></tr><tr><td>The use of the non-conforming <code title="attr-table-cellspacing"><a href="obsolete.html#attr-table-cellspacing">cellspacing</a></code> and <code title="attr-table-cellpadding"><a href="obsolete.html#attr-table-cellpadding">cellpadding</a></code> attributes with the value 0
</td><td>Probably a layout table
</td></tr></tbody><tbody><tr><td>The use of <code><a href="#the-caption-element">caption</a></code>, <code><a href="#the-thead-element">thead</a></code>, or <code><a href="#the-th-element">th</a></code> elements
</td><td>Probably a non-layout table
</td></tr><tr><td>The use of the <code title="attr-tdth-headers"><a href="#attr-tdth-headers">headers</a></code> and <code title="attr-th-scope"><a href="#attr-th-scope">scope</a></code> attributes
</td><td>Probably a non-layout table
</td></tr><tr><td>The use of the <code title="attr-table-border"><a href="#attr-table-border">border</a></code> attribute with a value other than 0
</td><td>Probably a non-layout table
</td></tr><tr><td>Explicit visible borders set using CSS
</td><td>Probably a non-layout table
</td></tr></tbody><tbody><tr><td>The use of the <code title="attr-table-summary"><a href="obsolete.html#attr-table-summary">summary</a></code> attribute
</td><td>Not a good indicator (both layout and non-layout tables have historically been given this attribute)
</td></tr></tbody></table></div><hr><dl class="domintro"><dt><var title="">table</var> . <code title="dom-table-caption"><a href="#dom-table-caption">caption</a></code> [ = <var title="">value</var> ]</dt>
<dd>
<p>Returns the table's <code><a href="#the-caption-element">caption</a></code> element.</p>
<p>Can be set, to replace the <code><a href="#the-caption-element">caption</a></code> element. If the
new value is not a <code><a href="#the-caption-element">caption</a></code> element, throws a
<code><a href="common-dom-interfaces.html#hierarchy_request_err">HIERARCHY_REQUEST_ERR</a></code> exception.</p>
</dd>
<dt><var title="">caption</var> = <var title="">table</var> . <code title="dom-table-createCaption"><a href="#dom-table-createcaption">createCaption</a></code>()</dt>
<dd>
<p>Ensures the table has a <code><a href="#the-caption-element">caption</a></code> element, and returns it.</p>
</dd>
<dt><var title="">table</var> . <code title="dom-table-deleteCaption"><a href="#dom-table-deletecaption">deleteCaption</a></code>()</dt>
<dd>
<p>Ensures the table does not have a <code><a href="#the-caption-element">caption</a></code> element.</p>
</dd>
<dt><var title="">table</var> . <code title="dom-table-tHead"><a href="#dom-table-thead">tHead</a></code> [ = <var title="">value</var> ]</dt>
<dd>
<p>Returns the table's <code><a href="#the-thead-element">thead</a></code> element.</p>
<p>Can be set, to replace the <code><a href="#the-thead-element">thead</a></code> element. If the
new value is not a <code><a href="#the-thead-element">thead</a></code> element, throws a
<code><a href="common-dom-interfaces.html#hierarchy_request_err">HIERARCHY_REQUEST_ERR</a></code> exception.</p>
</dd>
<dt><var title="">thead</var> = <var title="">table</var> . <code title="dom-table-createTHead"><a href="#dom-table-createthead">createTHead</a></code>()</dt>
<dd>
<p>Ensures the table has a <code><a href="#the-thead-element">thead</a></code> element, and returns it.</p>
</dd>
<dt><var title="">table</var> . <code title="dom-table-deleteTHead"><a href="#dom-table-deletethead">deleteTHead</a></code>()</dt>
<dd>
<p>Ensures the table does not have a <code><a href="#the-thead-element">thead</a></code> element.</p>
</dd>
<dt><var title="">table</var> . <code title="dom-table-tFoot"><a href="#dom-table-tfoot">tFoot</a></code> [ = <var title="">value</var> ]</dt>
<dd>
<p>Returns the table's <code><a href="#the-tfoot-element">tfoot</a></code> element.</p>
<p>Can be set, to replace the <code><a href="#the-tfoot-element">tfoot</a></code> element. If the
new value is not a <code><a href="#the-tfoot-element">tfoot</a></code> element, throws a
<code><a href="common-dom-interfaces.html#hierarchy_request_err">HIERARCHY_REQUEST_ERR</a></code> exception.</p>
</dd>
<dt><var title="">tfoot</var> = <var title="">table</var> . <code title="dom-table-createTFoot"><a href="#dom-table-createtfoot">createTFoot</a></code>()</dt>
<dd>
<p>Ensures the table has a <code><a href="#the-tfoot-element">tfoot</a></code> element, and returns it.</p>
</dd>
<dt><var title="">table</var> . <code title="dom-table-deleteTFoot"><a href="#dom-table-deletetfoot">deleteTFoot</a></code>()</dt>
<dd>
<p>Ensures the table does not have a <code><a href="#the-tfoot-element">tfoot</a></code> element.</p>
</dd>
<dt><var title="">table</var> . <code title="dom-table-tBodies"><a href="#dom-table-tbodies">tBodies</a></code></dt>
<dd>
<p>Returns an <code><a href="common-dom-interfaces.html#htmlcollection">HTMLCollection</a></code> of the <code><a href="#the-tbody-element">tbody</a></code> elements of the table.</p>
</dd>
<dt><var title="">tbody</var> = <var title="">table</var> . <code title="dom-table-createTBody"><a href="#dom-table-createtbody">createTBody</a></code>()</dt>
<dd>
<p>Creates a <code><a href="#the-tbody-element">tbody</a></code> element, inserts it into the table, and returns it.</p>
</dd>
<dt><var title="">table</var> . <code title="dom-table-rows"><a href="#dom-table-rows">rows</a></code></dt>
<dd>
<p>Returns an <code><a href="common-dom-interfaces.html#htmlcollection">HTMLCollection</a></code> of the <code><a href="#the-tr-element">tr</a></code> elements of the table.</p>
</dd>
<dt><var title="">tr</var> = <var title="">table</var> . <code title="dom-table-insertRow"><a href="#dom-table-insertrow">insertRow</a></code>(<var title="">index</var>)</dt>
<dd>
<p>Creates a <code><a href="#the-tr-element">tr</a></code> element, along with a <code><a href="#the-tbody-element">tbody</a></code> if required, inserts them into the table at the position given by the argument, and returns the <code><a href="#the-tr-element">tr</a></code>.</p>
<p>The position is relative to the rows in the table. The index −1 is equivalent to inserting at the end of the table.</p>
<p>If the given position is less than −1 or greater than the number of rows, throws an <code><a href="common-dom-interfaces.html#index_size_err">INDEX_SIZE_ERR</a></code> exception.</p>
</dd>
<dt><var title="">table</var> . <code title="dom-table-deleteRow"><a href="#dom-table-deleterow">deleteRow</a></code>(<var title="">index</var>)</dt>
<dd>
<p>Removes the <code><a href="#the-tr-element">tr</a></code> element with the given position in the table.</p>
<p>The position is relative to the rows in the table. The index −1 is equivalent to deleting the last row of the table.</p>
<p>If the given position is less than −1 or greater than the index of the last row, or if there are no rows, throws an <code><a href="common-dom-interfaces.html#index_size_err">INDEX_SIZE_ERR</a></code> exception.</p>
</dd>
</dl><div class="impl">
<p>The <dfn id="dom-table-caption" title="dom-table-caption"><code>caption</code></dfn> IDL
attribute must return, on getting, the first <code><a href="#the-caption-element">caption</a></code>
element child of the <code><a href="#the-table-element">table</a></code> element, if any, or null
otherwise. On setting, if the new value is a <code><a href="#the-caption-element">caption</a></code>
element, the first <code><a href="#the-caption-element">caption</a></code> element child of the
<code><a href="#the-table-element">table</a></code> element, if any, must be removed, and the new
value must be inserted as the first node of the <code><a href="#the-table-element">table</a></code>
element. If the new value is not a <code><a href="#the-caption-element">caption</a></code> element,
then a <code><a href="common-dom-interfaces.html#hierarchy_request_err">HIERARCHY_REQUEST_ERR</a></code> DOM exception must be
raised instead.</p>
<p>The <dfn id="dom-table-createcaption" title="dom-table-createCaption"><code>createCaption()</code></dfn>
method must return the first <code><a href="#the-caption-element">caption</a></code> element child of
the <code><a href="#the-table-element">table</a></code> element, if any; otherwise a new
<code><a href="#the-caption-element">caption</a></code> element must be created, inserted as the first
node of the <code><a href="#the-table-element">table</a></code> element, and then returned.</p>
<p>The <dfn id="dom-table-deletecaption" title="dom-table-deleteCaption"><code>deleteCaption()</code></dfn>
method must remove the first <code><a href="#the-caption-element">caption</a></code> element child of
the <code><a href="#the-table-element">table</a></code> element, if any.</p>
<p>The <dfn id="dom-table-thead" title="dom-table-tHead"><code>tHead</code></dfn> IDL
attribute must return, on getting, the first <code><a href="#the-thead-element">thead</a></code>
element child of the <code><a href="#the-table-element">table</a></code> element, if any, or null
otherwise. On setting, if the new value is a <code><a href="#the-thead-element">thead</a></code>
element, the first <code><a href="#the-thead-element">thead</a></code> element child of the
<code><a href="#the-table-element">table</a></code> element, if any, must be removed, and the new
value must be inserted immediately before the first element in the
<code><a href="#the-table-element">table</a></code> element that is neither a <code><a href="#the-caption-element">caption</a></code>
element nor a <code><a href="#the-colgroup-element">colgroup</a></code> element, if any, or at the end
of the table if there are no such elements. If the new value is not
a <code><a href="#the-thead-element">thead</a></code> element, then a
<code><a href="common-dom-interfaces.html#hierarchy_request_err">HIERARCHY_REQUEST_ERR</a></code> DOM exception must be raised
instead.</p>
<p>The <dfn id="dom-table-createthead" title="dom-table-createTHead"><code>createTHead()</code></dfn>
method must return the first <code><a href="#the-thead-element">thead</a></code> element child of the
<code><a href="#the-table-element">table</a></code> element, if any; otherwise a new
<code><a href="#the-thead-element">thead</a></code> element must be created and inserted immediately
before the first element in the <code><a href="#the-table-element">table</a></code> element that is
neither a <code><a href="#the-caption-element">caption</a></code> element nor a <code><a href="#the-colgroup-element">colgroup</a></code>
element, if any, or at the end of the table if there are no such
elements, and then that new element must be returned.</p>
<p>The <dfn id="dom-table-deletethead" title="dom-table-deleteTHead"><code>deleteTHead()</code></dfn>
method must remove the first <code><a href="#the-thead-element">thead</a></code> element child of the
<code><a href="#the-table-element">table</a></code> element, if any.</p>
<p>The <dfn id="dom-table-tfoot" title="dom-table-tFoot"><code>tFoot</code></dfn> IDL
attribute must return, on getting, the first <code><a href="#the-tfoot-element">tfoot</a></code>
element child of the <code><a href="#the-table-element">table</a></code> element, if any, or null
otherwise. On setting, if the new value is a <code><a href="#the-tfoot-element">tfoot</a></code>
element, the first <code><a href="#the-tfoot-element">tfoot</a></code> element child of the
<code><a href="#the-table-element">table</a></code> element, if any, must be removed, and the new
value must be inserted immediately before the first element in the
<code><a href="#the-table-element">table</a></code> element that is neither a <code><a href="#the-caption-element">caption</a></code>
element, a <code><a href="#the-colgroup-element">colgroup</a></code> element, nor a <code><a href="#the-thead-element">thead</a></code>
element, if any, or at the end of the table if there are no such
elements. If the new value is not a <code><a href="#the-tfoot-element">tfoot</a></code> element, then
a <code><a href="common-dom-interfaces.html#hierarchy_request_err">HIERARCHY_REQUEST_ERR</a></code> DOM exception must be raised
instead.</p>
<p>The <dfn id="dom-table-createtfoot" title="dom-table-createTFoot"><code>createTFoot()</code></dfn>
method must return the first <code><a href="#the-tfoot-element">tfoot</a></code> element child of the
<code><a href="#the-table-element">table</a></code> element, if any; otherwise a new
<code><a href="#the-tfoot-element">tfoot</a></code> element must be created and inserted immediately
before the first element in the <code><a href="#the-table-element">table</a></code> element that is
neither a <code><a href="#the-caption-element">caption</a></code> element, a <code><a href="#the-colgroup-element">colgroup</a></code>
element, nor a <code><a href="#the-thead-element">thead</a></code> element, if any, or at the end of
the table if there are no such elements, and then that new element
must be returned.</p>
<p>The <dfn id="dom-table-deletetfoot" title="dom-table-deleteTFoot"><code>deleteTFoot()</code></dfn>
method must remove the first <code><a href="#the-tfoot-element">tfoot</a></code> element child of the
<code><a href="#the-table-element">table</a></code> element, if any.</p>
<p>The <dfn id="dom-table-tbodies" title="dom-table-tBodies"><code>tBodies</code></dfn>
attribute must return an <code><a href="common-dom-interfaces.html#htmlcollection">HTMLCollection</a></code> rooted at the
<code><a href="#the-table-element">table</a></code> node, whose filter matches only
<code><a href="#the-tbody-element">tbody</a></code> elements that are children of the
<code><a href="#the-table-element">table</a></code> element.</p>
<p>The <dfn id="dom-table-createtbody" title="dom-table-createTBody"><code>createTBody()</code></dfn>
method must create a new <code><a href="#the-tbody-element">tbody</a></code> element, insert it
immediately after the last <code><a href="#the-tbody-element">tbody</a></code> element in the
<code><a href="#the-table-element">table</a></code> element, if any, or at the end of the
<code><a href="#the-table-element">table</a></code> element if the <code><a href="#the-table-element">table</a></code> element has no
<code><a href="#the-tbody-element">tbody</a></code> element children, and then must return the new
<code><a href="#the-tbody-element">tbody</a></code> element.</p>
<p>The <dfn id="dom-table-rows" title="dom-table-rows"><code>rows</code></dfn> attribute
must return an <code><a href="common-dom-interfaces.html#htmlcollection">HTMLCollection</a></code> rooted at the
<code><a href="#the-table-element">table</a></code> node, whose filter matches only <code><a href="#the-tr-element">tr</a></code>
elements that are either children of the <code><a href="#the-table-element">table</a></code> element,
or children of <code><a href="#the-thead-element">thead</a></code>, <code><a href="#the-tbody-element">tbody</a></code>, or
<code><a href="#the-tfoot-element">tfoot</a></code> elements that are themselves children of the
<code><a href="#the-table-element">table</a></code> element. The elements in the collection must be
ordered such that those elements whose parent is a
<code><a href="#the-thead-element">thead</a></code> are included first, in tree order, followed by
those elements whose parent is either a <code><a href="#the-table-element">table</a></code> or
<code><a href="#the-tbody-element">tbody</a></code> element, again in tree order, followed finally by
those elements whose parent is a <code><a href="#the-tfoot-element">tfoot</a></code> element, still
in tree order.</p>
<p>The behavior of the <dfn id="dom-table-insertrow" title="dom-table-insertRow"><code>insertRow(<var title="">index</var>)</code></dfn> method depends on the state of
the table. When it is called, the method must act as required by the
first item in the following list of conditions that describes the
state of the table and the <var title="">index</var> argument:</p>
<dl class="switch"><dt>If <var title="">index</var> is less than −1 or greater than
the number of elements in <code title="dom-table-rows"><a href="#dom-table-rows">rows</a></code>
collection:</dt>
<dd>The method must raise an <code><a href="common-dom-interfaces.html#index_size_err">INDEX_SIZE_ERR</a></code>
exception.</dd>
<dt>If the <code title="dom-table-rows"><a href="#dom-table-rows">rows</a></code> collection has
zero elements in it, and the <code><a href="#the-table-element">table</a></code> has no
<code><a href="#the-tbody-element">tbody</a></code> elements in it:</dt>
<dd>The method must create a <code><a href="#the-tbody-element">tbody</a></code> element, then
create a <code><a href="#the-tr-element">tr</a></code> element, then append the <code><a href="#the-tr-element">tr</a></code>
element to the <code><a href="#the-tbody-element">tbody</a></code> element, then append the
<code><a href="#the-tbody-element">tbody</a></code> element to the <code><a href="#the-table-element">table</a></code> element, and
finally return the <code><a href="#the-tr-element">tr</a></code> element.</dd>
<dt>If the <code title="dom-table-rows"><a href="#dom-table-rows">rows</a></code> collection has
zero elements in it:</dt>
<dd>The method must create a <code><a href="#the-tr-element">tr</a></code> element, append it to
the last <code><a href="#the-tbody-element">tbody</a></code> element in the table, and return the
<code><a href="#the-tr-element">tr</a></code> element.</dd>
<dt>If <var title="">index</var> is missing, equal to −1, or
equal to the number of items in <code title="dom-table-rows"><a href="#dom-table-rows">rows</a></code> collection:</dt>
<dd>The method must create a <code><a href="#the-tr-element">tr</a></code> element, and append it
to the parent of the last <code><a href="#the-tr-element">tr</a></code> element in the <code title="dom-table-rows"><a href="#dom-table-rows">rows</a></code> collection. Then, the newly
created <code><a href="#the-tr-element">tr</a></code> element must be returned.</dd>
<dt>Otherwise:</dt>
<dd>The method must create a <code><a href="#the-tr-element">tr</a></code> element, insert it
immediately before the <var title="">index</var>th <code><a href="#the-tr-element">tr</a></code>
element in the <code title="dom-table-rows"><a href="#dom-table-rows">rows</a></code> collection,
in the same parent, and finally must return the newly created
<code><a href="#the-tr-element">tr</a></code> element.</dd>
</dl><p>When the <dfn id="dom-table-deleterow" title="dom-table-deleteRow"><code>deleteRow(<var title="">index</var>)</code></dfn> method is called, the user agent
must run the following steps:</p>
<ol><li><p>If <var title="">index</var> is equal to −1, then
<var title="">index</var> must be set to the number if items in the
<code title="dom-table-rows"><a href="#dom-table-rows">rows</a></code> collection, minus
one.</p></li>
<li><p>Now, if <var title="">index</var> is less than zero, or
greater than or equal to the number of elements in the <code title="dom-table-rows"><a href="#dom-table-rows">rows</a></code> collection, the method must
instead raise an <code><a href="common-dom-interfaces.html#index_size_err">INDEX_SIZE_ERR</a></code> exception, and these
steps must be aborted.</p></li>
<li><p>Otherwise, the method must remove the <var title="">index</var>th element in the <code title="dom-table-rows"><a href="#dom-table-rows">rows</a></code> collection from its parent.</p>
</li></ol><p>The <dfn id="dom-table-border" title="dom-table-border"><code>border</code></dfn> IDL
attribute must <a href="common-dom-interfaces.html#reflect">reflect</a> the content attribute of the
same name.</p>
</div><div class="example">
<p>Here is an example of a table being used to mark up a Sudoku
puzzle. Observe the lack of headers, which are not necessary in
such a table.</p>
<pre><section>
<style scoped>
table { border-collapse: collapse; border: solid thick; }
colgroup, tbody { border: solid medium; }
td { border: solid thin; height: 1.4em; width: 1.4em; text-align: center; padding: 0; }
</style>
<h1>Today's Sudoku</h1>
<table>
<colgroup><col><col><col>
<colgroup><col><col><col>
<colgroup><col><col><col>
<tbody>
<tr> <td> 1 <td> <td> 3 <td> 6 <td> <td> 4 <td> 7 <td> <td> 9
<tr> <td> <td> 2 <td> <td> <td> 9 <td> <td> <td> 1 <td>
<tr> <td> 7 <td> <td> <td> <td> <td> <td> <td> <td> 6
<tbody>
<tr> <td> 2 <td> <td> 4 <td> <td> 3 <td> <td> 9 <td> <td> 8
<tr> <td> <td> <td> <td> <td> <td> <td> <td> <td>
<tr> <td> 5 <td> <td> <td> 9 <td> <td> 7 <td> <td> <td> 1
<tbody>
<tr> <td> 6 <td> <td> <td> <td> 5 <td> <td> <td> <td> 2
<tr> <td> <td> <td> <td> <td> 7 <td> <td> <td> <td>
<tr> <td> 9 <td> <td> <td> 8 <td> <td> 2 <td> <td> <td> 5
</table>
</section></pre>
</div><h5 id="table-descriptions-techniques"><span class="secno">4.9.1.1 </span>Techniques for describing tables</h5><p id="table-descriptions">For tables that consist of more than just
a grid of cells with headers in the first row and headers in the
first column, and for any table in general where the reader might
have difficulty understanding the content, authors should include
explanatory information introducing the table. This information is
useful for all users, but is especially useful for users who cannot
see the table, e.g. users of screen readers.</p><p>Such explanatory information should introduce the purpose of the
table, outline its basic cell structure, highlight any trends or
patterns, and generally teach the user how to use the table.</p><p>For instance, the following table:</p><table><caption>Characteristics with positive and negative sides</caption>
<thead><tr><th id="n"> Negative
</th><th> Characteristic
</th><th> Positive
</th></tr></thead><tbody><tr><td headers="n r1"> Sad
</td><th id="r1"> Mood
</th><td> Happy
</td></tr><tr><td headers="n r2"> Failing
</td><th id="r2"> Grade
</th><td> Passing
</td></tr></tbody></table><p>...might benefit from a description explaining the way the table
is laid out, something like "Characteristics are given in the
second column, with the negative side in the left column and the
positive side in the right column".</p><p>There are a variety of ways to include this information, such as:</p><dl><dt>In prose, surrounding the table</dt>
<dd>
<div class="example"><pre><p>In the following table, characteristics are given in the second
column, with the negative side in the left column and the positive
side in the right column.</p>
<table>
<caption>Characteristics with positive and negative sides</caption>
<thead>
<tr>
<th id="n"> Negative
<th> Characteristic
<th> Positive
<tbody>
<tr>
<td headers="n r1"> Sad
<th id="r1"> Mood
<td> Happy
<tr>
<td headers="n r2"> Failing
<th id="r2"> Grade
<td> Passing
</table></pre></div>
</dd>
<dt>In the table's <code><a href="#the-caption-element">caption</a></code></dt>
<dd>
<div class="example"><pre><table>
<caption>
<strong>Characteristics with positive and negative sides.</strong>
<p>Characteristics are given in the second column, with the
negative side in the left column and the positive side in the right
column.</p>
</caption>
<thead>
<tr>
<th id="n"> Negative
<th> Characteristic
<th> Positive
<tbody>
<tr>
<td headers="n r1"> Sad
<th id="r1"> Mood
<td> Happy
<tr>
<td headers="n r2"> Failing
<th id="r2"> Grade
<td> Passing
</table></pre></div>
</dd>
<dt>In the table's <code><a href="#the-caption-element">caption</a></code>, in a <code><a href="interactive-elements.html#the-details-element">details</a></code> element</dt>
<dd>
<div class="example"><pre><table>
<caption>
<strong>Characteristics with positive and negative sides.</strong>
<details>
<summary>Help</summary>
<p>Characteristics are given in the second column, with the
negative side in the left column and the positive side in the right
column.</p>
</details>
</caption>
<thead>
<tr>
<th id="n"> Negative
<th> Characteristic
<th> Positive
<tbody>
<tr>
<td headers="n r1"> Sad
<th id="r1"> Mood
<td> Happy
<tr>
<td headers="n r2"> Failing
<th id="r2"> Grade
<td> Passing
</table></pre></div>
</dd>
<dt>Next to the table, in the same <code><a href="grouping-content.html#the-figure-element">figure</a></code></dt>
<dd>
<div class="example"><pre><figure>
<figcaption>Characteristics with positive and negative sides</figcaption>
<p>Characteristics are given in the second column, with the
negative side in the left column and the positive side in the right
column.</p>
<table>
<thead>
<tr>
<th id="n"> Negative
<th> Characteristic
<th> Positive
<tbody>
<tr>
<td headers="n r1"> Sad
<th id="r1"> Mood
<td> Happy
<tr>
<td headers="n r2"> Failing
<th id="r2"> Grade
<td> Passing
</table>
</figure></pre></div>
</dd>
<dt>Next to the table, in a <code><a href="grouping-content.html#the-figure-element">figure</a></code>'s <code><a href="grouping-content.html#the-figcaption-element">figcaption</a></code></dt>
<dd>
<div class="example"><pre><figure>
<figcaption>
<strong>Characteristics with positive and negative sides</strong>
<p>Characteristics are given in the second column, with the
negative side in the left column and the positive side in the right
column.</p>
</figcaption>
<table>
<thead>
<tr>
<th id="n"> Negative
<th> Characteristic
<th> Positive
<tbody>
<tr>
<td headers="n r1"> Sad
<th id="r1"> Mood
<td> Happy
<tr>
<td headers="n r2"> Failing
<th id="r2"> Grade
<td> Passing
</table>
</figure></pre></div>
</dd>
</dl><p>Authors may also use other techniques, or combinations of the
above techniques, as appropriate.</p><p>The best option, of course, rather than writing a description
explaining the way the table is laid out, is to adjust the table
such that no explanation is needed.</p><div class="example">
<p>In the case of the table used in the examples above, a simple
rearrangement of the table so that the headers are on the top and
left sides removes the need for an explanation as well as removing
the need for the use of <code title="attr-tdth-headers"><a href="#attr-tdth-headers">headers</a></code> attributes:</p>
<pre><table>
<caption>Characteristics with positive and negative sides</caption>
<thead>
<tr>
<th> Characteristic
<th> Negative
<th> Positive
<tbody>
<tr>
<th> Mood
<td> Sad
<td> Happy
<tr>
<th> Grade
<td> Failing
<td> Passing
</table></pre>
</div><h5 id="table-layout-techniques"><span class="secno">4.9.1.2 </span>Techniques for table layout</h5><p>Good table layout is key to making tables more readable and usable.</p><p>In visual media, providing column and row borders and alternating
row backgrounds can be very effective to make complicated tables
more readable.</p><p>For tables with large volumes of numeric content, using
monospaced fonts can help users see patterns, especially in
situations where a user agent does not render the borders.
(Unfortunately, for historical reasons, not rendering borders on
tables is a common default.)</p><p>In speech media, table cells can be distinguished by reporting
the corresponding headers before reading the cell's contents, and by
allowing users to navigate the table in a grid fashion, rather than
serializing the entire contents of the table in source order.</p><p>Authors are encouraged to use CSS to achieve these effects.</p><div class="impl">
<p>User agents are encouraged to render tables using these
techniques whenever the page does not use CSS and the table is not
classified as a layout table.</p>
</div><h4 id="the-caption-element"><span class="secno">4.9.2 </span>The <dfn><code>caption</code></dfn> element</h4><dl class="element"><dt>Categories</dt>
<dd>None.</dd>
<dt>Contexts in which this element can be used:</dt>
<dd>As the first element child of a <code><a href="#the-table-element">table</a></code> element.</dd>
<dt>Content model:</dt>
<dd><a href="content-models.html#flow-content">Flow content</a>, but with no descendant <code><a href="#the-table-element">table</a></code> elements.</dd>
<dt>Content attributes:</dt>
<dd><a href="elements.html#global-attributes">Global attributes</a></dd>
<dt>DOM interface:</dt>
<dd>
<pre class="idl">interface <dfn id="htmltablecaptionelement">HTMLTableCaptionElement</dfn> : <a href="elements.html#htmlelement">HTMLElement</a> {};</pre>
</dd>
</dl><p>The <code><a href="#the-caption-element">caption</a></code> element <a href="rendering.html#represents">represents</a> the title of the
<code><a href="#the-table-element">table</a></code> that is its parent, if it has a parent and that
is a <code><a href="#the-table-element">table</a></code> element.</p><div class="impl">
<p>The <code><a href="#the-caption-element">caption</a></code> element takes part in the <a href="#table-model">table
model</a>.</p>
</div><p>When a <code><a href="#the-table-element">table</a></code> element is the only content in a
<code><a href="grouping-content.html#the-figure-element">figure</a></code> element other than the <code><a href="grouping-content.html#the-figcaption-element">figcaption</a></code>,
the <code><a href="#the-caption-element">caption</a></code> element should be omitted in favor of the
<code><a href="grouping-content.html#the-figcaption-element">figcaption</a></code>.</p><p>A caption can introduce context for a table, making it
significantly easier to understand.</p><div class="example">
<p>Consider, for instance, the following table:</p>
<table class="dice-example"><tr><th> </th><th> 1 </th><th> 2 </th><th> 3 </th><th> 4 </th><th> 5 </th><th> 6
</th></tr><tr><th> 1 </th><td> 2 </td><td> 3 </td><td> 4 </td><td> 5 </td><td> 6 </td><td> 7
</td></tr><tr><th> 2 </th><td> 3 </td><td> 4 </td><td> 5 </td><td> 6 </td><td> 7 </td><td> 8
</td></tr><tr><th> 3 </th><td> 4 </td><td> 5 </td><td> 6 </td><td> 7 </td><td> 8 </td><td> 9
</td></tr><tr><th> 4 </th><td> 5 </td><td> 6 </td><td> 7 </td><td> 8 </td><td> 9 </td><td> 10
</td></tr><tr><th> 5 </th><td> 6 </td><td> 7 </td><td> 8 </td><td> 9 </td><td> 10 </td><td> 11
</td></tr><tr><th> 6 </th><td> 7 </td><td> 8 </td><td> 9 </td><td> 10 </td><td> 11 </td><td> 12
</td></tr></table><p>In the abstract, this table is not clear. However, with a
caption giving the table's number (for reference in the main prose)
and explaining its use, it makes more sense:</p>
<pre><caption>
<p>Table 1.
<p>This table shows the total score obtained from rolling two
six-sided dice. The first row represents the value of the first die,
the first column the value of the second die. The total is given in
the cell that corresponds to the values of the two dice.
</caption></pre>
</div><h4 id="the-colgroup-element"><span class="secno">4.9.3 </span>The <dfn><code>colgroup</code></dfn> element</h4><dl class="element"><dt>Categories</dt>
<dd>None.</dd>
<dt>Contexts in which this element can be used:</dt>
<dd>As a child of a <code><a href="#the-table-element">table</a></code> element, after any
<code><a href="#the-caption-element">caption</a></code> elements and before any <code><a href="#the-thead-element">thead</a></code>,
<code><a href="#the-tbody-element">tbody</a></code>, <code><a href="#the-tfoot-element">tfoot</a></code>, and <code><a href="#the-tr-element">tr</a></code>
elements.</dd>
<dt>Content model:</dt>
<dd>If the <code title="attr-colgroup-span"><a href="#attr-colgroup-span">span</a></code> attribute is present: Empty.</dd>
<dd>If the <code title="attr-colgroup-span"><a href="#attr-colgroup-span">span</a></code> attribute is absent: Zero or more <code><a href="#the-col-element">col</a></code> elements.</dd>
<dt>Content attributes:</dt>
<dd><a href="elements.html#global-attributes">Global attributes</a></dd>
<dd><code title="attr-colgroup-span"><a href="#attr-colgroup-span">span</a></code></dd>
<dt>DOM interface:</dt>
<dd>
<pre class="idl">interface <dfn id="htmltablecolelement">HTMLTableColElement</dfn> : <a href="elements.html#htmlelement">HTMLElement</a> {
attribute unsigned long <a href="#dom-colgroup-span" title="dom-colgroup-span">span</a>;
};</pre>
</dd>
</dl><p>The <code><a href="#the-colgroup-element">colgroup</a></code> element <a href="rendering.html#represents">represents</a> a <a href="#concept-column-group" title="concept-column-group">group</a> of one or more <a href="#concept-column" title="concept-column">columns</a> in the <code><a href="#the-table-element">table</a></code> that
is its parent, if it has a parent and that is a <code><a href="#the-table-element">table</a></code>
element.</p><p>If the <code><a href="#the-colgroup-element">colgroup</a></code> element contains no <code><a href="#the-col-element">col</a></code>
elements, then the element may have a <dfn id="attr-colgroup-span" title="attr-colgroup-span"><code>span</code></dfn> content attribute
specified, whose value must be a <a href="common-microsyntaxes.html#valid-non-negative-integer">valid non-negative
integer</a> greater than zero.</p><div class="impl">
<p>The <code><a href="#the-colgroup-element">colgroup</a></code> element and its <code title="attr-colgroup-span"><a href="#attr-colgroup-span">span</a></code> attribute take part in the
<a href="#table-model">table model</a>.</p>
<p>The <dfn id="dom-colgroup-span" title="dom-colgroup-span"><code>span</code></dfn> IDL
attribute must <a href="common-dom-interfaces.html#reflect">reflect</a> the content attribute of the
same name. The value must be <a href="common-dom-interfaces.html#limited-to-only-non-negative-numbers-greater-than-zero">limited to only non-negative
numbers greater than zero</a>.</p>
</div><h4 id="the-col-element"><span class="secno">4.9.4 </span>The <dfn><code>col</code></dfn> element</h4><dl class="element"><dt>Categories</dt>
<dd>None.</dd>
<dt>Contexts in which this element can be used:</dt>
<dd>As a child of a <code><a href="#the-colgroup-element">colgroup</a></code> element that doesn't have
a <code title="attr-col-span"><a href="#attr-col-span">span</a></code> attribute.</dd>
<dt>Content model:</dt>
<dd>Empty.</dd>
<dt>Content attributes:</dt>
<dd><a href="elements.html#global-attributes">Global attributes</a></dd>
<dd><code title="attr-col-span"><a href="#attr-col-span">span</a></code></dd>
<dt>DOM interface:</dt>
<dd>
<p><code><a href="#htmltablecolelement">HTMLTableColElement</a></code>, same as for
<code><a href="#the-colgroup-element">colgroup</a></code> elements. This interface defines one member,
<code title="dom-col-span"><a href="#dom-col-span">span</a></code>.</p>
</dd>
</dl><p>If a <code><a href="#the-col-element">col</a></code> element has a parent and that is a
<code><a href="#the-colgroup-element">colgroup</a></code> element that itself has a parent that is a
<code><a href="#the-table-element">table</a></code> element, then the <code><a href="#the-col-element">col</a></code> element
<a href="rendering.html#represents">represents</a> one or more <a href="#concept-column" title="concept-column">columns</a> in the <a href="#concept-column-group" title="concept-column-group">column group</a> represented by that
<code><a href="#the-colgroup-element">colgroup</a></code>.</p><p>The element may have a <dfn id="attr-col-span" title="attr-col-span"><code>span</code></dfn> content attribute
specified, whose value must be a <a href="common-microsyntaxes.html#valid-non-negative-integer">valid non-negative
integer</a> greater than zero.</p><div class="impl">
<p>The <code><a href="#the-col-element">col</a></code> element and its <code title="attr-col-span"><a href="#attr-col-span">span</a></code> attribute take part in the
<a href="#table-model">table model</a>.</p>
<p>The <dfn id="dom-col-span" title="dom-col-span"><code>span</code></dfn> IDL
attribute must <a href="common-dom-interfaces.html#reflect">reflect</a> the content attribute of the
same name. The value must be <a href="common-dom-interfaces.html#limited-to-only-non-negative-numbers-greater-than-zero">limited to only non-negative
numbers greater than zero</a>.</p>
</div><h4 id="the-tbody-element"><span class="secno">4.9.5 </span>The <dfn><code>tbody</code></dfn> element</h4><dl class="element"><dt>Categories</dt>
<dd>None.</dd>
<dt>Contexts in which this element can be used:</dt>
<dd>As a child of a <code><a href="#the-table-element">table</a></code> element, after any
<code><a href="#the-caption-element">caption</a></code>, <code><a href="#the-colgroup-element">colgroup</a></code>, and
<code><a href="#the-thead-element">thead</a></code> elements, but only if there are no
<code><a href="#the-tr-element">tr</a></code> elements that are children of the
<code><a href="#the-table-element">table</a></code> element.</dd>
<dt>Content model:</dt>
<dd>Zero or more <code><a href="#the-tr-element">tr</a></code> elements</dd>
<dt>Content attributes:</dt>
<dd><a href="elements.html#global-attributes">Global attributes</a></dd>
<dt>DOM interface:</dt>
<dd>
<pre class="idl">interface <dfn id="htmltablesectionelement">HTMLTableSectionElement</dfn> : <a href="elements.html#htmlelement">HTMLElement</a> {
readonly attribute <a href="common-dom-interfaces.html#htmlcollection">HTMLCollection</a> <a href="#dom-tbody-rows" title="dom-tbody-rows">rows</a>;
<a href="elements.html#htmlelement">HTMLElement</a> <a href="#dom-tbody-insertrow" title="dom-tbody-insertRow">insertRow</a>(in optional long index);
void <a href="#dom-tbody-deleterow" title="dom-tbody-deleteRow">deleteRow</a>(in long index);
};</pre>
<p>The <code><a href="#htmltablesectionelement">HTMLTableSectionElement</a></code> interface is also
used for <code><a href="#the-thead-element">thead</a></code> and <code><a href="#the-tfoot-element">tfoot</a></code> elements.</p>
</dd>
</dl><p>The <code><a href="#the-tbody-element">tbody</a></code> element <a href="rendering.html#represents">represents</a> a <a href="#concept-row-group" title="concept-row-group">block</a> of <a href="#concept-row" title="concept-row">rows</a> that consist of a body of data for
the parent <code><a href="#the-table-element">table</a></code> element, if the <code><a href="#the-tbody-element">tbody</a></code>
element has a parent and it is a <code><a href="#the-table-element">table</a></code>.</p><div class="impl">
<p>The <code><a href="#the-tbody-element">tbody</a></code> element takes part in the <a href="#table-model">table
model</a>.</p>
</div><dl class="domintro"><dt><var title="">tbody</var> . <code title="dom-tbody-rows"><a href="#dom-tbody-rows">rows</a></code></dt>
<dd>
<p>Returns an <code><a href="common-dom-interfaces.html#htmlcollection">HTMLCollection</a></code> of the <code><a href="#the-tr-element">tr</a></code> elements of the table section.</p>
</dd>
<dt><var title="">tr</var> = <var title="">tbody</var> . <code title="dom-tbody-insertRow"><a href="#dom-tbody-insertrow">insertRow</a></code>( [ <var title="">index</var> ] )</dt>
<dd>
<p>Creates a <code><a href="#the-tr-element">tr</a></code> element, inserts it into the table section at the position given by the argument, and returns the <code><a href="#the-tr-element">tr</a></code>.</p>
<p>The position is relative to the rows in the table section. The index −1, which is the default if the argument is omitted, is equivalent to inserting at the end of the table section.</p>
<p>If the given position is less than −1 or greater than the number of rows, throws an <code><a href="common-dom-interfaces.html#index_size_err">INDEX_SIZE_ERR</a></code> exception.</p>
</dd>
<dt><var title="">tbody</var> . <code title="dom-tbody-deleteRow"><a href="#dom-tbody-deleterow">deleteRow</a></code>(<var title="">index</var>)</dt>
<dd>
<p>Removes the <code><a href="#the-tr-element">tr</a></code> element with the given position in the table section.</p>
<p>The position is relative to the rows in the table section. The index −1 is equivalent to deleting the last row of the table section.</p>
<p>If the given position is less than −1 or greater than the index of the last row, or if there are no rows, throws an <code><a href="common-dom-interfaces.html#index_size_err">INDEX_SIZE_ERR</a></code> exception.</p>
</dd>
</dl><div class="impl">
<p>The <dfn id="dom-tbody-rows" title="dom-tbody-rows"><code>rows</code></dfn> attribute
must return an <code><a href="common-dom-interfaces.html#htmlcollection">HTMLCollection</a></code> rooted at the element,
whose filter matches only <code><a href="#the-tr-element">tr</a></code> elements that are children
of the element.</p>
<p>The <dfn id="dom-tbody-insertrow" title="dom-tbody-insertRow"><code>insertRow(<var title="">index</var>)</code></dfn> method must, when invoked on an
element <var title="">table section</var>, act as follows:</p>
<p>If <var title="">index</var> is less than −1 or greater than the
number of elements in the <code title="dom-tbody-rows"><a href="#dom-tbody-rows">rows</a></code>
collection, the method must raise an <code><a href="common-dom-interfaces.html#index_size_err">INDEX_SIZE_ERR</a></code>
exception.</p>
<p>If <var title="">index</var> is missing, equal to −1, or
equal to the number of items in the <code title="dom-tbody-rows"><a href="#dom-tbody-rows">rows</a></code> collection, the method must
create a <code><a href="#the-tr-element">tr</a></code> element, append it to the element <var title="">table section</var>, and return the newly created
<code><a href="#the-tr-element">tr</a></code> element.</p>
<p>Otherwise, the method must create a <code><a href="#the-tr-element">tr</a></code> element,
insert it as a child of the <var title="">table section</var>
element, immediately before the <var title="">index</var>th
<code><a href="#the-tr-element">tr</a></code> element in the <code title="dom-tbody-rows"><a href="#dom-tbody-rows">rows</a></code> collection, and finally must
return the newly created <code><a href="#the-tr-element">tr</a></code> element.</p>
<p>The <dfn id="dom-tbody-deleterow" title="dom-tbody-deleteRow"><code>deleteRow(<var title="">index</var>)</code></dfn> method must remove the <var title="">index</var>th element in the <code title="dom-tbody-rows"><a href="#dom-tbody-rows">rows</a></code> collection from its parent. If
<var title="">index</var> is less than zero or greater than or equal
to the number of elements in the <code title="dom-tbody-rows"><a href="#dom-tbody-rows">rows</a></code> collection, the method must
instead raise an <code><a href="common-dom-interfaces.html#index_size_err">INDEX_SIZE_ERR</a></code> exception.</p>
</div><h4 id="the-thead-element"><span class="secno">4.9.6 </span>The <dfn><code>thead</code></dfn> element</h4><dl class="element"><dt>Categories</dt>
<dd>None.</dd>
<dt>Contexts in which this element can be used:</dt>
<dd>As a child of a <code><a href="#the-table-element">table</a></code> element, after any
<code><a href="#the-caption-element">caption</a></code>, and <code><a href="#the-colgroup-element">colgroup</a></code>
elements and before any <code><a href="#the-tbody-element">tbody</a></code>, <code><a href="#the-tfoot-element">tfoot</a></code>, and
<code><a href="#the-tr-element">tr</a></code> elements, but only if there are no other
<code><a href="#the-thead-element">thead</a></code> elements that are children of the
<code><a href="#the-table-element">table</a></code> element.</dd>
<dt>Content model:</dt>
<dd>Zero or more <code><a href="#the-tr-element">tr</a></code> elements</dd>
<dt>Content attributes:</dt>
<dd><a href="elements.html#global-attributes">Global attributes</a></dd>
<dt>DOM interface:</dt>
<dd><code><a href="#htmltablesectionelement">HTMLTableSectionElement</a></code>, as defined for
<code><a href="#the-tbody-element">tbody</a></code> elements.</dd>
</dl><p>The <code><a href="#the-thead-element">thead</a></code> element <a href="rendering.html#represents">represents</a> the <a href="#concept-row-group" title="concept-row-group">block</a> of <a href="#concept-row" title="concept-row">rows</a> that consist of the column labels
(headers) for the parent <code><a href="#the-table-element">table</a></code> element, if the
<code><a href="#the-thead-element">thead</a></code> element has a parent and it is a
<code><a href="#the-table-element">table</a></code>.</p><div class="impl">
<p>The <code><a href="#the-thead-element">thead</a></code> element takes part in the <a href="#table-model">table
model</a>.</p>
</div><div class="example">
<p>This example shows a <code><a href="#the-thead-element">thead</a></code> element being used.
Notice the use of both <code><a href="#the-th-element">th</a></code> and <code><a href="#the-td-element">td</a></code> elements
in the <code><a href="#the-thead-element">thead</a></code> element: the first row is the headers,
and the second row is an explanation of how to fill in the
table.</p>
<pre><table>
<caption> School auction sign-up sheet </caption>
<strong> <thead>
<tr>
<th><label for=e1>Name</label>
<th><label for=e2>Product</label>
<th><label for=e3>Picture</label>
<th><label for=e4>Price</label>
<tr>
<td>Your name here
<td>What are you selling?
<td>Link to a picture
<td>Your reserve price
</strong> <tbody>
<tr>
<td>Ms Danus
<td>Doughnuts
<td><img src="http://example.com/mydoughnuts.png" title="Doughnuts from Ms Danus">
<td>$45
<tr>
<td><input id=e1 type=text name=who required form=f>
<td><input id=e2 type=text name=what required form=f>
<td><input id=e3 type=url name=pic form=f>
<td><input id=e4 type=number step=0.01 min=0 value=0 required form=f>
</table>
<form id=f action="/auction.cgi">
<input type=button name=add value="Submit">
</form></pre>
</div><h4 id="the-tfoot-element"><span class="secno">4.9.7 </span>The <dfn><code>tfoot</code></dfn> element</h4><dl class="element"><dt>Categories</dt>
<dd>None.</dd>
<dt>Contexts in which this element can be used:</dt>
<dd>As a child of a <code><a href="#the-table-element">table</a></code> element, after any
<code><a href="#the-caption-element">caption</a></code>, <code><a href="#the-colgroup-element">colgroup</a></code>, and <code><a href="#the-thead-element">thead</a></code>
elements and before any <code><a href="#the-tbody-element">tbody</a></code> and <code><a href="#the-tr-element">tr</a></code>
elements, but only if there are no other <code><a href="#the-tfoot-element">tfoot</a></code>
elements that are children of the <code><a href="#the-table-element">table</a></code> element.</dd>
<dd>As a child of a <code><a href="#the-table-element">table</a></code> element, after any
<code><a href="#the-caption-element">caption</a></code>, <code><a href="#the-colgroup-element">colgroup</a></code>, <code><a href="#the-thead-element">thead</a></code>,
<code><a href="#the-tbody-element">tbody</a></code>, and <code><a href="#the-tr-element">tr</a></code> elements, but only if there
are no other <code><a href="#the-tfoot-element">tfoot</a></code> elements that are children of the
<code><a href="#the-table-element">table</a></code> element.</dd>
<dt>Content model:</dt>
<dd>Zero or more <code><a href="#the-tr-element">tr</a></code> elements</dd>
<dt>Content attributes:</dt>
<dd><a href="elements.html#global-attributes">Global attributes</a></dd>
<dt>DOM interface:</dt>
<dd><code><a href="#htmltablesectionelement">HTMLTableSectionElement</a></code>, as defined for
<code><a href="#the-tbody-element">tbody</a></code> elements.</dd>
</dl><p>The <code><a href="#the-tfoot-element">tfoot</a></code> element <a href="rendering.html#represents">represents</a> the <a href="#concept-row-group" title="concept-row-group">block</a> of <a href="#concept-row" title="concept-row">rows</a> that consist of the column summaries
(footers) for the parent <code><a href="#the-table-element">table</a></code> element, if the
<code><a href="#the-tfoot-element">tfoot</a></code> element has a parent and it is a
<code><a href="#the-table-element">table</a></code>.</p><div class="impl">
<p>The <code><a href="#the-tfoot-element">tfoot</a></code> element takes part in the <a href="#table-model">table
model</a>.</p>
</div><h4 id="the-tr-element"><span class="secno">4.9.8 </span>The <dfn><code>tr</code></dfn> element</h4><dl class="element"><dt>Categories</dt>
<dd>None.</dd>
<dt>Contexts in which this element can be used:</dt>
<dd>As a child of a <code><a href="#the-thead-element">thead</a></code> element.</dd>
<dd>As a child of a <code><a href="#the-tbody-element">tbody</a></code> element.</dd>
<dd>As a child of a <code><a href="#the-tfoot-element">tfoot</a></code> element.</dd>
<dd>As a child of a <code><a href="#the-table-element">table</a></code> element, after any
<code><a href="#the-caption-element">caption</a></code>, <code><a href="#the-colgroup-element">colgroup</a></code>, and <code><a href="#the-thead-element">thead</a></code>
elements, but only if there are no <code><a href="#the-tbody-element">tbody</a></code> elements that
are children of the <code><a href="#the-table-element">table</a></code> element.</dd>
<dt>Content model:</dt>
<dd>Zero or more <code><a href="#the-td-element">td</a></code> or <code><a href="#the-th-element">th</a></code> elements</dd>
<dt>Content attributes:</dt>
<dd><a href="elements.html#global-attributes">Global attributes</a></dd>
<dt>DOM interface:</dt>
<dd>
<pre class="idl">interface <dfn id="htmltablerowelement">HTMLTableRowElement</dfn> : <a href="elements.html#htmlelement">HTMLElement</a> {
readonly attribute long <a href="#dom-tr-rowindex" title="dom-tr-rowIndex">rowIndex</a>;
readonly attribute long <a href="#dom-tr-sectionrowindex" title="dom-tr-sectionRowIndex">sectionRowIndex</a>;
readonly attribute <a href="common-dom-interfaces.html#htmlcollection">HTMLCollection</a> <a href="#dom-tr-cells" title="dom-tr-cells">cells</a>;
<a href="elements.html#htmlelement">HTMLElement</a> <a href="#dom-tr-insertcell" title="dom-tr-insertCell">insertCell</a>(in optional long index);
void <a href="#dom-tr-deletecell" title="dom-tr-deleteCell">deleteCell</a>(in long index);
};</pre>
</dd>
</dl><p>The <code><a href="#the-tr-element">tr</a></code> element <a href="rendering.html#represents">represents</a> a <a href="#concept-row" title="concept-row">row</a> of <a href="#concept-cell" title="concept-cell">cells</a> in a <a href="#concept-table" title="concept-table">table</a>.</p><div class="impl">
<p>The <code><a href="#the-tr-element">tr</a></code> element takes part in the <a href="#table-model">table
model</a>.</p>
</div><dl class="domintro"><dt><var title="">tr</var> . <code title="dom-tr-rowIndex"><a href="#dom-tr-rowindex">rowIndex</a></code></dt>
<dd>
<p>Returns the position of the row in the table's <code title="dom-table-rows"><a href="#dom-table-rows">rows</a></code> list.</p>
<p>Returns −1 if the element isn't in a table.</p>
</dd>
<dt><var title="">tr</var> . <code title="dom-tr-sectionRowIndex"><a href="#dom-tr-sectionrowindex">sectionRowIndex</a></code></dt>
<dd>
<p>Returns the position of the row in the table section's <code title="dom-tbody-rows"><a href="#dom-tbody-rows">rows</a></code> list.</p>
<p>Returns −1 if the element isn't in a table section.</p>
</dd>
<dt><var title="">tr</var> . <code title="dom-tr-cells"><a href="#dom-tr-cells">cells</a></code></dt>
<dd>
<p>Returns an <code><a href="common-dom-interfaces.html#htmlcollection">HTMLCollection</a></code> of the <code><a href="#the-td-element">td</a></code> and <code><a href="#the-th-element">th</a></code> elements of the row.</p>
</dd>
<dt><var title="">cell</var> = <var title="">tr</var> . <code title="dom-tr-insertCell"><a href="#dom-tr-insertcell">insertCell</a></code>( [ <var title="">index</var> ] )</dt>
<dd>
<p>Creates a <code><a href="#the-td-element">td</a></code> element, inserts it into the table
row at the position given by the argument, and returns the
<code><a href="#the-td-element">td</a></code>.</p>
<p>The position is relative to the cells in the row. The
index −1, which is the default if the argument is omitted,
is equivalent to inserting at the end of the row.</p>
<p>If the given position is less than −1 or greater than
the number of cells, throws an <code><a href="common-dom-interfaces.html#index_size_err">INDEX_SIZE_ERR</a></code>
exception.</p>
</dd>
<dt><var title="">tr</var> . <code title="dom-tr-deleteCell"><a href="#dom-tr-deletecell">deleteCell</a></code>(<var title="">index</var>)</dt>
<dd>
<p>Removes the <code><a href="#the-td-element">td</a></code> or <code><a href="#the-th-element">th</a></code> element with the
given position in the row.</p>
<p>The position is relative to the cells in the row. The index
−1 is equivalent to deleting the last cell of the row.</p>
<p>If the given position is less than −1 or greater than
the index of the last cell, or if there are no cells, throws an
<code><a href="common-dom-interfaces.html#index_size_err">INDEX_SIZE_ERR</a></code> exception.</p>
</dd>
</dl><div class="impl">
<p>The <dfn id="dom-tr-rowindex" title="dom-tr-rowIndex"><code>rowIndex</code></dfn>
attribute must, if the element has a parent <code><a href="#the-table-element">table</a></code>
element, or a parent <code><a href="#the-tbody-element">tbody</a></code>, <code><a href="#the-thead-element">thead</a></code>, or
<code><a href="#the-tfoot-element">tfoot</a></code> element and a <em>grandparent</em>
<code><a href="#the-table-element">table</a></code> element, return the index of the <code><a href="#the-tr-element">tr</a></code>
element in that <code><a href="#the-table-element">table</a></code> element's <code title="dom-table-rows"><a href="#dom-table-rows">rows</a></code> collection. If there is no such
<code><a href="#the-table-element">table</a></code> element, then the attribute must return
−1.</p>
<p>The <dfn id="dom-tr-sectionrowindex" title="dom-tr-sectionRowIndex"><code>sectionRowIndex</code></dfn>
attribute must, if the element has a parent <code><a href="#the-table-element">table</a></code>,
<code><a href="#the-tbody-element">tbody</a></code>, <code><a href="#the-thead-element">thead</a></code>, or <code><a href="#the-tfoot-element">tfoot</a></code>
element, return the index of the <code><a href="#the-tr-element">tr</a></code> element in the
parent element's <code title="">rows</code> collection (for tables,
that's the <code title="dom-table-rows"><a href="#dom-table-rows">HTMLTableElement.rows</a></code>
collection; for table sections, that's the <code title="dom-tbody-rows"><a href="#dom-tbody-rows">HTMLTableRowElement.rows</a></code>
collection). If there is no such parent element, then the attribute
must return −1.</p>
<p>The <dfn id="dom-tr-cells" title="dom-tr-cells"><code>cells</code></dfn> attribute
must return an <code><a href="common-dom-interfaces.html#htmlcollection">HTMLCollection</a></code> rooted at the
<code><a href="#the-tr-element">tr</a></code> element, whose filter matches only <code><a href="#the-td-element">td</a></code>
and <code><a href="#the-th-element">th</a></code> elements that are children of the
<code><a href="#the-tr-element">tr</a></code> element.</p>
<p>The <dfn id="dom-tr-insertcell" title="dom-tr-insertCell"><code>insertCell(<var title="">index</var>)</code></dfn> method must act as follows:</p>
<p>If <var title="">index</var> is less than −1 or greater than the
number of elements in the <code title="dom-tr-cells"><a href="#dom-tr-cells">cells</a></code>
collection, the method must raise an <code><a href="common-dom-interfaces.html#index_size_err">INDEX_SIZE_ERR</a></code>
exception.</p>
<p>If <var title="">index</var> is missing, equal to −1, or
equal to the number of items in <code title="dom-tr-cells"><a href="#dom-tr-cells">cells</a></code> collection, the method must create
a <code><a href="#the-td-element">td</a></code> element, append it to the <code><a href="#the-tr-element">tr</a></code> element,
and return the newly created <code><a href="#the-td-element">td</a></code> element.</p>
<p>Otherwise, the method must create a <code><a href="#the-td-element">td</a></code> element,
insert it as a child of the <code><a href="#the-tr-element">tr</a></code> element, immediately
before the <var title="">index</var>th <code><a href="#the-td-element">td</a></code> or
<code><a href="#the-th-element">th</a></code> element in the <code title="dom-tr-cells"><a href="#dom-tr-cells">cells</a></code> collection, and finally must
return the newly created <code><a href="#the-td-element">td</a></code> element.</p>
<p>The <dfn id="dom-tr-deletecell" title="dom-tr-deleteCell"><code>deleteCell(<var title="">index</var>)</code></dfn> method must remove the <var title="">index</var>th element in the <code title="dom-tr-cells"><a href="#dom-tr-cells">cells</a></code> collection from its parent. If
<var title="">index</var> is less than zero or greater than or equal
to the number of elements in the <code title="dom-tr-cells"><a href="#dom-tr-cells">cells</a></code> collection, the method must
instead raise an <code><a href="common-dom-interfaces.html#index_size_err">INDEX_SIZE_ERR</a></code> exception.</p>
</div><h4 id="the-td-element"><span class="secno">4.9.9 </span>The <dfn><code>td</code></dfn> element</h4><dl class="element"><dt>Categories</dt>
<dd><a href="sections.html#sectioning-root">Sectioning root</a>.</dd>
<dt>Contexts in which this element can be used:</dt>
<dd>As a child of a <code><a href="#the-tr-element">tr</a></code> element.</dd>
<dt>Content model:</dt>
<dd><a href="content-models.html#flow-content">Flow content</a>.</dd>
<dt>Content attributes:</dt>
<dd><a href="elements.html#global-attributes">Global attributes</a></dd>
<dd><code title="attr-tdth-colspan"><a href="#attr-tdth-colspan">colspan</a></code></dd>
<dd><code title="attr-tdth-rowspan"><a href="#attr-tdth-rowspan">rowspan</a></code></dd>
<dd><code title="attr-tdth-headers"><a href="#attr-tdth-headers">headers</a></code></dd>
<dt>DOM interface:</dt>
<dd>
<pre class="idl">interface <dfn id="htmltabledatacellelement">HTMLTableDataCellElement</dfn> : <a href="#htmltablecellelement">HTMLTableCellElement</a> {};</pre>
</dd>
</dl><p>The <code><a href="#the-td-element">td</a></code> element <a href="rendering.html#represents">represents</a> a data <a href="#concept-cell" title="concept-cell">cell</a> in a table.</p><div class="impl">
<p>The <code><a href="#the-td-element">td</a></code> element and its <code title="attr-tdth-colspan"><a href="#attr-tdth-colspan">colspan</a></code>, <code title="attr-tdth-rowspan"><a href="#attr-tdth-rowspan">rowspan</a></code>, and <code title="attr-tdth-headers"><a href="#attr-tdth-headers">headers</a></code> attributes take part in the
<a href="#table-model">table model</a>.</p>
</div><h4 id="the-th-element"><span class="secno">4.9.10 </span>The <dfn><code>th</code></dfn> element</h4><dl class="element"><dt>Categories</dt>
<dd>None.</dd>
<dt>Contexts in which this element can be used:</dt>
<dd>As a child of a <code><a href="#the-tr-element">tr</a></code> element.</dd>
<dt>Content model:</dt>
<dd><a href="content-models.html#phrasing-content">Phrasing content</a>.</dd>
<dt>Content attributes:</dt>
<dd><a href="elements.html#global-attributes">Global attributes</a></dd>
<dd><code title="attr-tdth-colspan"><a href="#attr-tdth-colspan">colspan</a></code></dd>
<dd><code title="attr-tdth-rowspan"><a href="#attr-tdth-rowspan">rowspan</a></code></dd>
<dd><code title="attr-tdth-headers"><a href="#attr-tdth-headers">headers</a></code></dd>
<dd><code title="attr-th-scope"><a href="#attr-th-scope">scope</a></code></dd>
<dt>DOM interface:</dt>
<dd>
<pre class="idl">interface <dfn id="htmltableheadercellelement">HTMLTableHeaderCellElement</dfn> : <a href="#htmltablecellelement">HTMLTableCellElement</a> {
attribute DOMString <a href="#dom-th-scope" title="dom-th-scope">scope</a>;
};</pre>
</dd>
</dl><p>The <code><a href="#the-th-element">th</a></code> element <a href="rendering.html#represents">represents</a> a header <a href="#concept-cell" title="concept-cell">cell</a> in a table.</p><p>The <code><a href="#the-th-element">th</a></code> element may have a <dfn id="attr-th-scope" title="attr-th-scope"><code>scope</code></dfn> content attribute
specified. The <code title="attr-th-scope"><a href="#attr-th-scope">scope</a></code> attribute is
an <a href="common-microsyntaxes.html#enumerated-attribute">enumerated attribute</a> with five states, four of which
have explicit keywords:</p><dl><dt>The <dfn id="attr-th-scope-row" title="attr-th-scope-row"><code>row</code></dfn>
keyword, which maps to the <i>row</i> state</dt>
<dd>The <i>row</i> state means the header cell applies to some of
the subsequent cells in the same row(s).</dd>
<dt>The <dfn id="attr-th-scope-col" title="attr-th-scope-col"><code>col</code></dfn>
keyword, which maps to the <i>column</i> state</dt>
<dd>The <i>column</i> state means the header cell applies to some
of the subsequent cells in the same column(s).</dd>
<dt>The <dfn id="attr-th-scope-rowgroup" title="attr-th-scope-rowgroup"><code>rowgroup</code></dfn> keyword,
which maps to the <i>row group</i> state</dt>
<dd>The <i>row group</i> state means the header cell applies to all
the remaining cells in the row group. A <code><a href="#the-th-element">th</a></code> element's
<code title="attr-th-scope"><a href="#attr-th-scope">scope</a></code> attribute must not be in
the <a href="#attr-th-scope-rowgroup" title="attr-th-scope-rowgroup">row group</a> state if
the element is not anchored in a <a href="#concept-row-group" title="concept-row-group">row group</a>.</dd>
<dt>The <dfn id="attr-th-scope-colgroup" title="attr-th-scope-colgroup"><code>colgroup</code></dfn> keyword,
which maps to the <i>column group</i> state</dt>
<dd>The <i>column group</i> state means the header cell applies to
all the remaining cells in the column group. A <code><a href="#the-th-element">th</a></code>
element's <code title="attr-th-scope"><a href="#attr-th-scope">scope</a></code> attribute must
not be in the <a href="#attr-th-scope-colgroup" title="attr-th-scope-colgroup">column
group</a> state if the element is not anchored in a <a href="#concept-column-group" title="concept-column-group">column group</a>.</dd>
<dt>The <dfn id="attr-th-scope-auto" title="attr-th-scope-auto">auto</dfn> state</dt>
<dd>The <i>auto</i> state makes the header cell apply to a set of
cells selected based on context.</dd>
</dl><p>The <code title="attr-th-scope"><a href="#attr-th-scope">scope</a></code> attribute's
<i>missing value default</i> is the <i>auto</i> state.</p><div class="impl">
<p>The <code><a href="#the-th-element">th</a></code> element and its <code title="attr-tdth-colspan"><a href="#attr-tdth-colspan">colspan</a></code>, <code title="attr-tdth-rowspan"><a href="#attr-tdth-rowspan">rowspan</a></code>, <code title="attr-tdth-headers"><a href="#attr-tdth-headers">headers</a></code>, and <code title="attr-th-scope"><a href="#attr-th-scope">scope</a></code> attributes take part in the
<a href="#table-model">table model</a>.</p>
<p>The <dfn id="dom-th-scope" title="dom-th-scope"><code>scope</code></dfn> IDL
attribute must <a href="common-dom-interfaces.html#reflect">reflect</a> the content attribute of the
same name, <a href="common-dom-interfaces.html#limited-to-only-known-values">limited to only known values</a>.</p>
</div><div class="example">
<p>The following example shows how the <code title="attr-th-scope"><a href="#attr-th-scope">scope</a></code> attribute's <code title="attr-th-scope-rowgroup"><a href="#attr-th-scope-rowgroup">rowgroup</a></code> value affects which
data cells a header cell applies to.</p>
<p>Here is a markup fragment showing a table:</p>
<pre><table>
<thead>
<tr> <th> ID <th> Measurement <th> Average <th> Maximum
<tbody>
<tr> <td> <th scope=rowgroup> Cats <td> <td>
<tr> <td> 93 <th scope=row> Legs <td> 3.5 <td> 4
<tr> <td> 10 <th scope=row> Tails <td> 1 <td> 1
<tbody>
<tr> <td> <th scope=rowgroup> English speakers <td> <td>
<tr> <td> 32 <th scope=row> Legs <td> 2.67 <td> 4
<tr> <td> 35 <th scope=row> Tails <td> 0.33 <td> 1
</table></pre>
<p>This would result in the following table:</p>
<table><thead><tr><th> ID </th><th> Measurement </th><th> Average </th><th> Maximum
</th></tr></thead><tbody><tr><td> </td><th scope="rowgroup"> Cats </th><td> </td><td>
</td></tr><tr><td> 93 </td><th scope="row"> Legs </th><td> 3.5 </td><td> 4
</td></tr><tr><td> 10 </td><th scope="row"> Tails </th><td> 1 </td><td> 1
</td></tr></tbody><tbody><tr><td> </td><th scope="rowgroup"> English speakers </th><td> </td><td>
</td></tr><tr><td> 32 </td><th scope="row"> Legs </th><td> 2.67 </td><td> 4
</td></tr><tr><td> 35 </td><th scope="row"> Tails </th><td> 0.33 </td><td> 1
</td></tr></tbody></table><p>The headers in the first row all apply directly down to the rows
in their column.</p>
<p>The headers with the explicit <code title="attr-th-scope"><a href="#attr-th-scope">scope</a></code> attributes apply to all the
cells in their row group other than the cells in the first column.</p>
<p>The remaining headers apply just to the cells to the right of
them.</p>
<img alt="" height="256" src="table-scope-diagram.png" width="459"></div><h4 id="attributes-common-to-td-and-th-elements"><span class="secno">4.9.11 </span>Attributes common to <code><a href="#the-td-element">td</a></code> and <code><a href="#the-th-element">th</a></code> elements</h4><p>The <code><a href="#the-td-element">td</a></code> and <code><a href="#the-th-element">th</a></code> elements may have a <dfn id="attr-tdth-colspan" title="attr-tdth-colspan"><code>colspan</code></dfn> content
attribute specified, whose value must be a <a href="common-microsyntaxes.html#valid-non-negative-integer">valid non-negative
integer</a> greater than zero.</p><p>The <code><a href="#the-td-element">td</a></code> and <code><a href="#the-th-element">th</a></code> elements may also have a
<dfn id="attr-tdth-rowspan" title="attr-tdth-rowspan"><code>rowspan</code></dfn> content
attribute specified, whose value must be a <a href="common-microsyntaxes.html#valid-non-negative-integer">valid non-negative
integer</a>.</p><p>These attributes give the number of columns and rows respectively
that the cell is to span. These attributes must not be used to
overlap cells<span class="impl">, as described in the description of
the <a href="#table-model">table model</a></span>.</p><hr><p>The <code><a href="#the-td-element">td</a></code> and <code><a href="#the-th-element">th</a></code> element may have a <dfn id="attr-tdth-headers" title="attr-tdth-headers"><code>headers</code></dfn> content
attribute specified. The <code title="attr-tdth-headers"><a href="#attr-tdth-headers">headers</a></code> attribute, if specified,
must contain a string consisting of an <a href="common-microsyntaxes.html#unordered-set-of-unique-space-separated-tokens">unordered set of unique
space-separated tokens</a> that are <a href="infrastructure.html#case-sensitive">case-sensitive</a>,
each of which must have the value of an <a href="elements.html#concept-id" title="concept-id">ID</a> of a <code><a href="#the-th-element">th</a></code> element taking
part in the same <a href="#concept-table" title="concept-table">table</a> as the
<code><a href="#the-td-element">td</a></code> or <code><a href="#the-th-element">th</a></code> element<span class="impl"> (as
defined by the <a href="#table-model">table model</a>)</span>.</p><p>A <code><a href="#the-th-element">th</a></code> element with <a href="elements.html#concept-id" title="concept-id">ID</a> <var title="">id</var> is said
to be <i>directly targeted</i> by all <code><a href="#the-td-element">td</a></code> and
<code><a href="#the-th-element">th</a></code> elements in the same <a href="#concept-table" title="concept-table">table</a> that have <code title="attr-tdth-headers"><a href="#attr-tdth-headers">headers</a></code> attributes whose values
include as one of their tokens the <a href="elements.html#concept-id" title="concept-id">ID</a> <var title="">id</var>. A
<code><a href="#the-th-element">th</a></code> element <var title="">A</var> is said to be
<i>targeted</i> by a <code><a href="#the-th-element">th</a></code> or <code><a href="#the-td-element">td</a></code> element
<var title="">B</var> if either <var title="">A</var> is <i>directly
targeted</i> by <var title="">B</var> or if there exists an element
<var title="">C</var> that is itself <i>targeted</i> by the element
<var title="">B</var> and <var title="">A</var> is <i>directly
targeted</i> by <var title="">C</var>.</p><p>A <code><a href="#the-th-element">th</a></code> element must not be <i>targeted</i> by
itself.</p><div class="impl">
<p>The <code title="attr-tdth-colspan"><a href="#attr-tdth-colspan">colspan</a></code>, <code title="attr-tdth-rowspan"><a href="#attr-tdth-rowspan">rowspan</a></code>, and <code title="attr-tdth-headers"><a href="#attr-tdth-headers">headers</a></code> attributes take part in the
<a href="#table-model">table model</a>.</p>
</div><hr><p>The <code><a href="#the-td-element">td</a></code> and <code><a href="#the-th-element">th</a></code> elements implement
interfaces that inherit from the <code><a href="#htmltablecellelement">HTMLTableCellElement</a></code>
interface:</p><pre class="idl">interface <dfn id="htmltablecellelement">HTMLTableCellElement</dfn> : <a href="elements.html#htmlelement">HTMLElement</a> {
attribute unsigned long <a href="#dom-tdth-colspan" title="dom-tdth-colSpan">colSpan</a>;
attribute unsigned long <a href="#dom-tdth-rowspan" title="dom-tdth-rowSpan">rowSpan</a>;
[PutForwards=<a href="common-dom-interfaces.html#dom-domsettabletokenlist-value" title="dom-DOMSettableTokenList-value">value</a>] readonly attribute <a href="common-dom-interfaces.html#domsettabletokenlist">DOMSettableTokenList</a> <a href="#dom-tdth-headers" title="dom-tdth-headers">headers</a>;
readonly attribute long <a href="#dom-tdth-cellindex" title="dom-tdth-cellIndex">cellIndex</a>;
};</pre><dl class="domintro"><dt><var title="">cell</var> . <code title="dom-tdth-cellIndex"><a href="#dom-tdth-cellindex">cellIndex</a></code></dt>
<dd>
<p>Returns the position of the cell in the row's <code title="dom-tr-cells"><a href="#dom-tr-cells">cells</a></code> list. This does not necessarily
correspond to the <var title="">x</var>-position of the cell in
the table, since earlier cells might cover multiple rows or
columns.</p>
<p>Returns 0 if the element isn't in a row.</p>
</dd>
</dl><div class="impl">
<p>The <dfn id="dom-tdth-colspan" title="dom-tdth-colSpan"><code>colSpan</code></dfn> IDL
attribute must <a href="common-dom-interfaces.html#reflect">reflect</a> the content attribute of the
same name. The value must be <a href="common-dom-interfaces.html#limited-to-only-non-negative-numbers-greater-than-zero">limited to only non-negative
numbers greater than zero</a>.</p>
<p>The <dfn id="dom-tdth-rowspan" title="dom-tdth-rowSpan"><code>rowSpan</code></dfn> IDL
attribute must <a href="common-dom-interfaces.html#reflect">reflect</a> the content attribute of the
same name. Its default value, which must be used if <a href="common-microsyntaxes.html#rules-for-parsing-non-negative-integers" title="rules for parsing non-negative integers">parsing the
attribute as a non-negative integer</a> returns an error, is 1.</p>
<p>The <dfn id="dom-tdth-headers" title="dom-tdth-headers"><code>headers</code></dfn> IDL
attribute must <a href="common-dom-interfaces.html#reflect">reflect</a> the content attribute of the
same name.</p>
<p>The <dfn id="dom-tdth-cellindex" title="dom-tdth-cellIndex"><code>cellIndex</code></dfn>
IDL attribute must, if the element has a parent <code><a href="#the-tr-element">tr</a></code>
element, return the index of the cell's element in the parent
element's <code title="dom-tr-cells"><a href="#dom-tr-cells">cells</a></code> collection. If
there is no such parent element, then the attribute must return
0.</p>
</div><div class="impl">
<h4 id="processing-model-0"><span class="secno">4.9.12 </span>Processing model</h4>
<p>The various table elements and their content attributes together
define the <dfn id="table-model">table model</dfn>.</p>
<p>A <dfn id="concept-table" title="concept-table">table</dfn> consists of cells
aligned on a two-dimensional grid of <dfn id="concept-slots" title="concept-slots">slots</dfn> with coordinates (<var title="">x</var>, <var title="">y</var>). The grid is finite, and is
either empty or has one or more slots. If the grid has one or more
slots, then the <var title="">x</var> coordinates are always in the
range <span title="">0 ≤ <var title="">x</var> < <var title="">x<sub title="">width</sub></var></span>, and the <var title="">y</var>
coordinates are always in the range <span title="">0 ≤ <var title="">y</var> < <var title="">y<sub title="">height</sub></var></span>. If one or both of <var title="">x<sub title="">width</sub></var> and <var title="">y<sub title="">height</sub></var> are zero, then the table is empty (has
no slots). Tables correspond to <code><a href="#the-table-element">table</a></code> elements.</p>
<p>A <dfn id="concept-cell" title="concept-cell">cell</dfn> is a set of slots anchored
at a slot (<var title="">cell<sub title="">x</sub></var>, <var title="">cell<sub title="">y</sub></var>), and with a particular
<var title="">width</var> and <var title="">height</var> such that
the cell covers all the slots with coordinates (<var title="">x</var>, <var title="">y</var>) where <span title=""><var title="">cell<sub title="">x</sub></var> ≤ <var title="">x</var> < <var title="">cell<sub title="">x</sub></var>+<var title="">width</var></span> and
<span title=""><var title="">cell<sub title="">y</sub></var> ≤ <var title="">y</var> < <var title="">cell<sub title="">y</sub></var>+<var title="">height</var></span>. Cells can
either be <em>data cells</em> or <em>header cells</em>. Data cells
correspond to <code><a href="#the-td-element">td</a></code> elements, and header cells correspond
to <code><a href="#the-th-element">th</a></code> elements. Cells of both types can have zero or
more associated header cells.</p>
<p>It is possible, in certain error cases, for two cells to occupy
the same slot.</p>
<p>A <dfn id="concept-row" title="concept-row">row</dfn> is a complete set of slots
from <span title=""><var title="">x</var>=0</span> to <span title=""><var title="">x</var>=<var title="">x<sub title="">width</sub></var>-1</span>, for a particular value of <var title="">y</var>. Rows correspond to <code><a href="#the-tr-element">tr</a></code> elements.</p>
<p>A <dfn id="concept-column" title="concept-column">column</dfn> is a complete set of
slots from <span title=""><var title="">y</var>=0</span> to <span title=""><var title="">y</var>=<var title="">y<sub title="">height</sub></var>-1</span>, for a particular value of <var title="">x</var>. Columns can correspond to <code><a href="#the-col-element">col</a></code>
elements. In the absence of <code><a href="#the-col-element">col</a></code> elements, columns are
implied.</p>
<p>A <dfn id="concept-row-group" title="concept-row-group">row group</dfn> is a set of
<a href="#concept-row" title="concept-row">rows</a> anchored at a slot (0, <var title="">group<sub title="">y</sub></var>) with a particular <var title="">height</var> such that the row group covers all the slots
with coordinates (<var title="">x</var>, <var title="">y</var>)
where <span title="">0 ≤ <var title="">x</var> < <var title="">x<sub title="">width</sub></var></span> and <span title=""><var title="">group<sub title="">y</sub></var> ≤ <var title="">y</var> < <var title="">group<sub title="">y</sub></var>+<var title="">height</var></span>. Row groups
correspond to <code><a href="#the-tbody-element">tbody</a></code>, <code><a href="#the-thead-element">thead</a></code>, and
<code><a href="#the-tfoot-element">tfoot</a></code> elements. Not every row is necessarily in a row
group.</p>
<p>A <dfn id="concept-column-group" title="concept-column-group">column group</dfn> is a set
of <a href="#concept-column" title="concept-column">columns</a> anchored at a slot
(<var title="">group<sub title="">x</sub></var>, 0) with a
particular <var title="">width</var> such that the column group
covers all the slots with coordinates (<var title="">x</var>, <var title="">y</var>) where <span title=""><var title="">group<sub title="">x</sub></var> ≤ <var title="">x</var> < <var title="">group<sub title="">x</sub></var>+<var title="">width</var></span> and
<span title="">0 ≤ <var title="">y</var> < <var title="">y<sub title="">height</sub></var></span>. Column groups
correspond to <code><a href="#the-colgroup-element">colgroup</a></code> elements. Not every column is
necessarily in a column group.</p>
<p><a href="#concept-row-group" title="concept-row-group">Row groups</a> cannot overlap
each other. Similarly, <a href="#concept-column-group" title="concept-column-group">column
groups</a> cannot overlap each other.</p>
<p>A <a href="#concept-cell" title="concept-cell">cell</a> cannot cover slots that
are from two or more <a href="#concept-row-group" title="concept-row-group">row
groups</a>. It is, however, possible for a cell to be in multiple
<a href="#concept-column-group" title="concept-column-group">column groups</a>. All the
slots that form part of one cell are part of zero or one <a href="#concept-row-group" title="concept-row-group">row groups</a> and zero or more <a href="#concept-column-group" title="concept-column-group">column groups</a>.</p>
<p>In addition to <a href="#concept-cell" title="concept-cell">cells</a>, <a href="#concept-column" title="concept-column">columns</a>, <a href="#concept-row" title="concept-row">rows</a>, <a href="#concept-row-group" title="concept-row-group">row
groups</a>, and <a href="#concept-column-group" title="concept-column-group">column
groups</a>, <a href="#concept-table" title="concept-table">tables</a> can have a
<code><a href="#the-caption-element">caption</a></code> element associated with them. This gives the
table a heading, or legend.</p>
<p>A <dfn id="table-model-error">table model error</dfn> is an error with the data
represented by <code><a href="#the-table-element">table</a></code> elements and their
descendants. Documents must not have table model errors.</p>
<h5 id="forming-a-table"><span class="secno">4.9.12.1 </span>Forming a table</h5>
<p>To determine which elements correspond to which slots in a <a href="#concept-table" title="concept-table">table</a> associated with a
<code><a href="#the-table-element">table</a></code> element, to determine the dimensions of the table
(<var title="">x<sub title="">width</sub></var> and <var title="">y<sub title="">height</sub></var>), and to determine if
there are any <a href="#table-model-error" title="table model error">table model
errors</a>, user agents must use the following algorithm:</p>
<ol><li>
<p>Let <var title="">x<sub title="">width</sub></var> be zero.</p>
</li>
<li>
<p>Let <var title="">y<sub title="">height</sub></var> be zero.</p>
</li>
<li>
<p>Let <var title="">pending <code><a href="#the-tfoot-element">tfoot</a></code> elements</var> be
a list of <code><a href="#the-tfoot-element">tfoot</a></code> elements, initially empty.</p>
</li>
<li>
<p>Let <var title="">the table</var> be the <a href="#concept-table" title="concept-table">table</a> represented by the
<code><a href="#the-table-element">table</a></code> element. The <var title="">x<sub title="">width</sub></var> and <var title="">y<sub title="">height</sub></var> variables give <var title="">the
table</var>'s dimensions. <var title="">The table</var> is
initially empty.</p>
</li>
<li>
<p>If the <code><a href="#the-table-element">table</a></code> element has no children elements,
then return <var title="">the table</var> (which will be empty),
and abort these steps.</p>
</li>
<li>
<p>Associate the first <code><a href="#the-caption-element">caption</a></code> element child of the
<code><a href="#the-table-element">table</a></code> element with <var title="">the table</var>. If
there are no such children, then it has no associated
<code><a href="#the-caption-element">caption</a></code> element.</p>
</li>
<li>
<p>Let the <var title="">current element</var> be the first
element child of the <code><a href="#the-table-element">table</a></code> element.</p>
<p>If a step in this algorithm ever requires the <var title="">current element</var> to be <dfn id="concept-table-advance" title="concept-table-advance">advanced to the next child of the
<code>table</code></dfn> when there is no such next child, then
the user agent must jump to the step labeled <i>end</i>, near the
end of this algorithm.</p>
</li>
<li>
<p>While the <var title="">current element</var> is not one of the
following elements, <a href="#concept-table-advance" title="concept-table-advance">advance</a> the <var title="">current element</var> to the next child of the
<code><a href="#the-table-element">table</a></code>:</p>
<ul class="brief"><li><code><a href="#the-colgroup-element">colgroup</a></code></li>
<li><code><a href="#the-thead-element">thead</a></code></li>
<li><code><a href="#the-tbody-element">tbody</a></code></li>
<li><code><a href="#the-tfoot-element">tfoot</a></code></li>
<li><code><a href="#the-tr-element">tr</a></code></li>
</ul></li>
<li>
<p>If the <var title="">current element</var> is a
<code><a href="#the-colgroup-element">colgroup</a></code>, follow these substeps:</p>
<ol><li>
<p><i>Column groups</i>: Process the <var title="">current
element</var> according to the appropriate case below:</p>
<dl class="switch"><dt>If the <var title="">current element</var> has any
<code><a href="#the-col-element">col</a></code> element children</dt>
<dd>
<p>Follow these steps:</p>
<ol><li>
<p>Let <var title="">x<sub title="">start</sub></var> have
the value of <span title=""><var title="">x<sub title="">width</sub></var></span>.</p>
</li>
<li>
<p>Let the <var title="">current column</var> be the first
<code><a href="#the-col-element">col</a></code> element child of the <code><a href="#the-colgroup-element">colgroup</a></code>
element.</p>
</li>
<li>
<p><i>Columns</i>: If the <var title="">current column</var>
<code><a href="#the-col-element">col</a></code> element has a <code title="attr-col-span"><a href="#attr-col-span">span</a></code> attribute, then parse its
value using the <a href="common-microsyntaxes.html#rules-for-parsing-non-negative-integers">rules for parsing non-negative
integers</a>.</p>
<p>If the result of parsing the value is not an error or
zero, then let <var title="">span</var> be that value.</p>
<p>Otherwise, if the <code><a href="#the-col-element">col</a></code> element has no <code title="attr-col-span"><a href="#attr-col-span">span</a></code> attribute, or if trying to
parse the attribute's value resulted in an error or zero,
then let <var title="">span</var> be 1.</p>
</li>
<li>
<p>Increase <var title="">x<sub title="">width</sub></var> by
<var title="">span</var>.</p>
</li>
<li>
<p>Let the last <var title="">span</var> <a href="#concept-column" title="concept-column">columns</a> in <var title="">the
table</var> correspond to the <var title="">current
column</var> <code><a href="#the-col-element">col</a></code> element.</p>
</li>
<li>
<p>If <var title="">current column</var> is not the last
<code><a href="#the-col-element">col</a></code> element child of the <code><a href="#the-colgroup-element">colgroup</a></code>
element, then let the <var title="">current column</var> be
the next <code><a href="#the-col-element">col</a></code> element child of the
<code><a href="#the-colgroup-element">colgroup</a></code> element, and return to the step
labeled <i>columns</i>.</p>
</li>
<li>
<p>Let all the last <a href="#concept-column" title="concept-column">columns</a> in <var title="">the
table</var> from <span title="">x=<var title="">x<sub title="">start</sub></var></span> to <span title="">x=<var title="">x<sub title="">width</sub></var>-1</span> form a
new <a href="#concept-column-group" title="concept-column-group">column group</a>,
anchored at the slot (<var title="">x<sub title="">start</sub></var>, 0), with width <span title=""><var title="">x<sub title="">width</sub></var>-<var title="">x<sub title="">start</sub></var></span>,
corresponding to the <code><a href="#the-colgroup-element">colgroup</a></code> element.</p>
</li>
</ol></dd>
<dt>If the <var title="">current element</var> has no
<code><a href="#the-col-element">col</a></code> element children</dt>
<dd>
<ol><li>
<p>If the <code><a href="#the-colgroup-element">colgroup</a></code> element has a <code title="attr-colgroup-span"><a href="#attr-colgroup-span">span</a></code> attribute, then parse
its value using the <a href="common-microsyntaxes.html#rules-for-parsing-non-negative-integers">rules for parsing non-negative
integers</a>.</p>
<p>If the result of parsing the value is not an error or
zero, then let <var title="">span</var> be that value.</p>
<p>Otherwise, if the <code><a href="#the-colgroup-element">colgroup</a></code> element has no
<code title="attr-colgroup-span"><a href="#attr-colgroup-span">span</a></code> attribute, or
if trying to parse the attribute's value resulted in an
error or zero, then let <var title="">span</var> be 1.</p>
</li>
<li>
<p>Increase <var title="">x<sub title="">width</sub></var> by
<var title="">span</var>.</p>
</li>
<li>
<p>Let the last <var title="">span</var> <a href="#concept-column" title="concept-column">columns</a> in <var title="">the
table</var> form a new <a href="#concept-column-group" title="concept-column-group">column group</a>, anchored
at the slot (<span title=""><var title="">x<sub title="">width</sub></var>-<var title="">span</var></span>,
0), with width <var title="">span</var>, corresponding to
the <code><a href="#the-colgroup-element">colgroup</a></code> element.</p>
</li>
</ol></dd>
</dl></li>
<li>
<p><a href="#concept-table-advance" title="concept-table-advance">Advance</a> the <var title="">current element</var> to the next child of the
<code><a href="#the-table-element">table</a></code>.</p>
</li>
<li>
<p>While the <var title="">current element</var> is not one of
the following elements, <a href="#concept-table-advance" title="concept-table-advance">advance</a> the <var title="">current element</var> to the next child of the
<code><a href="#the-table-element">table</a></code>:</p>
<ul class="brief"><li><code><a href="#the-colgroup-element">colgroup</a></code></li>
<li><code><a href="#the-thead-element">thead</a></code></li>
<li><code><a href="#the-tbody-element">tbody</a></code></li>
<li><code><a href="#the-tfoot-element">tfoot</a></code></li>
<li><code><a href="#the-tr-element">tr</a></code></li>
</ul></li>
<li>
<p>If the <var title="">current element</var> is a
<code><a href="#the-colgroup-element">colgroup</a></code> element, jump to the step labeled
<i>column groups</i> above.</p>
</li>
</ol></li>
<li>
<p>Let <var title="">y<sub title="">current</sub></var> be
zero.</p>
</li>
<li>
<p>Let the <var title="">list of downward-growing cells</var> be
an empty list.</p>
</li>
<li>
<p><i>Rows</i>: While the <var title="">current element</var> is
not one of the following elements, <a href="#concept-table-advance" title="concept-table-advance">advance</a> the <var title="">current element</var> to the next child of the
<code><a href="#the-table-element">table</a></code>:</p>
<ul class="brief"><li><code><a href="#the-thead-element">thead</a></code></li>
<li><code><a href="#the-tbody-element">tbody</a></code></li>
<li><code><a href="#the-tfoot-element">tfoot</a></code></li>
<li><code><a href="#the-tr-element">tr</a></code></li>
</ul></li>
<li>
<p>If the <var title="">current element</var> is a
<code><a href="#the-tr-element">tr</a></code>, then run the <a href="#algorithm-for-processing-rows">algorithm for processing
rows</a>, <a href="#concept-table-advance" title="concept-table-advance">advance</a>
the <var title="">current element</var> to the next child of the
<code><a href="#the-table-element">table</a></code>, and return to the step labeled
<i>rows</i>.</p>
</li>
<li>
<p>Run the <a href="#algorithm-for-ending-a-row-group">algorithm for ending a row group</a>.</p>
</li>
<li>
<p>If the <var title="">current element</var> is a
<code><a href="#the-tfoot-element">tfoot</a></code>, then add that element to the list of <var title="">pending <code><a href="#the-tfoot-element">tfoot</a></code> elements</var>, <a href="#concept-table-advance" title="concept-table-advance">advance</a> the <var title="">current element</var> to the next child of the
<code><a href="#the-table-element">table</a></code>, and return to the step labeled
<i>rows</i>.</p>
</li>
<li>
<p>The <var title="">current element</var> is either a
<code><a href="#the-thead-element">thead</a></code> or a <code><a href="#the-tbody-element">tbody</a></code>.</p>
<p>Run the <a href="#algorithm-for-processing-row-groups">algorithm for processing row groups</a>.</p>
</li>
<li>
<p><a href="#concept-table-advance" title="concept-table-advance">Advance</a> the <var title="">current element</var> to the next child of the
<code><a href="#the-table-element">table</a></code>.</p>
</li>
<li>
<p>Return to the step labeled <i>rows</i>.</p>
</li>
<li>
<p><i>End</i>: For each <code><a href="#the-tfoot-element">tfoot</a></code> element in the list of
<var title="">pending <code><a href="#the-tfoot-element">tfoot</a></code> elements</var>, in tree
order, run the <a href="#algorithm-for-processing-row-groups">algorithm for processing row
groups</a>.</p>
</li>
<li>
<p>If there exists a <a href="#concept-row" title="concept-row">row</a> or <a href="#concept-column" title="concept-column">column</a> in <var title="">the
table</var> containing only <a href="#concept-slots" title="concept-slots">slots</a> that do not have a <a href="#concept-cell" title="concept-cell">cell</a> anchored to them, then this is a
<a href="#table-model-error">table model error</a>.</p>
</li>
<li>
<p>Return <var title="">the table</var>.</p>
</li>
</ol><p>The <dfn id="algorithm-for-processing-row-groups">algorithm for processing row groups</dfn>, which is
invoked by the set of steps above for processing
<code><a href="#the-thead-element">thead</a></code>, <code><a href="#the-tbody-element">tbody</a></code>, and <code><a href="#the-tfoot-element">tfoot</a></code>
elements, is:</p>
<ol><li>
<p>Let <var title="">y<sub title="">start</sub></var> have the
value of <var title="">y<sub title="">height</sub></var>.</p>
</li>
<li>
<p>For each <code><a href="#the-tr-element">tr</a></code> element that is a child of the element
being processed, in tree order, run the <a href="#algorithm-for-processing-rows">algorithm for
processing rows</a>.</p>
</li>
<li>
<p>If <span title=""><var title="">y<sub title="">height</sub></var> > <var title="">y<sub title="">start</sub></var></span>, then let all the last <a href="#concept-row" title="concept-row">rows</a> in <var title="">the table</var>
from <span title="">y=<var title="">y<sub title="">start</sub></var></span>
to <span title="">y=<var title="">y<sub title="">height</sub></var>-1</span> form a new <a href="#concept-row-group" title="concept-row-group">row group</a>, anchored at the slot
with coordinate (0, <var title="">y<sub title="">start</sub></var>), with height <span title=""><var title="">y<sub title="">height</sub></var>-<var title="">y<sub title="">start</sub></var></span>, corresponding to the element
being processed.</p>
</li>
<li>
<p>Run the <a href="#algorithm-for-ending-a-row-group">algorithm for ending a row group</a>.</p>
</li>
</ol><p>The <dfn id="algorithm-for-ending-a-row-group">algorithm for ending a row group</dfn>, which is invoked
by the set of steps above when starting and ending a block of rows,
is:</p>
<ol><li>
<p>While <var title="">y<sub title="">current</sub></var> is less
than <var title="">y<sub title="">height</sub></var>, follow these
steps:</p>
<ol><li>
<p>Run the <a href="#algorithm-for-growing-downward-growing-cells">algorithm for growing downward-growing
cells</a>.</p>
</li>
<li>
<p>Increase <var title="">y<sub title="">current</sub></var> by
1.</p>
</li>
</ol></li>
<li>
<p>Empty the <var title="">list of downward-growing
cells</var>.</p>
</li>
</ol><p>The <dfn id="algorithm-for-processing-rows">algorithm for processing rows</dfn>, which is invoked by
the set of steps above for processing <code><a href="#the-tr-element">tr</a></code> elements,
is:</p>
<ol><li>
<p>If <var title="">y<sub title="">height</sub></var> is equal to
<var title="">y<sub title="">current</sub></var>, then increase
<var title="">y<sub title="">height</sub></var> by 1. (<var title="">y<sub title="">current</sub></var> is never
<em>greater</em> than <var title="">y<sub title="">height</sub></var>.)</p>
</li>
<li>
<p>Let <var title="">x<sub title="">current</sub></var> be 0.</p>
</li>
<li>
<p>Run the <a href="#algorithm-for-growing-downward-growing-cells">algorithm for growing downward-growing
cells</a>.</p>
</li>
<li>
<p>If the <code><a href="#the-tr-element">tr</a></code> element being processed has no
<code><a href="#the-td-element">td</a></code> or <code><a href="#the-th-element">th</a></code> element children, then increase
<var title="">y<sub title="">current</sub></var> by 1, abort this
set of steps, and return to the algorithm above.</p>
</li>
<li>
<p>Let <var title="">current cell</var> be the first
<code><a href="#the-td-element">td</a></code> or <code><a href="#the-th-element">th</a></code> element in the <code><a href="#the-tr-element">tr</a></code>
element being processed.</p>
</li>
<li>
<p><i>Cells</i>: While <var title="">x<sub title="">current</sub></var> is less than <var title="">x<sub title="">width</sub></var> and the slot with coordinate (<var title="">x<sub title="">current</sub></var>, <var title="">y<sub title="">current</sub></var>) already has a cell assigned to it,
increase <var title="">x<sub title="">current</sub></var> by
1.</p>
</li>
<li>
<p>If <var title="">x<sub title="">current</sub></var> is equal to
<var title="">x<sub title="">width</sub></var>, increase <var title="">x<sub title="">width</sub></var> by 1. (<var title="">x<sub title="">current</sub></var> is never
<em>greater</em> than <var title="">x<sub title="">width</sub></var>.)</p>
</li>
<li>
<p>If the <var title="">current cell</var> has a <code title="attr-tdth-colspan"><a href="#attr-tdth-colspan">colspan</a></code> attribute, then <a href="common-microsyntaxes.html#rules-for-parsing-non-negative-integers" title="rules for parsing non-negative integers">parse that
attribute's value</a>, and let <var title="">colspan</var> be
the result.</p>
<p>If parsing that value failed, or returned zero, or if the
attribute is absent, then let <var title="">colspan</var> be 1,
instead.</p>
</li>
<li>
<p>If the <var title="">current cell</var> has a <code title="attr-tdth-rowspan"><a href="#attr-tdth-rowspan">rowspan</a></code> attribute, then <a href="common-microsyntaxes.html#rules-for-parsing-non-negative-integers" title="rules for
parsing non-negative integers">parse that attribute's
value</a>, and let <var title="">rowspan</var> be the
result.</p>
<p>If parsing that value failed or if the attribute is absent,
then let <var title="">rowspan</var> be 1, instead.</p>
</li>
<li>
<p>If <var title="">rowspan</var> is zero, then let <var title="">cell grows downward</var> be true, and set <var title="">rowspan</var> to 1. Otherwise, let <var title="">cell
grows downward</var> be false.</p>
</li>
<li>
<p>If <span title=""><var title="">x<sub title="">width</sub></var> < <var title="">x<sub title="">current</sub></var>+<var title="">colspan</var></span>,
then let <var title="">x<sub title="">width</sub></var> be
<span title=""><var title="">x<sub title="">current</sub></var>+<var title="">colspan</var></span>.</p>
</li>
<li>
<p>If <span title=""><var title="">y<sub title="">height</sub></var> < <var title="">y<sub title="">current</sub></var>+<var title="">rowspan</var></span>,
then let <var title="">y<sub title="">height</sub></var> be
<span title=""><var title="">y<sub title="">current</sub></var>+<var title="">rowspan</var></span>.</p>
</li>
<li>
<p>Let the slots with coordinates (<var title="">x</var>, <var title="">y</var>) such that <span title=""><var title="">x<sub title="">current</sub></var> ≤ <var title="">x</var> < <var title="">x<sub title="">current</sub></var>+<var title="">colspan</var></span>
and <span title=""><var title="">y<sub title="">current</sub></var> ≤ <var title="">y</var> < <var title="">y<sub title="">current</sub></var>+<var title="">rowspan</var></span> be
covered by a new <a href="#concept-cell" title="concept-cell">cell</a> <var title="">c</var>, anchored at (<var title="">x<sub title="">current</sub></var>, <var title="">y<sub title="">current</sub></var>), which has width <var title="">colspan</var> and height <var title="">rowspan</var>,
corresponding to the <var title="">current cell</var> element.</p>
<p>If the <var title="">current cell</var> element is a
<code><a href="#the-th-element">th</a></code> element, let this new cell <var title="">c</var>
be a header cell; otherwise, let it be a data cell.</p>
<p>To establish which header cells apply to the <var title="">current cell</var> element, use the <a href="#algorithm-for-assigning-header-cells">algorithm for
assigning header cells</a> described in the next section.</p>
<p>If any of the slots involved already had a <a href="#concept-cell" title="concept-cell">cell</a> covering them, then this is a
<a href="#table-model-error">table model error</a>. Those slots now have two cells
overlapping.</p>
</li>
<li>
<p>If <var title="">cell grows downward</var> is true, then add
the tuple {<var title="">c</var>, <var title="">x<sub title="">current</sub></var>, <var title="">colspan</var>} to the
<var title="">list of downward-growing cells</var>.</p>
</li>
<li>
<p>Increase <var title="">x<sub title="">current</sub></var> by
<var title="">colspan</var>.</p>
</li>
<li>
<p>If <var title="">current cell</var> is the last <code><a href="#the-td-element">td</a></code>
or <code><a href="#the-th-element">th</a></code> element in the <code><a href="#the-tr-element">tr</a></code> element being
processed, then increase <var title="">y<sub title="">current</sub></var> by 1, abort this set of steps, and
return to the algorithm above.</p>
</li>
<li>
<p>Let <var title="">current cell</var> be the next
<code><a href="#the-td-element">td</a></code> or <code><a href="#the-th-element">th</a></code> element in the <code><a href="#the-tr-element">tr</a></code>
element being processed.</p>
</li>
<li>
<p>Return to the step labelled <i>cells</i>.</p>
</li>
</ol><p>When the algorithms above require the user agent to run the
<dfn id="algorithm-for-growing-downward-growing-cells">algorithm for growing downward-growing cells</dfn>, the user
agent must, for each {<var title="">cell</var>, <var title="">cell<sub title="">x</sub></var>, <var title="">width</var>}
tuple in the <var title="">list of downward-growing cells</var>, if
any, extend the <a href="#concept-cell" title="concept-cell">cell</a> <var title="">cell</var> so that it also covers the slots with
coordinates (<var title="">x</var>, <var title="">y<sub title="">current</sub></var>), where <span title=""><var title="">cell<sub title="">x</sub></var> ≤ <var title="">x</var> < <var title="">cell<sub title="">x</sub></var>+<var title="">width</var></span>.</p>
<h5 id="header-and-data-cell-semantics"><span class="secno">4.9.12.2 </span>Forming relationships between data cells and header cells</h5>
<p>Each cell can be assigned zero or more header cells. The
<dfn id="algorithm-for-assigning-header-cells">algorithm for assigning header cells</dfn> to a cell <var title="">principal cell</var> is as follows.</p>
<ol><!-- INITIALIZATION --><li>
<p>Let <var title="">header list</var> be an empty list of
cells.</p>
</li>
<li>
<p>Let (<var title="">principal<sub title="">x</sub></var>, <var title="">principal<sub title="">y</sub></var>) be the coordinate
of the slot to which the <var title="">principal cell</var> is
anchored.</p>
</li>
<li>
<dl class="switch"><dt>If the <var title="">principal cell</var> has a <code title="attr-tdth-headers"><a href="#attr-tdth-headers">headers</a></code> attribute specified</dt>
<dd>
<!-- HEADERS="" -->
<ol><li>
<p>Take the value of the <var title="">principal cell</var>'s
<code title="attr-tdth-headers"><a href="#attr-tdth-headers">headers</a></code> attribute and
<a href="common-microsyntaxes.html#split-a-string-on-spaces" title="split a string on spaces">split it on
spaces</a>, letting <var title="">id list</var> be the list
of tokens obtained.</p>
</li>
<li>
<p>For each token in the <var title="">id list</var>, if the
first element in the <code><a href="infrastructure.html#document">Document</a></code> with an <a href="elements.html#concept-id" title="concept-id">ID</a> equal to
the token is a cell in the same <a href="#concept-table" title="concept-table">table</a>, and that cell is not the
<var title="">principal cell</var>, then add that cell to <var title="">header list</var>.</p>
</li>
</ol></dd>
<dt>If <var title="">principal cell</var> does not have a <code title="attr-tdth-headers"><a href="#attr-tdth-headers">headers</a></code> attribute specified</dt>
<dd>
<ol><li>
<p>Let <var title="">principal<sub title="">width</sub></var>
be the width of the <var title="">principal cell</var>.</p>
</li>
<li>
<p>Let <var title="">principal<sub title="">height</sub></var>
be the height of the <var title="">principal cell</var>.</p>
</li>
<!-- HORIZONTAL -->
<li>
<p>For each value of <var title="">y</var> from <var title="">principal<sub title="">y</sub></var> to <span title=""><var title="">principal<sub title="">y</sub></var>+<var title="">principal<sub title="">height</sub></var>-1</span>,
run the <a href="#internal-algorithm-for-scanning-and-assigning-header-cells">internal algorithm for scanning and assigning
header cells</a>, with the <var title="">principal
cell</var>, the <var title="">header list</var>, the initial
coordinate (<var title="">principal<sub title="">x</sub></var>,<var title="">y</var>), and the
increments <span title="">Δ<var title="">x</var>=−1</span>
and <span title="">Δ<var title="">y</var>=0</span>.</p>
</li>
<!-- VERTICAL -->
<li>
<p>For each value of <var title="">x</var> from <var title="">principal<sub title="">x</sub></var> to <span title=""><var title="">principal<sub title="">x</sub></var>+<var title="">principal<sub title="">width</sub></var>-1</span>,
run the <a href="#internal-algorithm-for-scanning-and-assigning-header-cells">internal algorithm for scanning and assigning
header cells</a>, with the <var title="">principal
cell</var>, the <var title="">header list</var>, the initial
coordinate (<var title="">x</var>,<var title="">principal<sub title="">y</sub></var>), and the increments <span title="">Δ<var title="">x</var>=0</span> and <span title="">Δ<var title="">y</var>=−1</span>.</p>
</li>
<!-- ROW GROUP HEADERS -->
<li>
<p>If the <var title="">principal cell</var> is anchored in a
<a href="#concept-row-group" title="concept-row-group">row group</a>, then add all
header cells that are <a href="#row-group-header" title="row group header">row group
headers</a> and are anchored in the same row group with an
<var title="">x</var>-coordinate less than or equal to
<span title=""><var title="">principal<sub title="">x</sub></var>+<var title="">principal<sub title="">width</sub></var>-1</span> and
a <var title="">y</var>-coordinate less than or equal to
<span title=""><var title="">principal<sub title="">y</sub></var>+<var title="">principal<sub title="">height</sub></var>-1</span> to
<var title="">header list</var>.</p>
</li>
<!-- COLUMN GROUP HEADERS -->
<li>
<p>If the <var title="">principal cell</var> is anchored in a
<a href="#concept-column-group" title="concept-column-group">column group</a>, then
add all header cells that are <a href="#column-group-header" title="column group
header">column group headers</a> and are anchored in the
same column group with an <var title="">x</var>-coordinate
less than or equal to <span title=""><var title="">principal<sub title="">x</sub></var>+<var title="">principal<sub title="">width</sub></var>-1</span> and a <var title="">y</var>-coordinate less than or equal to <span title=""><var title="">principal<sub title="">y</sub></var>+<var title="">principal<sub title="">height</sub></var>-1</span> to
<var title="">header list</var>.</p>
</li>
</ol></dd>
</dl></li>
<!-- CLEANUP -->
<li>
<p>Remove all the <a href="#empty-cell" title="empty cell">empty cells</a> from
the <var title="">header list</var>.</p>
</li>
<li>
<p>Remove any duplicates from the <var title="">header
list</var>.</p>
</li>
<li>
<p>Remove <var title="">principal cell</var> from the <var title="">header list</var> if it is there.</p>
</li>
<li>
<p>Assign the headers in the <var title="">header list</var> to
the <var title="">principal cell</var>.</p>
</li>
</ol><p>The <dfn id="internal-algorithm-for-scanning-and-assigning-header-cells">internal algorithm for scanning and assigning header
cells</dfn>, given a <var title="">principal cell</var>, a <var title="">header list</var>, an initial coordinate (<var title="">initial<sub title="">x</sub></var>, <var title="">initial<sub title="">y</sub></var>), and Δ<var title="">x</var> and Δ<var title="">y</var> increments, is as
follows:</p>
<ol><li>
<p>Let <var title="">x</var> equal <var title="">initial<sub title="">x</sub></var>.</p>
</li>
<li>
<p>Let <var title="">y</var> equal <var title="">initial<sub title="">y</sub></var>.</p>
</li>
<li>
<p>Let <var title="">opaque headers</var> be an empty list of
cells.</p>
</li>
<li>
<dl class="switch"><dt>If <var title="">principal cell</var> is a header cell</dt>
<dd><p>Let <var title="">in header block</var> be true, and let
<var title="">headers from current header block</var> be a list
of cells containing just the <var title="">principal
cell</var>.</p></dd>
<dt>Otherwise</dt>
<dd><p>Let <var title="">in header block</var> be false and let
<var title="">headers from current header block</var> be an
empty list of cells.</p>
</dd></dl></li>
<li>
<p><i>Loop</i>: Increment <var title="">x</var> by Δ<var title="">x</var>; increment <var title="">y</var> by Δ<var title="">y</var>.</p>
<p class="note">For each invocation of this algorithm, one of
Δ<var title="">x</var> and Δ<var title="">y</var> will
be −1, and the other will be 0.</p>
</li>
<li>
<p>If either <var title="">x</var> or <var title="">y</var> is
less than 0, then abort this internal algorithm.</p>
</li>
<li>
<p>If there is no cell covering slot (<var title="">x</var>,
<var title="">y</var>), or if there is more than one cell
covering slot (<var title="">x</var>, <var title="">y</var>),
return to the substep labeled <i>loop</i>.</p>
</li>
<li>
<p>Let <var title="">current cell</var> be the cell covering
slot (<var title="">x</var>, <var title="">y</var>).</p>
</li>
<li>
<dl class="switch"><dt>If <var title="">current cell</var> is a header cell</dt>
<dd>
<ol><li><p>Set <var title="">in header block</var> to
true.</p></li>
<li><p>Add <var title="">current cell</var> to <var title="">headers from current header block</var>.</p></li>
<li><p>Let <var title="">blocked</var> be false.</p></li>
<li>
<dl class="switch"><dt>If Δ<var title="">x</var> is 0</dt>
<dd>
<p>If there are any cells in the <var title="">opaque
headers</var> list anchored with the same <var title="">x</var>-coordinate as the <var title="">current
cell</var>, and with the same width as <var title="">current
cell</var>, then let <var title="">blocked</var> be
true.</p>
<p>If the <var title="">current cell</var> is not a
<a href="#column-header">column header</a>, then let <var title="">blocked</var> be true.</p>
</dd>
<dt>If Δ<var title="">y</var> is 0</dt>
<dd>
<p>If there are any cells in the <var title="">opaque
headers</var> list anchored with the same <var title="">y</var>-coordinate as the <var title="">current
cell</var>, and with the same height as <var title="">current cell</var>, then let <var title="">blocked</var> be true.</p>
<p>If the <var title="">current cell</var> is not a
<a href="#row-header">row header</a>, then let <var title="">blocked</var> be true.</p>
</dd>
</dl></li>
<li><p>If <var title="">blocked</var> is false, then add the
<var title="">current cell</var> to the <var title="">headers
list</var>.</p></li>
</ol></dd>
<dt>If <var title="">current cell</var> is a data cell and <var title="">in header block</var> is true</dt>
<dd><p>Set <var title="">in header block</var> to false. Add
all the cells in <var title="">headers from current header
block</var> to the <var title="">opaque headers</var> list, and
empty the <var title="">headers from current header block</var>
list.</p>
</dd></dl></li>
<li>
<p>Return to the step labeled <i>loop</i>.</p>
</li>
</ol><p>A header cell anchored at the slot with coordinate (<var title="">x</var>, <var title="">y</var>) with width <var title="">width</var> and height <var title="">height</var> is said
to be a <dfn id="column-header">column header</dfn> if any of the following conditions
are true:</p>
<ul><li>The cell's <code title="attr-th-scope"><a href="#attr-th-scope">scope</a></code> attribute
is in the <a href="#attr-th-scope-col" title="attr-th-scope-col">column</a> state, or</li>
<li>The cell's <code title="attr-th-scope"><a href="#attr-th-scope">scope</a></code> attribute
is in the <a href="#attr-th-scope-auto" title="attr-th-scope-auto">auto</a> state, and
there are no data cells in any of the cells covering slots with
<var title="">y</var>-coordinates <var title="">y</var>
.. <span title=""><var title="">y</var>+<var title="">height</var>-1</span>.</li>
</ul><p>A header cell anchored at the slot with coordinate (<var title="">x</var>, <var title="">y</var>) with width <var title="">width</var> and height <var title="">height</var> is said
to be a <dfn id="row-header">row header</dfn> if any of the following conditions
are true:</p>
<ul><li>The cell's <code title="attr-th-scope"><a href="#attr-th-scope">scope</a></code> attribute
is in the <a href="#attr-th-scope-row" title="attr-th-scope-row">row</a> state, or</li>
<li>The cell's <code title="attr-th-scope"><a href="#attr-th-scope">scope</a></code> attribute
is in the <a href="#attr-th-scope-auto" title="attr-th-scope-auto">auto</a> state, the
cell is not a <a href="#column-header">column header</a>, and there are no data
cells in any of the cells covering slots with <var title="">x</var>-coordinates <var title="">x</var> .. <span title=""><var title="">x</var>+<var title="">width</var>-1</span>.</li>
</ul><p>A header cell is said to be a <dfn id="column-group-header">column group header</dfn> if
its <code title="attr-th-scope"><a href="#attr-th-scope">scope</a></code> attribute is in the
<a href="#attr-th-scope-colgroup" title="attr-th-scope-colgroup">column group</a> state.</p>
<p>A header cell is said to be a <dfn id="row-group-header">row group header</dfn> if
its <code title="attr-th-scope"><a href="#attr-th-scope">scope</a></code> attribute is in the
<a href="#attr-th-scope-rowgroup" title="attr-th-scope-rowgroup">row group</a> state.</p>
<p>A cell is said to be an <dfn id="empty-cell">empty cell</dfn> if it contains no
elements and its text content, if any, consists only of
<a href="common-microsyntaxes.html#white_space">White_Space</a> characters.</p>
</div><h4 id="examples"><span class="secno">4.9.13 </span>Examples</h4><p><i>This section is non-normative.</i></p><p>The following shows how might one mark up the bottom part of
table 45 of the <cite>Smithsonian physical tables, Volume
71</cite>:</p><pre><table>
<caption>Specification values: <b>Steel</b>, <b>Castings</b>,
Ann. A.S.T.M. A27-16, Class B;* P max. 0.06; S max. 0.05.</caption>
<thead>
<tr>
<th rowspan=2>Grade.</th>
<th rowspan=2>Yield Point.</th>
<th colspan=2>Ultimate tensile strength</th>
<th rowspan=2>Per cent elong. 50.8mm or 2 in.</th>
<th rowspan=2>Per cent reduct. area.</th>
</tr>
<tr>
<th>kg/mm<sup>2</sup></th>
<th>lb/in<sup>2</sup></th>
</tr>
</thead>
<tbody>
<tr>
<td>Hard</td>
<td>0.45 ultimate</td>
<td>56.2</td>
<td>80,000</td>
<td>15</td>
<td>20</td>
</tr>
<tr>
<td>Medium</td>
<td>0.45 ultimate</td>
<td>49.2</td>
<td>70,000</td>
<td>18</td>
<td>25</td>
</tr>
<tr>
<td>Soft</td>
<td>0.45 ultimate</td>
<td>42.2</td>
<td>60,000</td>
<td>22</td>
<td>30</td>
</tr>
</tbody>
</table></pre><p>This table could look like this:</p><table id="table-example-1"><caption>Specification values: <b>Steel</b>, <b>Castings</b>,
Ann. A.S.T.M. A27-16, Class B;* P max. 0.06; S max. 0.05.</caption>
<thead><tr><th rowspan="2">Grade.</th>
<th rowspan="2">Yield Point.</th>
<th colspan="2">Ultimate tensile strength</th>
<th rowspan="2">Per cent elong. 50.8 mm or 2 in.</th>
<th rowspan="2">Per cent reduct. area.</th>
</tr><tr><th>kg/mm<sup>2</sup></th>
<th>lb/in<sup>2</sup></th>
</tr></thead><tbody><tr><td>Hard</td>
<td>0.45 ultimate</td>
<td>56.2</td>
<td>80,000</td>
<td>15</td>
<td>20</td>
</tr><tr><td>Medium</td>
<td>0.45 ultimate</td>
<td>49.2</td>
<td>70,000</td>
<td>18</td>
<td>25</td>
</tr><tr><td>Soft</td>
<td>0.45 ultimate</td>
<td>42.2</td>
<td>60,000</td>
<td>22</td>
<td>30</td>
</tr></tbody></table><hr><p>The following shows how one might mark up the gross margin table
on page 46 of Apple, Inc's 10-K filing for fiscal year 2008:</p><pre><table>
<thead>
<tr>
<th>
<th>2008
<th>2007
<th>2006
<tbody>
<tr>
<th>Net sales
<td>$ 32,479
<td>$ 24,006
<td>$ 19,315
<tr>
<th>Cost of sales
<td> 21,334
<td> 15,852
<td> 13,717
<tbody>
<tr>
<th>Gross margin
<td>$ 11,145
<td>$ 8,154
<td>$ 5,598
<tfoot>
<tr>
<th>Gross margin percentage
<td>34.3%
<td>34.0%
<td>29.0%
</table></pre><hr><p>The following shows how one might mark up the operating expenses
table from lower on the same page of that document:</p><pre><table>
<colgroup> <col>
<colgroup> <col> <col> <col>
<thead>
<tr> <th> <th>2008 <th>2007 <th>2006
<tbody>
<tr> <th scope=rowgroup> Research and development
<td> $ 1,109 <td> $ 782 <td> $ 712
<tr> <th scope=row> Percentage of net sales
<td> 3.4% <td> 3.3% <td> 3.7%
<tbody>
<tr> <th scope=rowgroup> Selling, general, and administrative
<td> $ 3,761 <td> $ 2,963 <td> $ 2,433
<tr> <th scope=row> Percentage of net sales
<td> 11.6% <td> 12.3% <td> 12.6%
</table></pre><p>This table could look like this:</p><table class="apple-table-examples e2"><thead><tr><th> </th><th>2008 </th><th>2007 </th><th>2006
</th></tr></thead><tbody><tr><th scope="rowgroup"> Research and development
</th><td> $ 1,109 </td><td> $ 782 </td><td> $ 712
</td></tr><tr><th scope="row"> Percentage of net sales
</th><td> 3.4% </td><td> 3.3% </td><td> 3.7%
</td></tr></tbody><tbody><tr><th scope="rowgroup"> Selling, general, and administrative
</th><td> $ 3,761 </td><td> $ 2,963 </td><td> $ 2,433
</td></tr><tr><th scope="row"> Percentage of net sales
</th><td> 11.6% </td><td> 12.3% </td><td> 12.6%
</td></tr></tbody></table></body></html>