the-end.html 92.5 KB
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 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
<!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>8.2.6 The end &#8212; 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="tree-construction.html" title="8.2.5 Tree construction" rel="prev">
  <link href="spec.html#contents" title="Table of contents" rel="index">
  <link href="named-character-references.html" title="8.5 Named character references" 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="&#9587;&#8413;"></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="tree-construction.html" class="prev">8.2.5 Tree construction</a> &#8211;
   <a href="spec.html#contents">Table of contents</a> &#8211;
   <a href="named-character-references.html" class="next">8.5 Named character references</a>
  <ol class="toc"><li><ol><li><ol><li><a href="the-end.html#the-end"><span class="secno">8.2.6 </span>The end</a></li><li><a href="the-end.html#coercing-an-html-dom-into-an-infoset"><span class="secno">8.2.7 </span>Coercing an HTML DOM into an infoset</a></li><li><a href="the-end.html#an-introduction-to-error-handling-and-strange-cases-in-the-parser"><span class="secno">8.2.8 </span>An introduction to error handling and strange cases in the parser</a>
      <ol><li><a href="the-end.html#misnested-tags:-b-i-b-i"><span class="secno">8.2.8.1 </span>Misnested tags: &lt;b&gt;&lt;i&gt;&lt;/b&gt;&lt;/i&gt;</a></li><li><a href="the-end.html#misnested-tags:-b-p-b-p"><span class="secno">8.2.8.2 </span>Misnested tags: &lt;b&gt;&lt;p&gt;&lt;/b&gt;&lt;/p&gt;</a></li><li><a href="the-end.html#unexpected-markup-in-tables"><span class="secno">8.2.8.3 </span>Unexpected markup in tables</a></li><li><a href="the-end.html#scripts-that-modify-the-page-as-it-is-being-parsed"><span class="secno">8.2.8.4 </span>Scripts that modify the page as it is being parsed</a></li><li><a href="the-end.html#the-execution-of-scripts-that-are-moving-across-multiple-documents"><span class="secno">8.2.8.5 </span>The execution of scripts that are moving across multiple documents</a></li><li><a href="the-end.html#unclosed-formatting-elements"><span class="secno">8.2.8.6 </span>Unclosed formatting elements</a></li></ol></li></ol></li><li><a href="the-end.html#serializing-html-fragments"><span class="secno">8.3 </span>Serializing HTML fragments</a></li><li><a href="the-end.html#parsing-html-fragments"><span class="secno">8.4 </span>Parsing HTML fragments</a></li></ol></li></ol></div>

  <div class="impl">

  <h4 id="the-end"><span class="secno">8.2.6 </span>The end</h4>

  <p>Once the user agent <dfn id="stop-parsing" title="stop parsing">stops parsing</dfn>
  the document, the user agent must run the following steps:</p>

  <ol><li><p>Set the <a href="dom.html#current-document-readiness">current document readiness</a> to
   "interactive"  and
   the <a href="parsing.html#insertion-point">insertion point</a> to undefined.</p></li>

   <li><p>Pop <em>all</em> the nodes off the <a href="parsing.html#stack-of-open-elements">stack of open
   elements</a>.</p></li>

   <li><p>If the <a href="scripting-1.html#list-of-scripts-that-will-execute-when-the-document-has-finished-parsing">list of scripts that will execute when the
   document has finished parsing</a> is not empty, run these
   substeps:</p>

    <ol><li><p><a href="webappapis.html#spin-the-event-loop">Spin the event loop</a> until the first
     <code><a href="scripting-1.html#the-script-element">script</a></code> in the <a href="scripting-1.html#list-of-scripts-that-will-execute-when-the-document-has-finished-parsing">list of scripts that will
     execute when the document has finished parsing</a> has its
     <a href="scripting-1.html#ready-to-be-parser-executed">"ready to be parser-executed"</a> flag set <em>and</em>
     the parser's <code><a href="infrastructure.html#document">Document</a></code> <a href="semantics.html#has-no-style-sheet-that-is-blocking-scripts">has no style sheet that
     is blocking scripts</a>.</p></li>

     <li><p><a href="scripting-1.html#execute-the-script-block" title="execute the script block">Execute</a> the
     first <code><a href="scripting-1.html#the-script-element">script</a></code> in the <a href="scripting-1.html#list-of-scripts-that-will-execute-when-the-document-has-finished-parsing">list of scripts that will
     execute when the document has finished parsing</a>.</p></li>

     <li><p>Remove the first <code><a href="scripting-1.html#the-script-element">script</a></code> element from the
     <a href="scripting-1.html#list-of-scripts-that-will-execute-when-the-document-has-finished-parsing">list of scripts that will execute when the document has
     finished parsing</a> (i.e. shift out the first entry in the
     list).</p></li>

     <li><p>If the <a href="scripting-1.html#list-of-scripts-that-will-execute-when-the-document-has-finished-parsing">list of scripts that will execute when the
     document has finished parsing</a> is still not empty, repeat
     these substeps again from substep 1.</p>

    </li></ol></li>

   <li><p><a href="webappapis.html#queue-a-task">Queue a task</a> to <a href="webappapis.html#fire-a-simple-event">fire a simple
   event</a> that bubbles named <code title="event-DOMContentLoaded">DOMContentLoaded</code> at the
   <code><a href="infrastructure.html#document">Document</a></code>.</p></li>

   <li><p><a href="webappapis.html#spin-the-event-loop">Spin the event loop</a> until the <a href="scripting-1.html#set-of-scripts-that-will-execute-as-soon-as-possible">set of
   scripts that will execute as soon as possible</a> and the
   <a href="scripting-1.html#list-of-scripts-that-will-execute-in-order-as-soon-as-possible">list of scripts that will execute in order as soon as
   possible</a> are empty.</p></li> 
   <li><p><a href="webappapis.html#spin-the-event-loop">Spin the event loop</a> until there is nothing that
   <dfn id="delay-the-load-event" title="delay the load event">delays the load event</dfn> in
   the <code><a href="infrastructure.html#document">Document</a></code>.</p></li>

   <li><p><a href="webappapis.html#queue-a-task">Queue a task</a> to set the <a href="dom.html#current-document-readiness">current document
   readiness</a> to "complete". </p></li>

   <li><p>If the <code><a href="infrastructure.html#document">Document</a></code> is in a <a href="browsers.html#browsing-context">browsing
   context</a>, then <a href="webappapis.html#queue-a-task">queue a task</a> to <a href="webappapis.html#fire-a-simple-event">fire a
   simple event</a> named <code title="event-load">load</code> at
   the <code><a href="infrastructure.html#document">Document</a></code>'s <code><a href="browsers.html#window">Window</a></code> object, but with
   its <code title="dom-event-target"><a href="infrastructure.html#dom-event-target">target</a></code> set to the
   <code><a href="infrastructure.html#document">Document</a></code> object (and the <code title="dom-event-currentTarget">currentTarget</code> set to the
   <code><a href="browsers.html#window">Window</a></code> object).</p></li>

   <li><p>If the <code><a href="infrastructure.html#document">Document</a></code> is in a <a href="browsers.html#browsing-context">browsing
   context</a>, then <a href="webappapis.html#queue-a-task">queue a task</a> to fire a <code title="event-pageshow"><a href="history.html#event-pageshow">pageshow</a></code> event at the
   <code><a href="browsers.html#window">Window</a></code> object of the <code><a href="infrastructure.html#document">Document</a></code>, but with
   its <code title="dom-event-target"><a href="infrastructure.html#dom-event-target">target</a></code> set to the
   <code><a href="infrastructure.html#document">Document</a></code> object (and the <code title="dom-event-currentTarget">currentTarget</code> set to the
   <code><a href="browsers.html#window">Window</a></code> object), using the
   <code><a href="history.html#pagetransitionevent">PageTransitionEvent</a></code> interface, with the <code title="dom-PageTransitionEvent-persisted"><a href="history.html#dom-pagetransitionevent-persisted">persisted</a></code>
   attribute set to false. This event must not bubble, must not be
   cancelable, and has no default action.</p></li>

   <li><p>If the <code><a href="infrastructure.html#document">Document</a></code> has any <a href="offline.html#pending-application-cache-download-process-tasks">pending
   application cache download process tasks</a>, then <a href="webappapis.html#queue-a-task" title="queue a task">queue</a> each such <a href="webappapis.html#concept-task" title="concept-task">task</a> in the order they were added to
   the list of <a href="offline.html#pending-application-cache-download-process-tasks">pending application cache download process
   tasks</a>, and then empty the list of <a href="offline.html#pending-application-cache-download-process-tasks">pending application
   cache download process tasks</a>. The <a href="webappapis.html#task-source">task source</a>
   for these <a href="webappapis.html#concept-task" title="concept-task">tasks</a> is the
   <a href="webappapis.html#networking-task-source">networking task source</a>.</p></li>

   <li><p>The <code><a href="infrastructure.html#document">Document</a></code> is now <dfn id="ready-for-post-load-tasks">ready for post-load
   tasks</dfn>.</p></li>

   <li><p><a href="webappapis.html#queue-a-task">Queue a task</a> to mark the <code><a href="infrastructure.html#document">Document</a></code>
   as <dfn id="completely-loaded">completely loaded</dfn>.</p></li>

  </ol><p>When the user agent is to <dfn id="abort-a-parser">abort a parser</dfn>, it must run
  the following steps:</p>

  <ol><li><p>Throw away any pending content in the <a href="parsing.html#the-input-stream">input
   stream</a>, and discard any future content that would have been
   added to it.</p></li>

   <li><p>Pop <em>all</em> the nodes off the <a href="parsing.html#stack-of-open-elements">stack of open
   elements</a>.</p></li>

   
  </ol><p>Except where otherwise specified, the <a href="webappapis.html#task-source">task source</a>
  for the <a href="webappapis.html#concept-task" title="concept-task">tasks</a> mentioned in this
  section is the <a href="webappapis.html#dom-manipulation-task-source">DOM manipulation task source</a>.</p>

  </div><div class="impl">

  <h4 id="coercing-an-html-dom-into-an-infoset"><span class="secno">8.2.7 </span>Coercing an HTML DOM into an infoset</h4>

  <p>When an application uses an <a href="parsing.html#html-parser">HTML parser</a> in
  conjunction with an XML pipeline, it is possible that the
  constructed DOM is not compatible with the XML tool chain in certain
  subtle ways. For example, an XML toolchain might not be able to
  represent attributes with the name <code title="">xmlns</code>,
  since they conflict with the Namespaces in XML syntax. There is also
  some data that the <a href="parsing.html#html-parser">HTML parser</a> generates that isn't
  included in the DOM itself. This section specifies some rules for
  handling these issues.</p>

  <p>If the XML API being used doesn't support DOCTYPEs, the tool may
  drop DOCTYPEs altogether.</p>

  <p>If the XML API doesn't support attributes in no namespace that
  are named "<code title="">xmlns</code>", attributes whose names
  start with "<code title="">xmlns:</code>", or attributes in the
  <a href="namespaces.html#xmlns-namespace">XMLNS namespace</a>, then the tool may drop such
  attributes.</p>

  <p>The tool may annotate the output with any namespace declarations
  required for proper operation.</p>

  <p>If the XML API being used restricts the allowable characters in
  the local names of elements and attributes, then the tool may map
  all element and attribute local names that the API wouldn't support
  to a set of names that <em>are</em> allowed, by replacing any
  character that isn't supported with the uppercase letter U and the
  six digits of the character's Unicode code point when expressed in
  hexadecimal, using digits 0-9 and capital letters A-F as the
  symbols, in increasing numeric order.</p>

  <p class="example">For example, the element name <code title="">foo&lt;bar</code>, which can be output by the <a href="parsing.html#html-parser">HTML
  parser</a>, though it is neither a legal HTML element name nor a
  well-formed XML element name, would be converted into <code title="">fooU00003Cbar</code>, which <em>is</em> a well-formed XML
  element name (though it's still not legal in HTML by any means).</p>

  <p class="example">As another example, consider the attribute
  <code>xlink:href</code>. Used on a MathML element, it becomes, after
  being <a href="tree-construction.html#adjust-foreign-attributes" title="adjust foreign attributes">adjusted</a>, an
  attribute with a prefix "<code title="">xlink</code>" and a local
  name "<code title="">href</code>". However, used on an HTML element,
  it becomes an attribute with no prefix and the local name "<code title="">xlink:href</code>", which is not a valid NCName, and thus
  might not be accepted by an XML API. It could thus get converted,
  becoming "<code title="">xlinkU00003Ahref</code>".</p>

  <p class="note">The resulting names from this conversion
  conveniently can't clash with any attribute generated by the
  <a href="parsing.html#html-parser">HTML parser</a>, since those are all either lowercase or
  those listed in the <a href="tree-construction.html#adjust-foreign-attributes">adjust foreign attributes</a>
  algorithm's table.</p>

  <p>If the XML API restricts comments from having two consecutive
  U+002D HYPHEN-MINUS characters (--), the tool may insert a single
  U+0020 SPACE character between any such offending characters.</p>

  <p>If the XML API restricts comments from ending in a
  U+002D HYPHEN-MINUS character (-), the tool may insert a single
  U+0020 SPACE character at the end of such comments.</p>

  <p>If the XML API restricts allowed characters in character data,
  attribute values, or comments, the tool may replace any U+000C FORM
  FEED (FF) character with a U+0020 SPACE character, and any other
  literal non-XML character with a U+FFFD REPLACEMENT CHARACTER.</p>

  <p>If the tool has no way to convey out-of-band information, then
  the tool may drop the following information:</p>

  <ul><li>Whether the document is set to <i><a href="dom.html#no-quirks-mode">no-quirks mode</a></i>,
   <i><a href="dom.html#limited-quirks-mode">limited-quirks mode</a></i>, or <i><a href="dom.html#quirks-mode">quirks mode</a></i></li>

   <li>The association between form controls and forms that aren't
   their nearest <code><a href="forms.html#the-form-element">form</a></code> element ancestor (use of the
   <a href="parsing.html#form-element-pointer"><code>form</code> element pointer</a> in the parser)</li>

  </ul><p class="note">The mutations allowed by this section apply
  <em>after</em> the <a href="parsing.html#html-parser">HTML parser</a>'s rules have been
  applied. For example, a <code title="">&lt;a::&gt;</code> start tag
  will be closed by a <code title="">&lt;/a::&gt;</code> end tag, and
  never by a <code title="">&lt;/aU00003AU00003A&gt;</code> end tag, even
  if the user agent is using the rules above to then generate an
  actual element in the DOM with the name <code title="">aU00003AU00003A</code> for that start tag.</p>

  </div><div class="impl">

  <h4 id="an-introduction-to-error-handling-and-strange-cases-in-the-parser"><span class="secno">8.2.8 </span>An introduction to error handling and strange cases in the parser</h4>

  <p><i>This section is non-normative.</i></p>

  <p>This section examines some erroneous markup and discusses how
  the <a href="parsing.html#html-parser">HTML parser</a> handles these cases.</p>


  <h5 id="misnested-tags:-b-i-b-i"><span class="secno">8.2.8.1 </span>Misnested tags: &lt;b&gt;&lt;i&gt;&lt;/b&gt;&lt;/i&gt;</h5>

  <p><i>This section is non-normative.</i></p>

  <p>The most-often discussed example of erroneous markup is as
  follows:</p>

  <pre>&lt;p&gt;1&lt;b&gt;2&lt;i&gt;3&lt;/b&gt;4&lt;/i&gt;5&lt;/p&gt;</pre>

  <p>The parsing of this markup is straightforward up to the "3". At
  this point, the DOM looks like this:</p>

  <ul class="domTree"><li class="t1"><code><a href="semantics.html#the-html-element">html</a></code><ul><li class="t1"><code><a href="semantics.html#the-head-element">head</a></code></li><li class="t1"><code><a href="sections.html#the-body-element">body</a></code><ul><li class="t1"><code><a href="grouping-content.html#the-p-element">p</a></code><ul><li class="t3"><code>#text</code>: <span title="">1</span></li><li class="t1"><code><a href="text-level-semantics.html#the-b-element">b</a></code><ul><li class="t3"><code>#text</code>: <span title="">2</span></li><li class="t1"><code><a href="text-level-semantics.html#the-i-element">i</a></code><ul><li class="t3"><code>#text</code>: <span title="">3</span></li></ul></li></ul></li></ul></li></ul></li></ul></li></ul><p>Here, the <a href="parsing.html#stack-of-open-elements">stack of open elements</a> has five elements
  on it: <code><a href="semantics.html#the-html-element">html</a></code>, <code><a href="sections.html#the-body-element">body</a></code>, <code><a href="grouping-content.html#the-p-element">p</a></code>,
  <code><a href="text-level-semantics.html#the-b-element">b</a></code>, and <code><a href="text-level-semantics.html#the-i-element">i</a></code>. The <a href="parsing.html#list-of-active-formatting-elements">list of active
  formatting elements</a> just has two: <code><a href="text-level-semantics.html#the-b-element">b</a></code> and
  <code><a href="text-level-semantics.html#the-i-element">i</a></code>. The <a href="parsing.html#insertion-mode">insertion mode</a> is "<a href="tree-construction.html#parsing-main-inbody" title="insertion mode: in body">in body</a>".</p>

  <p>Upon receiving the end tag token with the tag name "b", the "<a href="tree-construction.html#adoptionAgency">adoption agency algorithm</a>" is
  invoked. This is a simple case, in that the <var title="">formatting
  element</var> is the <code><a href="text-level-semantics.html#the-b-element">b</a></code> element, and there is no
  <var title="">furthest block</var>. Thus, the <a href="parsing.html#stack-of-open-elements">stack of open
  elements</a> ends up with just three elements: <code><a href="semantics.html#the-html-element">html</a></code>,
  <code><a href="sections.html#the-body-element">body</a></code>, and <code><a href="grouping-content.html#the-p-element">p</a></code>, while the <a href="parsing.html#list-of-active-formatting-elements">list of
  active formatting elements</a> has just one: <code><a href="text-level-semantics.html#the-i-element">i</a></code>. The
  DOM tree is unmodified at this point.</p>

  <p>The next token is a character ("4"), triggers the <a href="parsing.html#reconstruct-the-active-formatting-elements" title="reconstruct the active formatting elements">reconstruction of
  the active formatting elements</a>, in this case just the
  <code><a href="text-level-semantics.html#the-i-element">i</a></code> element. A new <code><a href="text-level-semantics.html#the-i-element">i</a></code> element is thus created
  for the "4" text node. After the end tag token for the "i" is also
  received, and the "5" text node is inserted, the DOM looks as
  follows:</p>

  <ul class="domTree"><li class="t1"><code><a href="semantics.html#the-html-element">html</a></code><ul><li class="t1"><code><a href="semantics.html#the-head-element">head</a></code></li><li class="t1"><code><a href="sections.html#the-body-element">body</a></code><ul><li class="t1"><code><a href="grouping-content.html#the-p-element">p</a></code><ul><li class="t3"><code>#text</code>: <span title="">1</span></li><li class="t1"><code><a href="text-level-semantics.html#the-b-element">b</a></code><ul><li class="t3"><code>#text</code>: <span title="">2</span></li><li class="t1"><code><a href="text-level-semantics.html#the-i-element">i</a></code><ul><li class="t3"><code>#text</code>: <span title="">3</span></li></ul></li></ul></li><li class="t1"><code><a href="text-level-semantics.html#the-i-element">i</a></code><ul><li class="t3"><code>#text</code>: <span title="">4</span></li></ul></li><li class="t3"><code>#text</code>: <span title="">5</span></li></ul></li></ul></li></ul></li></ul><h5 id="misnested-tags:-b-p-b-p"><span class="secno">8.2.8.2 </span>Misnested tags: &lt;b&gt;&lt;p&gt;&lt;/b&gt;&lt;/p&gt;</h5>

  <p><i>This section is non-normative.</i></p>

  <p>A case similar to the previous one is the following:</p>

  <pre>&lt;b&gt;1&lt;p&gt;2&lt;/b&gt;3&lt;/p&gt;</pre>

  <p>Up to the "2" the parsing here is straightforward:</p>

  <ul class="domTree"><li class="t1"><code><a href="semantics.html#the-html-element">html</a></code><ul><li class="t1"><code><a href="semantics.html#the-head-element">head</a></code></li><li class="t1"><code><a href="sections.html#the-body-element">body</a></code><ul><li class="t1"><code><a href="text-level-semantics.html#the-b-element">b</a></code><ul><li class="t3"><code>#text</code>: <span title="">1</span></li><li class="t1"><code><a href="grouping-content.html#the-p-element">p</a></code><ul><li class="t3"><code>#text</code>: <span title="">2</span></li></ul></li></ul></li></ul></li></ul></li></ul><p>The interesting part is when the end tag token with the tag name
  "b" is parsed.</p>

  <p>Before that token is seen, the <a href="parsing.html#stack-of-open-elements">stack of open
  elements</a> has four elements on it: <code><a href="semantics.html#the-html-element">html</a></code>,
  <code><a href="sections.html#the-body-element">body</a></code>, <code><a href="text-level-semantics.html#the-b-element">b</a></code>, and <code><a href="grouping-content.html#the-p-element">p</a></code>. The
  <a href="parsing.html#list-of-active-formatting-elements">list of active formatting elements</a> just has the one:
  <code><a href="text-level-semantics.html#the-b-element">b</a></code>. The <a href="parsing.html#insertion-mode">insertion mode</a> is "<a href="tree-construction.html#parsing-main-inbody" title="insertion mode: in body">in body</a>".</p>

  <p>Upon receiving the end tag token with the tag name "b", the "<a href="tree-construction.html#adoptionAgency">adoption agency algorithm</a>" is invoked, as
  in the previous example. However, in this case, there <em>is</em> a
  <var title="">furthest block</var>, namely the <code><a href="grouping-content.html#the-p-element">p</a></code> element. Thus,
  this time the adoption agency algorithm isn't skipped over.</p>

  <p>The <var title="">common ancestor</var> is the <code><a href="sections.html#the-body-element">body</a></code>
  element. A conceptual "bookmark" marks the position of the
  <code><a href="text-level-semantics.html#the-b-element">b</a></code> in the <a href="parsing.html#list-of-active-formatting-elements">list of active formatting
  elements</a>, but since that list has only one element in it,
  the bookmark won't have much effect.</p>

  <p>As the algorithm progresses, <var title="">node</var> ends up set
  to the formatting element (<code><a href="text-level-semantics.html#the-b-element">b</a></code>), and <var title="">last
  node</var> ends up set to the <var title="">furthest block</var>
  (<code><a href="grouping-content.html#the-p-element">p</a></code>).</p>

  <p>The <var title="">last node</var> gets appended (moved) to the
  <var title="">common ancestor</var>, so that the DOM looks like:</p>

  <ul class="domTree"><li class="t1"><code><a href="semantics.html#the-html-element">html</a></code><ul><li class="t1"><code><a href="semantics.html#the-head-element">head</a></code></li><li class="t1"><code><a href="sections.html#the-body-element">body</a></code><ul><li class="t1"><code><a href="text-level-semantics.html#the-b-element">b</a></code><ul><li class="t3"><code>#text</code>: <span title="">1</span></li></ul></li><li class="t1"><code><a href="grouping-content.html#the-p-element">p</a></code><ul><li class="t3"><code>#text</code>: <span title="">2</span></li></ul></li></ul></li></ul></li></ul><p>A new <code><a href="text-level-semantics.html#the-b-element">b</a></code> element is created, and the children of the
  <code><a href="grouping-content.html#the-p-element">p</a></code> element are moved to it:</p>

  <ul class="domTree"><li class="t1"><code><a href="semantics.html#the-html-element">html</a></code><ul><li class="t1"><code><a href="semantics.html#the-head-element">head</a></code></li><li class="t1"><code><a href="sections.html#the-body-element">body</a></code><ul><li class="t1"><code><a href="text-level-semantics.html#the-b-element">b</a></code><ul><li class="t3"><code>#text</code>: <span title="">1</span></li></ul></li><li class="t1"><code><a href="grouping-content.html#the-p-element">p</a></code></li></ul></li></ul></li></ul><ul class="domTree"><li class="t1"><code><a href="text-level-semantics.html#the-b-element">b</a></code><ul><li class="t3"><code>#text</code>: <span title="">2</span></li></ul></li></ul><p>Finally, the new <code><a href="text-level-semantics.html#the-b-element">b</a></code> element is appended to the
  <code><a href="grouping-content.html#the-p-element">p</a></code> element, so that the DOM looks like:</p>

  <ul class="domTree"><li class="t1"><code><a href="semantics.html#the-html-element">html</a></code><ul><li class="t1"><code><a href="semantics.html#the-head-element">head</a></code></li><li class="t1"><code><a href="sections.html#the-body-element">body</a></code><ul><li class="t1"><code><a href="text-level-semantics.html#the-b-element">b</a></code><ul><li class="t3"><code>#text</code>: <span title="">1</span></li></ul></li><li class="t1"><code><a href="grouping-content.html#the-p-element">p</a></code><ul><li class="t1"><code><a href="text-level-semantics.html#the-b-element">b</a></code><ul><li class="t3"><code>#text</code>: <span title="">2</span></li></ul></li></ul></li></ul></li></ul></li></ul><p>The <code><a href="text-level-semantics.html#the-b-element">b</a></code> element is removed from the <a href="parsing.html#list-of-active-formatting-elements">list of
  active formatting elements</a> and the <a href="parsing.html#stack-of-open-elements">stack of open
  elements</a>, so that when the "3" is parsed, it is appended to
  the <code><a href="grouping-content.html#the-p-element">p</a></code> element:</p>

  <ul class="domTree"><li class="t1"><code><a href="semantics.html#the-html-element">html</a></code><ul><li class="t1"><code><a href="semantics.html#the-head-element">head</a></code></li><li class="t1"><code><a href="sections.html#the-body-element">body</a></code><ul><li class="t1"><code><a href="text-level-semantics.html#the-b-element">b</a></code><ul><li class="t3"><code>#text</code>: <span title="">1</span></li></ul></li><li class="t1"><code><a href="grouping-content.html#the-p-element">p</a></code><ul><li class="t1"><code><a href="text-level-semantics.html#the-b-element">b</a></code><ul><li class="t3"><code>#text</code>: <span title="">2</span></li></ul></li><li class="t3"><code>#text</code>: <span title="">3</span></li></ul></li></ul></li></ul></li></ul><h5 id="unexpected-markup-in-tables"><span class="secno">8.2.8.3 </span>Unexpected markup in tables</h5>

  <p><i>This section is non-normative.</i></p>

  <p>Error handling in tables is, for historical reasons, especially
  strange. For example, consider the following markup:</p>

  <pre>&lt;table&gt;<strong>&lt;b&gt;</strong>&lt;tr&gt;&lt;td&gt;aaa&lt;/td&gt;&lt;/tr&gt;<strong>bbb</strong>&lt;/table&gt;ccc</pre>

  <p>The highlighted <code><a href="text-level-semantics.html#the-b-element">b</a></code> element start tag is not allowed
  directly inside a table like that, and the parser handles this case
  by placing the element <em>before</em> the table. (This is called <i title="foster parent"><a href="tree-construction.html#foster-parent">foster parenting</a></i>.) This can be seen by
  examining the DOM tree as it stands just after the
  <code><a href="tabular-data.html#the-table-element">table</a></code> element's start tag has been seen:</p>

  <ul class="domTree"><li class="t1"><code><a href="semantics.html#the-html-element">html</a></code><ul><li class="t1"><code><a href="semantics.html#the-head-element">head</a></code></li><li class="t1"><code><a href="sections.html#the-body-element">body</a></code><ul><li class="t1"><code><a href="tabular-data.html#the-table-element">table</a></code></li></ul></li></ul></li></ul><p>...and then immediately after the <code><a href="text-level-semantics.html#the-b-element">b</a></code> element start
  tag has been seen:</p>

  <ul class="domTree"><li class="t1"><code><a href="semantics.html#the-html-element">html</a></code><ul><li class="t1"><code><a href="semantics.html#the-head-element">head</a></code></li><li class="t1"><code><a href="sections.html#the-body-element">body</a></code><ul><li class="t1"><code><a href="text-level-semantics.html#the-b-element">b</a></code></li><li class="t1"><code><a href="tabular-data.html#the-table-element">table</a></code></li></ul></li></ul></li></ul><p>At this point, the <a href="parsing.html#stack-of-open-elements">stack of open elements</a> has on it
  the elements <code><a href="semantics.html#the-html-element">html</a></code>, <code><a href="sections.html#the-body-element">body</a></code>,
  <code><a href="tabular-data.html#the-table-element">table</a></code>, and <code><a href="text-level-semantics.html#the-b-element">b</a></code> (in that order, despite the
  resulting DOM tree); the <a href="parsing.html#list-of-active-formatting-elements">list of active formatting
  elements</a> just has the <code><a href="text-level-semantics.html#the-b-element">b</a></code> element in it; and the
  <a href="parsing.html#insertion-mode">insertion mode</a> is "<a href="tree-construction.html#parsing-main-intable" title="insertion mode: in
  table">in table</a>".</p>

  <p>The <code><a href="tabular-data.html#the-tr-element">tr</a></code> start tag causes the <code><a href="text-level-semantics.html#the-b-element">b</a></code> element
  to be popped off the stack and a <code><a href="tabular-data.html#the-tbody-element">tbody</a></code> start tag to be
  implied; the <code><a href="tabular-data.html#the-tbody-element">tbody</a></code> and <code><a href="tabular-data.html#the-tr-element">tr</a></code> elements are
  then handled in a rather straight-forward manner, taking the parser
  through the "<a href="tree-construction.html#parsing-main-intbody" title="insertion mode: in table body">in table
  body</a>" and "<a href="tree-construction.html#parsing-main-intr" title="insertion mode: in row">in
  row</a>" insertion modes, after which the DOM looks as
  follows:</p>

  <ul class="domTree"><li class="t1"><code><a href="semantics.html#the-html-element">html</a></code><ul><li class="t1"><code><a href="semantics.html#the-head-element">head</a></code></li><li class="t1"><code><a href="sections.html#the-body-element">body</a></code><ul><li class="t1"><code><a href="text-level-semantics.html#the-b-element">b</a></code></li><li class="t1"><code><a href="tabular-data.html#the-table-element">table</a></code><ul><li class="t1"><code><a href="tabular-data.html#the-tbody-element">tbody</a></code><ul><li class="t1"><code><a href="tabular-data.html#the-tr-element">tr</a></code></li></ul></li></ul></li></ul></li></ul></li></ul><p>Here, the <a href="parsing.html#stack-of-open-elements">stack of open elements</a> has on it the
  elements <code><a href="semantics.html#the-html-element">html</a></code>, <code><a href="sections.html#the-body-element">body</a></code>, <code><a href="tabular-data.html#the-table-element">table</a></code>,
  <code><a href="tabular-data.html#the-tbody-element">tbody</a></code>, and <code><a href="tabular-data.html#the-tr-element">tr</a></code>; the <a href="parsing.html#list-of-active-formatting-elements">list of active
  formatting elements</a> still has the <code><a href="text-level-semantics.html#the-b-element">b</a></code> element in
  it; and the <a href="parsing.html#insertion-mode">insertion mode</a> is "<a href="tree-construction.html#parsing-main-intr" title="insertion
  mode: in row">in row</a>".</p>

  <p>The <code><a href="tabular-data.html#the-td-element">td</a></code> element start tag token, after putting a
  <code><a href="tabular-data.html#the-td-element">td</a></code> element on the tree, puts a marker on the <a href="parsing.html#list-of-active-formatting-elements">list
  of active formatting elements</a> (it also switches to the "<a href="tree-construction.html#parsing-main-intd" title="insertion mode: in cell">in cell</a>" <a href="parsing.html#insertion-mode">insertion
  mode</a>).</p>

  <ul class="domTree"><li class="t1"><code><a href="semantics.html#the-html-element">html</a></code><ul><li class="t1"><code><a href="semantics.html#the-head-element">head</a></code></li><li class="t1"><code><a href="sections.html#the-body-element">body</a></code><ul><li class="t1"><code><a href="text-level-semantics.html#the-b-element">b</a></code></li><li class="t1"><code><a href="tabular-data.html#the-table-element">table</a></code><ul><li class="t1"><code><a href="tabular-data.html#the-tbody-element">tbody</a></code><ul><li class="t1"><code><a href="tabular-data.html#the-tr-element">tr</a></code><ul><li class="t1"><code><a href="tabular-data.html#the-td-element">td</a></code></li></ul></li></ul></li></ul></li></ul></li></ul></li></ul><p>The marker means that when the "aaa" character tokens are seen,
  no <code><a href="text-level-semantics.html#the-b-element">b</a></code> element is created to hold the resulting text
  node:</p>

  <ul class="domTree"><li class="t1"><code><a href="semantics.html#the-html-element">html</a></code><ul><li class="t1"><code><a href="semantics.html#the-head-element">head</a></code></li><li class="t1"><code><a href="sections.html#the-body-element">body</a></code><ul><li class="t1"><code><a href="text-level-semantics.html#the-b-element">b</a></code></li><li class="t1"><code><a href="tabular-data.html#the-table-element">table</a></code><ul><li class="t1"><code><a href="tabular-data.html#the-tbody-element">tbody</a></code><ul><li class="t1"><code><a href="tabular-data.html#the-tr-element">tr</a></code><ul><li class="t1"><code><a href="tabular-data.html#the-td-element">td</a></code><ul><li class="t3"><code>#text</code>: <span title="">aaa</span></li></ul></li></ul></li></ul></li></ul></li></ul></li></ul></li></ul><p>The end tags are handled in a straight-forward manner; after
  handling them, the <a href="parsing.html#stack-of-open-elements">stack of open elements</a> has on it the
  elements <code><a href="semantics.html#the-html-element">html</a></code>, <code><a href="sections.html#the-body-element">body</a></code>, <code><a href="tabular-data.html#the-table-element">table</a></code>,
  and <code><a href="tabular-data.html#the-tbody-element">tbody</a></code>; the <a href="parsing.html#list-of-active-formatting-elements">list of active formatting
  elements</a> still has the <code><a href="text-level-semantics.html#the-b-element">b</a></code> element in it (the
  marker having been removed by the "td" end tag token); and the
  <a href="parsing.html#insertion-mode">insertion mode</a> is "<a href="tree-construction.html#parsing-main-intbody" title="insertion mode: in
  table body">in table body</a>".</p>

  <p>Thus it is that the "bbb" character tokens are found. These
  trigger the "<a href="tree-construction.html#parsing-main-intabletext" title="insertion mode: in table text">in table
  text</a>" insertion mode to be used (with the <a href="parsing.html#original-insertion-mode">original
  insertion mode</a> set to "<a href="tree-construction.html#parsing-main-intbody" title="insertion mode: in table
  body">in table body</a>"). The character tokens are collected,
  and when the next token (the <code><a href="tabular-data.html#the-table-element">table</a></code> element end tag) is
  seen, they are processed as a group. Since they are not all spaces,
  they are handled as per the "anything else" rules in the "<a href="tree-construction.html#parsing-main-intable" title="insertion mode: in table">in table</a>" insertion mode,
  which defer to the "<a href="tree-construction.html#parsing-main-inbody" title="insertion mode: in body">in
  body</a>" insertion mode but with <a href="tree-construction.html#foster-parent" title="foster
  parent">foster parenting</a>.</p>

  <p>When <a href="parsing.html#reconstruct-the-active-formatting-elements" title="reconstruct the active formatting elements">the
  active formatting elements are reconstructed</a>, a
  <code><a href="text-level-semantics.html#the-b-element">b</a></code> element is created and <a href="tree-construction.html#foster-parent" title="foster
  parent">foster parented</a>, and then the "bbb" text node is
  appended to it:</p>

  <ul class="domTree"><li class="t1"><code><a href="semantics.html#the-html-element">html</a></code><ul><li class="t1"><code><a href="semantics.html#the-head-element">head</a></code></li><li class="t1"><code><a href="sections.html#the-body-element">body</a></code><ul><li class="t1"><code><a href="text-level-semantics.html#the-b-element">b</a></code></li><li class="t1"><code><a href="text-level-semantics.html#the-b-element">b</a></code><ul><li class="t3"><code>#text</code>: <span title="">bbb</span></li></ul></li><li class="t1"><code><a href="tabular-data.html#the-table-element">table</a></code><ul><li class="t1"><code><a href="tabular-data.html#the-tbody-element">tbody</a></code><ul><li class="t1"><code><a href="tabular-data.html#the-tr-element">tr</a></code><ul><li class="t1"><code><a href="tabular-data.html#the-td-element">td</a></code><ul><li class="t3"><code>#text</code>: <span title="">aaa</span></li></ul></li></ul></li></ul></li></ul></li></ul></li></ul></li></ul><p>The <a href="parsing.html#stack-of-open-elements">stack of open elements</a> has on it the elements
  <code><a href="semantics.html#the-html-element">html</a></code>, <code><a href="sections.html#the-body-element">body</a></code>, <code><a href="tabular-data.html#the-table-element">table</a></code>,
  <code><a href="tabular-data.html#the-tbody-element">tbody</a></code>, and the new <code><a href="text-level-semantics.html#the-b-element">b</a></code> (again, note that
  this doesn't match the resulting tree!); the <a href="parsing.html#list-of-active-formatting-elements">list of active
  formatting elements</a> has the new <code><a href="text-level-semantics.html#the-b-element">b</a></code> element in it;
  and the <a href="parsing.html#insertion-mode">insertion mode</a> is still "<a href="tree-construction.html#parsing-main-intbody" title="insertion
  mode: in table body">in table body</a>".</p>

  <p>Had the character tokens been only <a href="common-microsyntaxes.html#space-character" title="space
  character">space characters</a> instead of "bbb", then those
  <a href="common-microsyntaxes.html#space-character" title="space character">space characters</a> would just be
  appended to the <code><a href="tabular-data.html#the-tbody-element">tbody</a></code> element.</p>

  <p>Finally, the <code><a href="tabular-data.html#the-table-element">table</a></code> is closed by a "table" end
  tag. This pops all the nodes from the <a href="parsing.html#stack-of-open-elements">stack of open
  elements</a> up to and including the <code><a href="tabular-data.html#the-table-element">table</a></code> element,
  but it doesn't affect the <a href="parsing.html#list-of-active-formatting-elements">list of active formatting
  elements</a>, so the "ccc" character tokens after the table
  result in yet another <code><a href="text-level-semantics.html#the-b-element">b</a></code> element being created, this
  time after the table:</p>

  <ul class="domTree"><li class="t1"><code><a href="semantics.html#the-html-element">html</a></code><ul><li class="t1"><code><a href="semantics.html#the-head-element">head</a></code></li><li class="t1"><code><a href="sections.html#the-body-element">body</a></code><ul><li class="t1"><code><a href="text-level-semantics.html#the-b-element">b</a></code></li><li class="t1"><code><a href="text-level-semantics.html#the-b-element">b</a></code><ul><li class="t3"><code>#text</code>: <span title="">bbb</span></li></ul></li><li class="t1"><code><a href="tabular-data.html#the-table-element">table</a></code><ul><li class="t1"><code><a href="tabular-data.html#the-tbody-element">tbody</a></code><ul><li class="t1"><code><a href="tabular-data.html#the-tr-element">tr</a></code><ul><li class="t1"><code><a href="tabular-data.html#the-td-element">td</a></code><ul><li class="t3"><code>#text</code>: <span title="">aaa</span></li></ul></li></ul></li></ul></li></ul></li><li class="t1"><code><a href="text-level-semantics.html#the-b-element">b</a></code><ul><li class="t3"><code>#text</code>: <span title="">ccc</span></li></ul></li></ul></li></ul></li></ul><h5 id="scripts-that-modify-the-page-as-it-is-being-parsed"><span class="secno">8.2.8.4 </span>Scripts that modify the page as it is being parsed</h5>

  <p><i>This section is non-normative.</i></p>

  <p>Consider the following markup, which for this example we will
  assume is the document with <a href="urls.html#url">URL</a> <code title="">http://example.com/inner</code>, being rendered as the
  content of an <code><a href="the-iframe-element.html#the-iframe-element">iframe</a></code> in another document with the
  <a href="urls.html#url">URL</a> <code title="">http://example.com/outer</code>:</p>

  <pre>&lt;div id=a&gt;
 &lt;script&gt;
  var div = document.getElementById('a');
  parent.document.body.appendChild(div);
 &lt;/script&gt;
 &lt;script&gt;
  alert(document.URL);
 &lt;/script&gt;
&lt;/div&gt;
&lt;script&gt;
 alert(document.URL);
&lt;/script&gt;</pre>

  <p>Up to the first "script" end tag, before the script is parsed,
  the result is relatively straightforward:</p>

  <ul class="domTree"><li class="t1"><code><a href="semantics.html#the-html-element">html</a></code><ul><li class="t1"><code><a href="semantics.html#the-head-element">head</a></code></li><li class="t1"><code><a href="sections.html#the-body-element">body</a></code><ul><li class="t1"><code><a href="grouping-content.html#the-div-element">div</a></code> <span class="t2" title=""><code class="attribute name">id</code>="<code class="attribute value"><a href="text-level-semantics.html#the-a-element">a</a></code>"</span><ul><li class="t3"><code>#text</code>: <span title="">
 </span></li><li class="t1"><code><a href="scripting-1.html#the-script-element">script</a></code><ul><li class="t3"><code>#text</code>: <span title="">var div = document.getElementById('a'); &#9166; parent.document.body.appendChild(div);</span></li></ul></li></ul></li></ul></li></ul></li></ul><p>After the script is parsed, though, the <code><a href="grouping-content.html#the-div-element">div</a></code> element
  and its child <code><a href="scripting-1.html#the-script-element">script</a></code> element are gone:</p>

  <ul class="domTree"><li class="t1"><code><a href="semantics.html#the-html-element">html</a></code><ul><li class="t1"><code><a href="semantics.html#the-head-element">head</a></code></li><li class="t1"><code><a href="sections.html#the-body-element">body</a></code></li></ul></li></ul><p>They are, at this point, in the <code><a href="infrastructure.html#document">Document</a></code> of the
  aforementioned outer <a href="browsers.html#browsing-context">browsing context</a>. However, the
  <a href="parsing.html#stack-of-open-elements">stack of open elements</a> <em>still contains the
  <code><a href="grouping-content.html#the-div-element">div</a></code> element</em>.</p>

  <p>Thus, when the second <code><a href="scripting-1.html#the-script-element">script</a></code> element is parsed, it
  is inserted <em>into the outer <code><a href="infrastructure.html#document">Document</a></code>
  object</em>.</p>

  <p>This also means that the <a href="webappapis.html#script-s-global-object">script's global object</a> is
  the outer <a href="browsers.html#browsing-context">browsing context</a>'s <code><a href="browsers.html#window">Window</a></code>
  object, <em>not</em> the <code><a href="browsers.html#window">Window</a></code> object inside the
  <code><a href="the-iframe-element.html#the-iframe-element">iframe</a></code>.</p>

  <p class="note">This isn't a security problem since the script that
  moves the <code><a href="grouping-content.html#the-div-element">div</a></code> into the outer <code><a href="infrastructure.html#document">Document</a></code> can
  only do so because the two <code><a href="infrastructure.html#document">Document</a></code> object have the
  same <a href="origin-0.html#origin">origin</a>.</p>

  <p>Thus, the first alert says "http://example.com/outer".</p>

  <p>Once the <code><a href="grouping-content.html#the-div-element">div</a></code> element's end tag is parsed, the
  <code><a href="grouping-content.html#the-div-element">div</a></code> element is popped off the stack, and so the next
  <code><a href="scripting-1.html#the-script-element">script</a></code> element is in the inner <code><a href="infrastructure.html#document">Document</a></code>:</p>

  <ul class="domTree"><li class="t1"><code><a href="semantics.html#the-html-element">html</a></code><ul><li class="t1"><code><a href="semantics.html#the-head-element">head</a></code></li><li class="t1"><code><a href="sections.html#the-body-element">body</a></code><ul><li class="t1"><code><a href="scripting-1.html#the-script-element">script</a></code><ul><li class="t3"><code>#text</code>: <span title="">alert(document.URL);</span></li></ul></li></ul></li></ul></li></ul><p>This second alert will say "http://example.com/inner".</p>


  <h5 id="the-execution-of-scripts-that-are-moving-across-multiple-documents"><span class="secno">8.2.8.5 </span>The execution of scripts that are moving across multiple documents</h5>

  <p><i>This section is non-normative.</i></p>

  <p>Elaborating on the example in the previous section, consider a
  case where a <code><a href="scripting-1.html#the-script-element">script</a></code> element with a <code title="attr-script-src"><a href="scripting-1.html#attr-script-src">src</a></code> attribute is parsed, but while
  the external script is being downloaded, the element is moved to
  another document.</p>

  <p>In this case, the <a href="webappapis.html#script-s-global-object">script's global object</a> is that
  second document's <a href="browsers.html#browsing-context">browsing context</a>'s
  <code><a href="browsers.html#window">Window</a></code> object, not the <code><a href="browsers.html#window">Window</a></code> object of
  the document into which the element was parsed.</p>



  <h5 id="unclosed-formatting-elements"><span class="secno">8.2.8.6 </span>Unclosed formatting elements</h5>

  <p><i>This section is non-normative.</i></p>

  <p>The following markup shows how nested formatting elements (such
  as <code><a href="text-level-semantics.html#the-b-element">b</a></code>) get collected and continue to be applied even as
  the elements they are contained in are closed, but that excessive
  duplicates are thrown away.</p>

  <pre>&lt;!DOCTYPE html&gt;
&lt;p&gt;&lt;b class=x&gt;&lt;b class=x&gt;&lt;b&gt;&lt;b class=x&gt;&lt;b class=x&gt;&lt;b&gt;X
&lt;p&gt;X
&lt;p&gt;&lt;b&gt;&lt;b class=x&gt;&lt;b&gt;X
&lt;p&gt;&lt;/b&gt;&lt;/b&gt;&lt;/b&gt;&lt;/b&gt;&lt;/b&gt;&lt;/b&gt;X</pre>

  <p>The resulting DOM tree is as follows:</p>

  <ul class="domTree"><li class="t10">DOCTYPE: <code><a href="semantics.html#the-html-element">html</a></code></li><li class="t1"><code><a href="semantics.html#the-html-element">html</a></code><ul><li class="t1"><code><a href="semantics.html#the-head-element">head</a></code></li><li class="t1"><code><a href="sections.html#the-body-element">body</a></code><ul><li class="t1"><code><a href="grouping-content.html#the-p-element">p</a></code><ul><li class="t1"><code><a href="text-level-semantics.html#the-b-element">b</a></code> <span class="t2" title=""><code class="attribute name">class</code>="<code class="attribute value">x</code>"</span><ul><li class="t1"><code><a href="text-level-semantics.html#the-b-element">b</a></code> <span class="t2" title=""><code class="attribute name">class</code>="<code class="attribute value">x</code>"</span><ul><li class="t1"><code><a href="text-level-semantics.html#the-b-element">b</a></code><ul><li class="t1"><code><a href="text-level-semantics.html#the-b-element">b</a></code> <span class="t2" title=""><code class="attribute name">class</code>="<code class="attribute value">x</code>"</span><ul><li class="t1"><code><a href="text-level-semantics.html#the-b-element">b</a></code> <span class="t2" title=""><code class="attribute name">class</code>="<code class="attribute value">x</code>"</span><ul><li class="t1"><code><a href="text-level-semantics.html#the-b-element">b</a></code><ul><li class="t3"><code>#text</code>: <span title="">X&#9166;</span></li></ul></li></ul></li></ul></li></ul></li></ul></li></ul></li></ul></li><li class="t1"><code><a href="grouping-content.html#the-p-element">p</a></code><ul><li class="t1"><code><a href="text-level-semantics.html#the-b-element">b</a></code> <span class="t2" title=""><code class="attribute name">class</code>="<code class="attribute value">x</code>"</span><ul><li class="t1"><code><a href="text-level-semantics.html#the-b-element">b</a></code><ul><li class="t1"><code><a href="text-level-semantics.html#the-b-element">b</a></code> <span class="t2" title=""><code class="attribute name">class</code>="<code class="attribute value">x</code>"</span><ul><li class="t1"><code><a href="text-level-semantics.html#the-b-element">b</a></code> <span class="t2" title=""><code class="attribute name">class</code>="<code class="attribute value">x</code>"</span><ul><li class="t1"><code><a href="text-level-semantics.html#the-b-element">b</a></code><ul><li class="t3"><code>#text</code>: <span title="">X&#9166;</span></li></ul></li></ul></li></ul></li></ul></li></ul></li></ul></li><li class="t1"><code><a href="grouping-content.html#the-p-element">p</a></code><ul><li class="t1"><code><a href="text-level-semantics.html#the-b-element">b</a></code> <span class="t2" title=""><code class="attribute name">class</code>="<code class="attribute value">x</code>"</span><ul><li class="t1"><code><a href="text-level-semantics.html#the-b-element">b</a></code><ul><li class="t1"><code><a href="text-level-semantics.html#the-b-element">b</a></code> <span class="t2" title=""><code class="attribute name">class</code>="<code class="attribute value">x</code>"</span><ul><li class="t1"><code><a href="text-level-semantics.html#the-b-element">b</a></code> <span class="t2" title=""><code class="attribute name">class</code>="<code class="attribute value">x</code>"</span><ul><li class="t1"><code><a href="text-level-semantics.html#the-b-element">b</a></code><ul><li class="t1"><code><a href="text-level-semantics.html#the-b-element">b</a></code><ul><li class="t1"><code><a href="text-level-semantics.html#the-b-element">b</a></code> <span class="t2" title=""><code class="attribute name">class</code>="<code class="attribute value">x</code>"</span><ul><li class="t1"><code><a href="text-level-semantics.html#the-b-element">b</a></code><ul><li class="t3"><code>#text</code>: <span title="">X&#9166;</span></li></ul></li></ul></li></ul></li></ul></li></ul></li></ul></li></ul></li></ul></li></ul></li><li class="t1"><code><a href="grouping-content.html#the-p-element">p</a></code><ul><li class="t3"><code>#text</code>: <span title="">X&#9166;</span></li></ul></li></ul></li></ul></li></ul><p>Note how the second <code><a href="grouping-content.html#the-p-element">p</a></code> element in the markup has no
  explicit <code><a href="text-level-semantics.html#the-b-element">b</a></code> elements, but in the resulting DOM, up to
  three of each kind of formatting element (in this case three
  <code><a href="text-level-semantics.html#the-b-element">b</a></code> elements with the class attribute, and two unadorned
  <code><a href="text-level-semantics.html#the-b-element">b</a></code> elements) get reconstructed before the element's
  "X".</p>

  <p>Also note how this means that in the final paragraph only six
  <code><a href="text-level-semantics.html#the-b-element">b</a></code> end tags are needed to completely clear the list of
  formatting elements, even though nine <code><a href="text-level-semantics.html#the-b-element">b</a></code> start tags have
  been seen up to this point.</p>




  <h3 id="serializing-html-fragments"><span class="secno">8.3 </span>Serializing HTML fragments</h3>

  <p>The following steps form the <dfn id="html-fragment-serialization-algorithm">HTML fragment serialization
  algorithm</dfn>. The algorithm takes as input a DOM
  <code><a href="infrastructure.html#element">Element</a></code>, <code><a href="infrastructure.html#document">Document</a></code>, or
  <code><a href="infrastructure.html#documentfragment">DocumentFragment</a></code> referred to as <var title="">the
  node</var>, and either returns a string or raises an exception.</p>

  <p class="note">This algorithm serializes the <em>children</em> of
  the node being serialized, not the node itself.</p>

  <ol><li><p>Let <var title="">s</var> be a string, and initialize it to
   the empty string.</p></li>

   <li>

    <p>For each child node of <var title="">the node</var>, in
    <a href="infrastructure.html#tree-order">tree order</a>, run the following steps:

    </p><ol><li><p>Let <var title="">current node</var> be the child node
     being processed.</p></li>

     <li>

      <p>Append the appropriate string from the following list to
      <var title="">s</var>:</p>

      <dl class="switch"><dt>If <var title="">current node</var> is an <code title="">Element</code></dt>

       <dd>

        <p>If <var title="">current node</var> is an element in the
        <a href="namespaces.html#html-namespace-0">HTML namespace</a>, the <a href="namespaces.html#mathml-namespace">MathML
        namespace</a>, or the <a href="namespaces.html#svg-namespace">SVG namespace</a>, then let
        <var title="">tagname</var> be <var title="">current
        node</var>'s local name. Otherwise, let <var title="">tagname</var> be <var title="">current node</var>'s
        qualified name.</p>

        <p>Append a U+003C LESS-THAN SIGN character (&lt;), followed
        by <var title="">tagname</var>.</p>

        <p class="note">For <a href="infrastructure.html#html-elements">HTML elements</a> created by the
        <a href="parsing.html#html-parser">HTML parser</a> or <code title="">Document.createElement()</code>, <var title="">tagname</var> will be lowercase.</p>

        <p>For each attribute that the element has, append a U+0020
        SPACE character, the <a href="#attribute-s-serialized-name" title="attribute's serialized
        name">attribute's serialized name as described below</a>, a
        U+003D EQUALS SIGN character (=), a U+0022 QUOTATION MARK
        character ("), the attribute's value, <a href="#escapingString" title="escaping a string">escaped as described below</a> in
        <i>attribute mode</i>, and a second U+0022 QUOTATION MARK
        character (").</p>

        <p>An <dfn id="attribute-s-serialized-name">attribute's serialized name</dfn> for the purposes
        of the previous paragraph must be determined as follows:</p>

        <dl class="switch"><dt>If the attribute has no namespace</dt>

         <dd>

          <p>The attribute's serialized name is the attribute's local
          name.</p>

          <p class="note">For attributes on <a href="infrastructure.html#html-elements">HTML elements</a>
          set by the <a href="parsing.html#html-parser">HTML parser</a> or by <code title="">Element.setAttributeNode()</code> or <code title="">Element.setAttribute()</code>, the local name will
          be lowercase.</p>

         </dd>


         <dt>If the attribute is in the <a href="namespaces.html#xml-namespace">XML namespace</a></dt>

         <dd><p>The attribute's serialized name is the string "<code title="">xml:</code>" followed by the attribute's local
         name.</p></dd>


         <dt>If the attribute is in the <a href="namespaces.html#xmlns-namespace">XMLNS namespace</a> and the attribute's local name is <code title="">xmlns</code></dt>

         <dd><p>The attribute's serialized name is the string "<code title="">xmlns</code>".</p></dd>


         <dt>If the attribute is in the <a href="namespaces.html#xmlns-namespace">XMLNS namespace</a> and the attribute's local name is not <code title="">xmlns</code></dt>

         <dd><p>The attribute's serialized name is the string "<code title="">xmlns:</code>" followed by the attribute's local
         name.</p></dd>


         <dt>If the attribute is in the <a href="namespaces.html#xlink-namespace">XLink namespace</a></dt>

         <dd><p>The attribute's serialized name is the string "<code title="">xlink:</code>" followed by the attribute's local
         name.</p></dd>


         <dt>If the attribute is in some other namespace</dt>

         <dd><p>The attribute's serialized name is the attribute's
         qualified name.</p></dd>

        </dl><p>While the exact order of attributes is UA-defined, and may
        depend on factors such as the order that the attributes were
        given in the original markup, the sort order must be stable,
        such that consecutive invocations of this algorithm serialize an
        element's attributes in the same order.</p>

        <p>Append a U+003E GREATER-THAN SIGN character (&gt;).</p>

        <p>If <var title="">current node</var> is an
        <code><a href="the-map-element.html#the-area-element">area</a></code>, <code><a href="semantics.html#the-base-element">base</a></code>, <code><a href="obsolete.html#basefont">basefont</a></code>,
        <code><a href="obsolete.html#bgsound">bgsound</a></code>, <code><a href="text-level-semantics.html#the-br-element">br</a></code>, <code><a href="tabular-data.html#the-col-element">col</a></code>,
        <code><a href="interactive-elements.html#the-command-element">command</a></code>, <code><a href="the-iframe-element.html#the-embed-element">embed</a></code>, <code><a href="obsolete.html#frame">frame</a></code>,
        <code><a href="grouping-content.html#the-hr-element">hr</a></code>, <code><a href="embedded-content-1.html#the-img-element">img</a></code>, <code><a href="the-input-element.html#the-input-element">input</a></code>,
        <code><a href="the-button-element.html#the-keygen-element">keygen</a></code>, <code><a href="semantics.html#the-link-element">link</a></code>, <code><a href="semantics.html#the-meta-element">meta</a></code>,
        <code><a href="the-iframe-element.html#the-param-element">param</a></code>, <code><a href="the-iframe-element.html#the-source-element">source</a></code>, <code><a href="the-iframe-element.html#the-track-element">track</a></code> or
        <code><a href="text-level-semantics.html#the-wbr-element">wbr</a></code> element, then continue on to the next child
        node at this point.</p> 
        
        <p>If <var title="">current node</var> is a <code><a href="grouping-content.html#the-pre-element">pre</a></code>,
        <code><a href="the-button-element.html#the-textarea-element">textarea</a></code>, or <code><a href="obsolete.html#listing">listing</a></code> element, append
        a U+000A LINE FEED (LF) character.</p>

        <p>Append the value of running the <a href="#html-fragment-serialization-algorithm">HTML fragment
        serialization algorithm</a> on the <var title="">current
        node</var> element (thus recursing into this algorithm for
        that element), followed by a U+003C LESS-THAN SIGN character
        (&lt;), a U+002F SOLIDUS character (/), <var title="">tagname</var> again, and finally a U+003E
        GREATER-THAN SIGN character (&gt;).</p>

       </dd>


       <dt>If <var title="">current node</var> is a <code title="">Text</code> or <code title="">CDATASection</code>
       node</dt>

       <dd>

        <p>If the parent of <var title="">current node</var> is a
        <code><a href="semantics.html#the-style-element">style</a></code>, <code><a href="scripting-1.html#the-script-element">script</a></code>, <code><a href="obsolete.html#xmp">xmp</a></code>,
        <code><a href="the-iframe-element.html#the-iframe-element">iframe</a></code>, <code><a href="obsolete.html#noembed">noembed</a></code>,
        <code><a href="obsolete.html#noframes">noframes</a></code>, or <code><a href="obsolete.html#plaintext">plaintext</a></code> element, or
        if the parent of <var title="">current node</var> is
        <code><a href="scripting-1.html#the-noscript-element">noscript</a></code> element and <a href="webappapis.html#concept-n-script" title="concept-n-script">scripting is enabled</a> for the
        node, then append the value of <var title="">current
        node</var>'s <code title="">data</code> IDL attribute
        literally.</p>

        <p>Otherwise, append the value of <var title="">current
        node</var>'s <code title="">data</code> IDL attribute, <a href="#escapingString" title="escaping a string">escaped as described
        below</a>.</p>

       </dd>


       <dt>If <var title="">current node</var> is a <code title="">Comment</code></dt>

       <dd>

        <p>Append the literal string <code>&lt;!--</code> (U+003C
        LESS-THAN SIGN, U+0021 EXCLAMATION MARK, U+002D HYPHEN-MINUS,
        U+002D HYPHEN-MINUS), followed by the value of <var title="">current node</var>'s <code title="">data</code> IDL
        attribute, followed by the literal string <code>--&gt;</code>
        (U+002D HYPHEN-MINUS, U+002D HYPHEN-MINUS, U+003E GREATER-THAN
        SIGN).</p>

       </dd>


       <dt>If <var title="">current node</var> is a <code title="">ProcessingInstruction</code></dt>

       <dd>

        <p>Append the literal string <code>&lt;?</code> (U+003C
        LESS-THAN SIGN, U+003F QUESTION MARK), followed by the value
        of <var title="">current node</var>'s <code title="">target</code> IDL attribute, followed by a single
        U+0020 SPACE character, followed by the value of <var title="">current node</var>'s <code title="">data</code> IDL
        attribute, followed by a single U+003E GREATER-THAN SIGN
        character (&gt;).</p>

       </dd>


       <dt>If <var title="">current node</var> is a <code title="">DocumentType</code></dt>

       <dd>

        <p>Append the literal string <code>&lt;!DOCTYPE</code> (U+003C
        LESS-THAN SIGN, U+0021 EXCLAMATION MARK, U+0044 LATIN CAPITAL
        LETTER D, U+004F LATIN CAPITAL LETTER O, U+0043 LATIN CAPITAL
        LETTER C, U+0054 LATIN CAPITAL LETTER T, U+0059 LATIN CAPITAL
        LETTER Y, U+0050 LATIN CAPITAL LETTER P, U+0045 LATIN CAPITAL
        LETTER E), followed by a space (U+0020 SPACE), followed by the
        value of <var title="">current node</var>'s <code title="">name</code> IDL attribute, followed by the literal
        string <code>&gt;</code> (U+003E GREATER-THAN SIGN).</p>

       </dd>


      </dl><p>Other node types (e.g. <code title="">Attr</code>) cannot
      occur as children of elements. If, despite this, they somehow do
      occur, this algorithm must raise an
      <code><a href="common-dom-interfaces.html#invalid_state_err">INVALID_STATE_ERR</a></code> exception.</p>

     </li>

    </ol></li>

   <li><p>The result of the algorithm is the string <var title="">s</var>.</p></li>

  </ol><p class="note">Entity reference nodes are <a href="infrastructure.html#entity-references">assumed to be expanded</a> by the user
  agent, and are therefore not covered in the algorithm above.</p>

  <p class="warning">It is possible that the output of this algorithm, if
  parsed with an <a href="parsing.html#html-parser">HTML parser</a>, will not return the
  original tree structure.</p>

  <div class="example">

   <p>For instance, if a <code><a href="the-button-element.html#the-textarea-element">textarea</a></code> element to which a
   <code title="">Comment</code> node has been appended is serialized
   and the output is then reparsed, the comment will end up being
   displayed in the text field. Similarly, if, as a result of DOM
   manipulation, an element contains a comment that contains the
   literal string "<code title="">--&gt;</code>", then when the result
   of serializing the element is parsed, the comment will be truncated
   at that point and the rest of the comment will be interpreted as
   markup. More examples would be making a <code><a href="scripting-1.html#the-script-element">script</a></code> element
   contain a text node with the text string
   "<code>&lt;/script&gt;</code>", or having a <code><a href="grouping-content.html#the-p-element">p</a></code> element
   that contains a <code><a href="grouping-content.html#the-ul-element">ul</a></code> element (as the <code><a href="grouping-content.html#the-ul-element">ul</a></code>
   element's <a href="syntax.html#syntax-start-tag" title="syntax-start-tag">start tag</a> would
   imply the end tag for the <code><a href="grouping-content.html#the-p-element">p</a></code>).</p>

   <p>This can enable cross-site scripting attacks. An example of this
   would be a page that lets the user enter some font names that are
   then inserted into a CSS <code><a href="semantics.html#the-style-element">style</a></code> block via the DOM and
   which then uses the <code title="dom-innerHTML"><a href="apis-in-html-documents.html#dom-innerhtml">innerHTML</a></code>
   IDL attribute to get the HTML serialization of that
   <code><a href="semantics.html#the-style-element">style</a></code> element: if the user enters
   "<code>&lt;/style&gt;&lt;script&gt;attack&lt;/script&gt;</code>" as a font
   name, <code title="dom-innerHTML"><a href="apis-in-html-documents.html#dom-innerhtml">innerHTML</a></code> will return
   markup that, if parsed in a different context, would contain a
   <code><a href="scripting-1.html#the-script-element">script</a></code> node, even though no <code><a href="scripting-1.html#the-script-element">script</a></code> node
   existed in the original DOM.</p>

  </div>

  <p><dfn id="escapingString">Escaping a string</dfn> (for the
  purposes of the algorithm above) consists of running the following
  steps:</p>

  <ol><li><p>Replace any occurrence of the "<code title="">&amp;</code>"
   character by the string "<code title="">&amp;amp;</code>".</p></li>

   <li><p>Replace any occurrences of the U+00A0 NO-BREAK SPACE
   character by the string "<code title="">&amp;nbsp;</code>".</p></li>

   <li><p>If the algorithm was invoked in the <i>attribute mode</i>,
   replace any occurrences of the "<code title="">"</code>"
   character by the string "<code title="">&amp;quot;</code>".</p></li>

   <li><p>If the algorithm was <em>not</em> invoked in the
   <i>attribute mode</i>, replace any occurrences of the "<code title="">&lt;</code>" character by the string "<code title="">&amp;lt;</code>", and any occurrences of the "<code title="">&gt;</code>" character by the string "<code title="">&amp;gt;</code>".</p></li>

  </ol><h3 id="parsing-html-fragments"><span class="secno">8.4 </span>Parsing HTML fragments</h3>

  <p>The following steps form the <dfn id="html-fragment-parsing-algorithm">HTML fragment parsing
  algorithm</dfn>. The algorithm optionally takes as input an
  <code><a href="infrastructure.html#element">Element</a></code> node, referred to as the <dfn id="concept-frag-parse-context" title="concept-frag-parse-context"><var>context</var></dfn> element,
  which gives the context for the parser, as well as <var title="">input</var>, a string to parse, and returns a list of zero
  or more nodes.</p>

  <p class="note">Parts marked <dfn id="fragment-case">fragment case</dfn> in algorithms
  in the parser section are parts that only occur if the parser was
  created for the purposes of this algorithm (and with a <var title="concept-frag-parse-context"><a href="#concept-frag-parse-context">context</a></var> element). The
  algorithms have been annotated with such markings for informational
  purposes only; such markings have no normative weight. If it is
  possible for a condition described as a <a href="#fragment-case">fragment case</a>
  to occur even when the parser wasn't created for the purposes of
  handling this algorithm, then that is an error in the
  specification.</p>

  <ol><li>

    <p>Create a new <code><a href="infrastructure.html#document">Document</a></code> node, and mark it as being
    an <a href="dom.html#html-documents" title="HTML documents">HTML document</a>.</p>

   </li>

   <li>

    <p>If there is a <var title="concept-frag-parse-context"><a href="#concept-frag-parse-context">context</a></var> element, and the
    <code><a href="infrastructure.html#document">Document</a></code> of the <var title="concept-frag-parse-context"><a href="#concept-frag-parse-context">context</a></var> element is in
    <a href="dom.html#quirks-mode">quirks mode</a>, then let the <code><a href="infrastructure.html#document">Document</a></code> be in
    <a href="dom.html#quirks-mode">quirks mode</a>. Otherwise, if there is a <var title="concept-frag-parse-context"><a href="#concept-frag-parse-context">context</a></var> element, and the
    <code><a href="infrastructure.html#document">Document</a></code> of the <var title="concept-frag-parse-context"><a href="#concept-frag-parse-context">context</a></var> element is in
    <a href="dom.html#limited-quirks-mode">limited-quirks mode</a>, then let the
    <code><a href="infrastructure.html#document">Document</a></code> be in <a href="dom.html#limited-quirks-mode">limited-quirks mode</a>.
    Otherwise, leave the <code><a href="infrastructure.html#document">Document</a></code> in <a href="dom.html#no-quirks-mode">no-quirks
    mode</a>.</p>

   </li>

   <li>

    <p>Create a new <a href="parsing.html#html-parser">HTML parser</a>, and associate it with
    the just created <code><a href="infrastructure.html#document">Document</a></code> node.</p>

   </li>

   <li>

    <p>If there is a <var title="concept-frag-parse-context"><a href="#concept-frag-parse-context">context</a></var> element, run
    these substeps:</p>

    <ol><li>

      <p>Set the state of the <a href="parsing.html#html-parser">HTML parser</a>'s
      <a href="tokenization.html#tokenization">tokenization</a> stage as follows:</p>

      <dl class="switch"><dt>If it is a <code><a href="semantics.html#the-title-element">title</a></code> or <code><a href="the-button-element.html#the-textarea-element">textarea</a></code>
       element</dt>

       <dd>Switch the tokenizer to the <a href="tokenization.html#rcdata-state">RCDATA state</a>.</dd>


       <dt>If it is a <code><a href="semantics.html#the-style-element">style</a></code>, <code><a href="obsolete.html#xmp">xmp</a></code>,
       <code><a href="the-iframe-element.html#the-iframe-element">iframe</a></code>, <code><a href="obsolete.html#noembed">noembed</a></code>, or
       <code><a href="obsolete.html#noframes">noframes</a></code> element</dt>

       <dd>Switch the tokenizer to the <a href="tokenization.html#rawtext-state">RAWTEXT state</a>.</dd>


       <dt>If it is a <code><a href="scripting-1.html#the-script-element">script</a></code> element</dt>

       <dd>Switch the tokenizer to the <a href="tokenization.html#script-data-state">script data state</a>.</dd>


       <dt>If it is a <code><a href="scripting-1.html#the-noscript-element">noscript</a></code> element</dt>

       <dd>If the <a href="parsing.html#scripting-flag">scripting flag</a> is enabled, switch the
       tokenizer to the <a href="tokenization.html#rawtext-state">RAWTEXT state</a>.  Otherwise,
       leave the tokenizer in the <a href="tokenization.html#data-state">data state</a>.</dd>


       <dt>If it is a <code><a href="obsolete.html#plaintext">plaintext</a></code> element</dt>

       <dd>Switch the tokenizer to the <a href="tokenization.html#plaintext-state">PLAINTEXT
       state</a>.</dd>


       <dt>Otherwise</dt>

       <dd>Leave the tokenizer in the <a href="tokenization.html#data-state">data state</a>.</dd>

      </dl><p class="note">For performance reasons, an implementation that
      does not report errors and that uses the actual state machine
      described in this specification directly could use the PLAINTEXT
      state instead of the RAWTEXT and script data states where those
      are mentioned in the list above. Except for rules regarding
      parse errors, they are equivalent, since there is no
      <a href="tokenization.html#appropriate-end-tag-token">appropriate end tag token</a> in the fragment case, yet
      they involve far fewer state transitions.</p>

     </li>

     <li>

      <p>Let <var title="">root</var> be a new <code><a href="semantics.html#the-html-element">html</a></code> element
      with no attributes.</p>

     </li>

     <li>

      <p>Append the element <var title="">root</var> to the
      <code><a href="infrastructure.html#document">Document</a></code> node created above.</p>

     </li>

     <li>

      <p>Set up the parser's <a href="parsing.html#stack-of-open-elements">stack of open elements</a> so that
      it contains just the single element <var title="">root</var>.</p>

     </li>

     <li>

      <p><a href="parsing.html#reset-the-insertion-mode-appropriately" title="reset the insertion mode appropriately">Reset the
      parser's insertion mode appropriately</a>.</p>

      <p class="note">The parser will reference the <var title="concept-frag-parse-context"><a href="#concept-frag-parse-context">context</a></var> element as part
      of that algorithm.</p>

     </li>

     <li>

      <p>Set the parser's <a href="parsing.html#form-element-pointer"><code>form</code> element
      pointer</a> to the nearest node to the <var title="concept-frag-parse-context"><a href="#concept-frag-parse-context">context</a></var> element that is
      a <code><a href="forms.html#the-form-element">form</a></code> element (going straight up the ancestor
      chain, and including the element itself, if it is a
      <code><a href="forms.html#the-form-element">form</a></code> element), or, if there is no such
      <code><a href="forms.html#the-form-element">form</a></code> element, to null.</p>

     </li>

    </ol></li>

   <li>

    <p>Place into the <a href="parsing.html#the-input-stream">input stream</a> for the <a href="parsing.html#html-parser">HTML
    parser</a> just created the <var title="">input</var>. The
    encoding <a href="parsing.html#concept-encoding-confidence" title="concept-encoding-confidence">confidence</a> is
    <i>irrelevant</i>.</p>

   </li>

   <li>

    <p>Start the parser and let it run until it has consumed all the
    characters just inserted into the input stream.</p>

   </li>

   <li>

    <p>If there is a <var title="concept-frag-parse-context"><a href="#concept-frag-parse-context">context</a></var> element, return
    the child nodes of <var title="">root</var>, in <a href="infrastructure.html#tree-order">tree
    order</a>.</p>

    <p>Otherwise, return the children of the <code><a href="infrastructure.html#document">Document</a></code>
    object, in <a href="infrastructure.html#tree-order">tree order</a>.</p>

   </li>

  </ol><p class="note">This algorithm is invoked without a <var title="concept-frag-parse-context"><a href="#concept-frag-parse-context">context</a></var> element in the case
  of <code title="dom-Document-innerHTML">Document.innerHTML</code>.</p>

  </div></body></html>