Annotation of html5/spec/syntax.html, revision 1.1021

1.872     mike        1: <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN">
1.894     mike        2: <!DOCTYPE html>
1.996     mike        3: <!-- when publishing, change bits marked ZZZ --><html lang="en-US-x-Hixie" class="split chapter"><head><title>8 The HTML syntax &#8212; HTML5 </title><style type="text/css">
1.1       mike        4:    pre { margin-left: 2em; white-space: pre-wrap; }
                      5:    h2 { margin: 3em 0 1em 0; }
                      6:    h3 { margin: 2.5em 0 1em 0; }
                      7:    h4 { margin: 2.5em 0 0.75em 0; }
                      8:    h5, h6 { margin: 2.5em 0 1em; }
                      9:    h1 + h2, h1 + h2 + h2 { margin: 0.75em 0 0.75em; }
                     10:    h2 + h3, h3 + h4, h4 + h5, h5 + h6 { margin-top: 0.5em; }
                     11:    p { margin: 1em 0; }
                     12:    hr:not(.top) { display: block; background: none; border: none; padding: 0; margin: 2em 0; height: auto; }
                     13:    dl, dd { margin-top: 0; margin-bottom: 0; }
                     14:    dt { margin-top: 0.75em; margin-bottom: 0.25em; clear: left; }
                     15:    dt + dt { margin-top: 0; }
                     16:    dd dt { margin-top: 0.25em; margin-bottom: 0; }
                     17:    dd p { margin-top: 0; }
                     18:    dd dl + p { margin-top: 1em; }
                     19:    dd table + p { margin-top: 1em; }
                     20:    p + * > li, dd li { margin: 1em 0; }
                     21:    dt, dfn { font-weight: bold; font-style: normal; }
                     22:    dt dfn { font-style: italic; }
                     23:    pre, code { font-size: inherit; font-family: monospace; font-variant: normal; }
                     24:    pre strong { color: black; font: inherit; font-weight: bold; background: yellow; }
                     25:    pre em { font-weight: bolder; font-style: normal; }
                     26:    @media screen { code { color: orangered; } code :link, code :visited { color: inherit; } }
                     27:    var sub { vertical-align: bottom; font-size: smaller; position: relative; top: 0.1em; }
                     28:    table { border-collapse: collapse; border-style: hidden hidden none hidden; }
1.983     mike       29:    table thead, table tbody { border-bottom: solid; }
1.1       mike       30:    table tbody th:first-child { border-left: solid; }
1.475     mike       31:    table tbody th { text-align: left; }
1.1       mike       32:    table td, table th { border-left: solid; border-right: solid; border-bottom: solid thin; vertical-align: top; padding: 0.2em; }
                     33:    blockquote { margin: 0 0 0 2em; border: 0; padding: 0; font-style: italic; }
                     34: 
                     35:    .bad, .bad *:not(.XXX) { color: gray; border-color: gray; background: transparent; }
                     36:    .matrix, .matrix td { border: none; text-align: right; }
                     37:    .matrix { margin-left: 2em; }
                     38:    .dice-example { border-collapse: collapse; border-style: hidden solid solid hidden; border-width: thin; margin-left: 3em; }
                     39:    .dice-example caption { width: 30em; font-size: smaller; font-style: italic; padding: 0.75em 0; text-align: left; }
                     40:    .dice-example td, .dice-example th { border: solid thin; width: 1.35em; height: 1.05em; text-align: center; padding: 0; }
                     41: 
                     42:    .toc dfn, h1 dfn, h2 dfn, h3 dfn, h4 dfn, h5 dfn, h6 dfn { font: inherit; }
                     43:    img.extra { float: right; }
                     44:    pre.idl { border: solid thin; background: #EEEEEE; color: black; padding: 0.5em 1em; }
                     45:    pre.idl :link, pre.idl :visited { color: inherit; background: transparent; }
                     46:    pre.css { border: solid thin; background: #FFFFEE; color: black; padding: 0.5em 1em; }
                     47:    pre.css:first-line { color: #AAAA50; }
1.840     mike       48:    dl.domintro { color: green; margin: 2em 0 2em 2em; padding: 0.5em 1em; border: none; background: #DDFFDD; }
1.1       mike       49:    hr + dl.domintro, div.impl + dl.domintro { margin-top: 2.5em; margin-bottom: 1.5em; }
                     50:    dl.domintro dt, dl.domintro dt * { color: black; text-decoration: none; }
                     51:    dl.domintro dd { margin: 0.5em 0 1em 2em; padding: 0; }
                     52:    dl.domintro dd p { margin: 0.5em 0; }
                     53:    dl.switch { padding-left: 2em; }
                     54:    dl.switch > dt { text-indent: -1.5em; }
                     55:    dl.switch > dt:before { content: '\21AA'; padding: 0 0.5em 0 0; display: inline-block; width: 1em; text-align: right; line-height: 0.5em; }
                     56:    dl.triple { padding: 0 0 0 1em; }
                     57:    dl.triple dt, dl.triple dd { margin: 0; display: inline }
                     58:    dl.triple dt:after { content: ':'; }
                     59:    dl.triple dd:after { content: '\A'; white-space: pre; }
                     60:    .diff-old { text-decoration: line-through; color: silver; background: transparent; }
                     61:    .diff-chg, .diff-new { text-decoration: underline; color: green; background: transparent; }
                     62:    a .diff-new { border-bottom: 1px blue solid; }
                     63: 
                     64:    h2 { page-break-before: always; }
                     65:    h1, h2, h3, h4, h5, h6 { page-break-after: avoid; }
                     66:    h1 + h2, hr + h2.no-toc { page-break-before: auto; }
                     67: 
1.1016    mike       68:    p  > span:not([title=""]):not([class="XXX"]):not([class="impl"]):not([class="note"]),
                     69:    li > span:not([title=""]):not([class="XXX"]):not([class="impl"]):not([class="note"]), { border-bottom: solid #9999CC; }
1.1       mike       70: 
                     71:    div.head { margin: 0 0 1em; padding: 1em 0 0 0; }
                     72:    div.head p { margin: 0; }
                     73:    div.head h1 { margin: 0; }
                     74:    div.head .logo { float: right; margin: 0 1em; }
                     75:    div.head .logo img { border: none } /* remove border from top image */
                     76:    div.head dl { margin: 1em 0; }
1.671     mike       77:    div.head p.copyright, div.head p.alt { font-size: x-small; font-style: oblique; margin: 0; }
1.1       mike       78: 
                     79:    body > .toc > li { margin-top: 1em; margin-bottom: 1em; }
                     80:    body > .toc.brief > li { margin-top: 0.35em; margin-bottom: 0.35em; }
                     81:    body > .toc > li > * { margin-bottom: 0.5em; }
                     82:    body > .toc > li > * > li > * { margin-bottom: 0.25em; }
                     83:    .toc, .toc li { list-style: none; }
                     84: 
                     85:    .brief { margin-top: 1em; margin-bottom: 1em; line-height: 1.1; }
                     86:    .brief li { margin: 0; padding: 0; }
                     87:    .brief li p { margin: 0; padding: 0; }
                     88: 
                     89:    .category-list { margin-top: -0.75em; margin-bottom: 1em; line-height: 1.5; }
                     90:    .category-list::before { content: '\21D2\A0'; font-size: 1.2em; font-weight: 900; }
                     91:    .category-list li { display: inline; }
                     92:    .category-list li:not(:last-child)::after { content: ', '; }
                     93:    .category-list li > span, .category-list li > a { text-transform: lowercase; }
                     94:    .category-list li * { text-transform: none; } /* don't affect <code> nested in <a> */
                     95: 
                     96:    .XXX { color: #E50000; background: white; border: solid red; padding: 0.5em; margin: 1em 0; }
                     97:    .XXX > :first-child { margin-top: 0; }
                     98:    p .XXX { line-height: 3em; }
1.159     mike       99:    .annotation { border: solid thin black; background: #0C479D; color: white; position: relative; margin: 8px 0 20px 0; }
                    100:    .annotation:before { position: absolute; left: 0; top: 0; width: 100%; height: 100%; margin: 6px -6px -6px 6px; background: #333333; z-index: -1; content: ''; }
                    101:    .annotation :link, .annotation :visited { color: inherit; }
                    102:    .annotation :link:hover, .annotation :visited:hover { background: transparent; }
                    103:    .annotation span { border: none ! important; }
1.1       mike      104:    .note { color: green; background: transparent; font-family: sans-serif; }
                    105:    .warning { color: red; background: transparent; }
                    106:    .note, .warning { font-weight: bolder; font-style: italic; }
                    107:    p.note, div.note { padding: 0.5em 2em; }
                    108:    span.note { padding: 0 2em; }
                    109:    .note p:first-child, .warning p:first-child { margin-top: 0; }
                    110:    .note p:last-child, .warning p:last-child { margin-bottom: 0; }
                    111:    .warning:before { font-style: normal; }
                    112:    p.note:before { content: 'Note: '; }
                    113:    p.warning:before { content: '\26A0 Warning! '; }
                    114: 
                    115:    .bookkeeping:before { display: block; content: 'Bookkeeping details'; font-weight: bolder; font-style: italic; }
                    116:    .bookkeeping { font-size: 0.8em; margin: 2em 0; }
                    117:    .bookkeeping p { margin: 0.5em 2em; display: list-item; list-style: square; }
1.1006    mike      118:    .bookkeeping dt { margin: 0.5em 2em 0; }
                    119:    .bookkeeping dd { margin: 0 3em 0.5em; }
1.1       mike      120: 
                    121:    h4 { position: relative; z-index: 3; }
                    122:    h4 + .element, h4 + div + .element { margin-top: -2.5em; padding-top: 2em; }
                    123:    .element {
                    124:      background: #EEEEFF;
                    125:      color: black;
                    126:      margin: 0 0 1em 0.15em;
                    127:      padding: 0 1em 0.25em 0.75em;
                    128:      border-left: solid #9999FF 0.25em;
                    129:      position: relative;
                    130:      z-index: 1;
                    131:    }
                    132:    .element:before {
                    133:      position: absolute;
                    134:      z-index: 2;
                    135:      top: 0;
                    136:      left: -1.15em;
                    137:      height: 2em;
                    138:      width: 0.9em;
                    139:      background: #EEEEFF;
                    140:      content: ' ';
                    141:      border-style: none none solid solid;
                    142:      border-color: #9999FF;
                    143:      border-width: 0.25em;
                    144:    }
                    145: 
1.149     mike      146:    .example { display: block; color: #222222; background: #FCFCFC; border-left: double; margin-left: 2em; padding-left: 1em; }
                    147:    td > .example:only-child { margin: 0 0 0 0.1em; }
1.1       mike      148: 
                    149:    ul.domTree, ul.domTree ul { padding: 0 0 0 1em; margin: 0; }
                    150:    ul.domTree li { padding: 0; margin: 0; list-style: none; position: relative; }
                    151:    ul.domTree li li { list-style: none; }
                    152:    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; }
                    153:    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; }
                    154:    ul.domTree span { font-style: italic; font-family: serif; }
                    155:    ul.domTree .t1 code { color: purple; font-weight: bold; }
                    156:    ul.domTree .t2 { font-style: normal; font-family: monospace; }
                    157:    ul.domTree .t2 .name { color: black; font-weight: bold; }
                    158:    ul.domTree .t2 .value { color: blue; font-weight: normal; }
                    159:    ul.domTree .t3 code, .domTree .t4 code, .domTree .t5 code { color: gray; }
                    160:    ul.domTree .t7 code, .domTree .t8 code { color: green; }
                    161:    ul.domTree .t10 code { color: teal; }
                    162: 
1.736     mike      163:    body.dfnEnabled dfn { cursor: pointer; }
                    164:    .dfnPanel {
                    165:      display: inline;
                    166:      position: absolute;
                    167:      z-index: 10;
                    168:      height: auto;
                    169:      width: auto;
                    170:      padding: 0.5em 0.75em;
                    171:      font: small sans-serif, Droid Sans Fallback;
                    172:      background: #DDDDDD;
                    173:      color: black;
                    174:      border: outset 0.2em;
                    175:    }
                    176:    .dfnPanel * { margin: 0; padding: 0; font: inherit; text-indent: 0; }
                    177:    .dfnPanel :link, .dfnPanel :visited { color: black; }
                    178:    .dfnPanel p { font-weight: bolder; }
                    179:    .dfnPanel * + p { margin-top: 0.25em; }
                    180:    .dfnPanel li { list-style-position: inside; }
                    181: 
1.671     mike      182:    #configUI { position: absolute; z-index: 20; top: 10em; right: 1em; width: 11em; font-size: small; }
                    183:    #configUI p { margin: 0.5em 0; padding: 0.3em; background: #EEEEEE; color: black; border: inset thin; }
                    184:    #configUI p label { display: block; }
                    185:    #configUI #updateUI, #configUI .loginUI { text-align: center; }
                    186:    #configUI input[type=button] { display: block; margin: auto; }
1.1002    mike      187: 
1.1021  ! mike      188:    fieldset { margin: 1em; padding: 0.5em 1em; }
        !           189:    fieldset > legend + * { margin-top: 0; }
1.1013    mike      190:    fieldset > :last-child { margin-bottom: 0; }
1.1021  ! mike      191:    fieldset p { margin: 0.5em 0; }
        !           192: 
        !           193:    .stability {
        !           194:      position: fixed;
        !           195:      bottom: 0;
        !           196:      left: 0; right: 0;
        !           197:      margin: 0 auto 0 auto;
        !           198:      width: 50%;
        !           199:      background: maroon; color: yellow;
        !           200:      -webkit-border-radius: 1em 1em 0 0;
        !           201:      -moz-border-radius: 1em 1em 0 0;
        !           202:      border-radius: 1em 1em 0 0;
        !           203:      -moz-box-shadow: 0 0 1em #500;
        !           204:      -webkit-box-shadow: 0 0 1em #500;
        !           205:      box-shadow: 0 0 1em red;
        !           206:      padding: 0.5em 1em;
        !           207:      text-align: center;
        !           208:    }
        !           209:    .stability strong {
        !           210:      display: block;
        !           211:    }
        !           212:    .stability :link, .stability :visited,
        !           213:    .stability :link:hover, .stability :visited:hover {
        !           214:      background: transparent;
        !           215:      color: white;
        !           216:    }
1.1013    mike      217: 
1.267     mike      218:   </style><style type="text/css">
                    219: 
1.292     mike      220:    .applies thead th > * { display: block; }
                    221:    .applies thead code { display: block; }
                    222:    .applies tbody th { whitespace: nowrap; }
                    223:    .applies td { text-align: center; }
                    224:    .applies .yes { background: yellow; }
                    225: 
1.1007    mike      226:    .matrix, .matrix td { border: hidden; text-align: right; }
1.267     mike      227:    .matrix { margin-left: 2em; }
                    228: 
                    229:    .dice-example { border-collapse: collapse; border-style: hidden solid solid hidden; border-width: thin; margin-left: 3em; }
                    230:    .dice-example caption { width: 30em; font-size: smaller; font-style: italic; padding: 0.75em 0; text-align: left; }
                    231:    .dice-example td, .dice-example th { border: solid thin; width: 1.35em; height: 1.05em; text-align: center; padding: 0; }
                    232: 
1.1009    mike      233:    td.eg { border-width: thin; text-align: center; }
                    234: 
1.267     mike      235:    #table-example-1 { border: solid thin; border-collapse: collapse; margin-left: 3em; }
                    236:    #table-example-1 * { font-family: "Essays1743", serif; line-height: 1.01em; }
                    237:    #table-example-1 caption { padding-bottom: 0.5em; }
                    238:    #table-example-1 thead, #table-example-1 tbody { border: none; }
                    239:    #table-example-1 th, #table-example-1 td { border: solid thin; }
                    240:    #table-example-1 th { font-weight: normal; }
                    241:    #table-example-1 td { border-style: none solid; vertical-align: top; }
                    242:    #table-example-1 th { padding: 0.5em; vertical-align: middle; text-align: center; }
                    243:    #table-example-1 tbody tr:first-child td { padding-top: 0.5em; }
                    244:    #table-example-1 tbody tr:last-child td { padding-bottom: 1.5em; }
                    245:    #table-example-1 tbody td:first-child { padding-left: 2.5em; padding-right: 0; width: 9em; }
                    246:    #table-example-1 tbody td:first-child::after { content: leader(". "); }
                    247:    #table-example-1 tbody td { padding-left: 2em; padding-right: 2em; }
                    248:    #table-example-1 tbody td:first-child + td { width: 10em; }
                    249:    #table-example-1 tbody td:first-child + td ~ td { width: 2.5em; }
                    250:    #table-example-1 tbody td:first-child + td + td + td ~ td { width: 1.25em; }
                    251: 
                    252:    .apple-table-examples { border: none; border-collapse: separate; border-spacing: 1.5em 0em; width: 40em; margin-left: 3em; }
                    253:    .apple-table-examples * { font-family: "Times", serif; }
                    254:    .apple-table-examples td, .apple-table-examples th { border: none; white-space: nowrap; padding-top: 0; padding-bottom: 0; }
                    255:    .apple-table-examples tbody th:first-child { border-left: none; width: 100%; }
                    256:    .apple-table-examples thead th:first-child ~ th { font-size: smaller; font-weight: bolder; border-bottom: solid 2px; text-align: center; }
                    257:    .apple-table-examples tbody th::after, .apple-table-examples tfoot th::after { content: leader(". ") }
                    258:    .apple-table-examples tbody th, .apple-table-examples tfoot th { font: inherit; text-align: left; }
                    259:    .apple-table-examples td { text-align: right; vertical-align: top; }
                    260:    .apple-table-examples.e1 tbody tr:last-child td { border-bottom: solid 1px; }
                    261:    .apple-table-examples.e1 tbody + tbody tr:last-child td { border-bottom: double 3px; }
                    262:    .apple-table-examples.e2 th[scope=row] { padding-left: 1em; }
                    263:    .apple-table-examples sup { line-height: 0; }
                    264: 
1.724     mike      265:    .details-example img { vertical-align: top; }
                    266: 
1.882     mike      267:    #named-character-references-table {
1.1010    mike      268:      white-space: nowrap;
1.882     mike      269:      font-size: 0.6em;
1.1010    mike      270:      column-width: 30em;
1.882     mike      271:      column-gap: 1em;
1.1010    mike      272:      -moz-column-width: 30em;
1.882     mike      273:      -moz-column-gap: 1em;
1.1010    mike      274:      -webkit-column-width: 30em;
1.882     mike      275:      -webkit-column-gap: 1em;
                    276:    }
1.1010    mike      277:    #named-character-references-table > table > tbody > tr > td:first-child + td,
1.882     mike      278:    #named-character-references-table > table > tbody > tr > td:last-child { text-align: center; }
                    279:    #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; }
1.1010    mike      280:    #named-character-references-table > table > tbody > tr#entity-CounterClockwiseContourIntegral > td:first-child { font-size: 0.5em; }
1.882     mike      281: 
1.997     mike      282:    .glyph.control { color: red; }
                    283: 
1.999     mike      284:    @font-face {
                    285:      font-family: 'Essays1743';
                    286:      src: url('http://www.whatwg.org/specs/web-apps/current-work/fonts/Essays1743.ttf');
                    287:    }
                    288:    @font-face {
                    289:      font-family: 'Essays1743';
                    290:      font-weight: bold;
                    291:      src: url('http://www.whatwg.org/specs/web-apps/current-work/fonts/Essays1743-Bold.ttf');
                    292:    }
                    293:    @font-face {
                    294:      font-family: 'Essays1743';
                    295:      font-style: italic;
                    296:      src: url('http://www.whatwg.org/specs/web-apps/current-work/fonts/Essays1743-Italic.ttf');
                    297:    }
                    298:    @font-face {
                    299:      font-family: 'Essays1743';
                    300:      font-style: italic;
                    301:      font-weight: bold;
                    302:      src: url('http://www.whatwg.org/specs/web-apps/current-work/fonts/Essays1743-BoldItalic.ttf');
                    303:    }
                    304: 
1.872     mike      305:   </style><style type="text/css">
1.881     mike      306:    .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; }
                    307:   </style><link href="data:text/css," id="complete" rel="stylesheet" title="Complete specification"><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"><script type="text/javascript">
1.671     mike      308:    function getCookie(name) {
                    309:      var params = location.search.substr(1).split("&");
                    310:      for (var index = 0; index < params.length; index++) {
                    311:        if (params[index] == name)
                    312:          return "1";
                    313:        var data = params[index].split("=");
                    314:        if (data[0] == name)
                    315:          return unescape(data[1]);
                    316:      }
                    317:      var cookies = document.cookie.split("; ");
                    318:      for (var index = 0; index < cookies.length; index++) {
                    319:        var data = cookies[index].split("=");
                    320:        if (data[0] == name)
                    321:          return unescape(data[1]);
                    322:      }
                    323:      return null;
                    324:    }
                    325:    function load(script) {
                    326:      var e = document.createElement('script');
1.1021  ! mike      327:      e.setAttribute('src', script);
1.671     mike      328:      document.body.appendChild(e);
                    329:    }
                    330:    function init() {
                    331:      if (location.search == '?slow-browser')
                    332:        return;
                    333:      var configUI = document.createElement('div');
                    334:      configUI.id = 'configUI';
                    335:      document.body.appendChild(configUI);
                    336:      // load('reviewer.js'); // would need cross-site XHR
                    337:      if (document.getElementById('head'))
                    338:        load('toc.js');
                    339:      load('styler.js');
                    340:      // load('updater.js'); // would need cross-site XHR
1.724     mike      341:      load('dfn.js'); // doesn't support split-out specs, but, oh well.
1.671     mike      342:      // load('status.js'); // would need cross-site XHR
                    343:      if (getCookie('profile') == '1')
                    344:        document.getElementsByTagName('h2')[0].textContent += '; load: ' + (new Date() - loadTimer) + 'ms';
                    345:      fixBrokenLink();
                    346:    }
1.1021  ! mike      347:   </script><link href="http://www.w3.org/StyleSheets/TR/W3C-WD" rel="stylesheet" type="text/css">
1.996     mike      348:   <script src="link-fixup.js"></script>
1.1014    mike      349:   <link href="dnd.html" title="7.7 Drag and drop" rel="prev">
1.2       mike      350:   <link href="spec.html#contents" title="Table of contents" rel="index">
1.996     mike      351:   <link href="parsing.html" title="8.2 Parsing HTML documents" rel="next">
1.671     mike      352:   </head><body onload="fixBrokenLink(); init()"><div class="head" id="head">
1.1       mike      353:    <p><a href="http://www.w3.org/"><img alt="W3C" height="48" src="http://www.w3.org/Icons/w3c_home" width="72"></a></p>
1.998     mike      354: 
1.183     mike      355:    <h1>HTML5</h1>
1.874     mike      356:    </div><div>
1.1014    mike      357:    <a href="dnd.html">&#8592; 7.7 Drag and drop</a> &#8211;
1.2       mike      358:    <a href="spec.html#contents">Table of contents</a> &#8211;
1.996     mike      359:    <a href="parsing.html">8.2 Parsing HTML documents &#8594;</a>
                    360:   <ol class="toc"><li><a href="syntax.html#syntax"><span class="secno">8 </span>The HTML syntax</a>
                    361:   <ol><li><a href="syntax.html#writing"><span class="secno">8.1 </span>Writing HTML documents</a>
                    362:     <ol><li><a href="syntax.html#the-doctype"><span class="secno">8.1.1 </span>The DOCTYPE</a></li><li><a href="syntax.html#elements-0"><span class="secno">8.1.2 </span>Elements</a>
                    363:       <ol><li><a href="syntax.html#start-tags"><span class="secno">8.1.2.1 </span>Start tags</a></li><li><a href="syntax.html#end-tags"><span class="secno">8.1.2.2 </span>End tags</a></li><li><a href="syntax.html#attributes-0"><span class="secno">8.1.2.3 </span>Attributes</a></li><li><a href="syntax.html#optional-tags"><span class="secno">8.1.2.4 </span>Optional tags</a></li><li><a href="syntax.html#element-restrictions"><span class="secno">8.1.2.5 </span>Restrictions on content models</a></li><li><a href="syntax.html#cdata-rcdata-restrictions"><span class="secno">8.1.2.6 </span>Restrictions on the contents of raw text and RCDATA elements</a></li></ol></li><li><a href="syntax.html#text-0"><span class="secno">8.1.3 </span>Text</a>
                    364:       <ol><li><a href="syntax.html#newlines"><span class="secno">8.1.3.1 </span>Newlines</a></li></ol></li><li><a href="syntax.html#character-references"><span class="secno">8.1.4 </span>Character references</a></li><li><a href="syntax.html#cdata-sections"><span class="secno">8.1.5 </span>CDATA sections</a></li><li><a href="syntax.html#comments"><span class="secno">8.1.6 </span>Comments</a></li></ol></li></ol></li></ol></div>
1.1       mike      365: 
1.755     mike      366:   <h2 id="syntax"><span class="secno">8 </span><dfn>The HTML syntax</dfn></h2><p class="note">This section only describes the rules for resources
1.725     mike      367:   labeled with an <a href="infrastructure.html#html-mime-type">HTML MIME type</a>. Rules for XML resources
                    368:   are discussed in the section below entitled "<a href="the-xhtml-syntax.html#the-xhtml-syntax">The XHTML
1.1008    mike      369:   syntax</a>".</p><h3 id="writing"><span class="secno">8.1 </span>Writing HTML documents</h3><div class="impl">
1.1       mike      370: 
                    371:   <p><i>This section only applies to documents, authoring tools, and
                    372:   markup generators. In particular, it does not apply to conformance
                    373:   checkers; conformance checkers must use the requirements given in
                    374:   the next section ("parsing HTML documents").</i></p>
                    375: 
1.123     mike      376:   </div><p>Documents must consist of the following parts, in the given
                    377:   order:</p><ol><li>Optionally, a single U+FEFF BYTE ORDER MARK (BOM) character.</li>
1.1       mike      378: 
                    379:    <li>Any number of <a href="#syntax-comments" title="syntax-comments">comments</a> and
1.996     mike      380:    <a href="common-microsyntaxes.html#space-character" title="space character">space characters</a>.</li>
1.1       mike      381: 
                    382:    <li>A <a href="#syntax-doctype" title="syntax-doctype">DOCTYPE</a>.
                    383: 
                    384:    </li><li>Any number of <a href="#syntax-comments" title="syntax-comments">comments</a> and
1.996     mike      385:    <a href="common-microsyntaxes.html#space-character" title="space character">space characters</a>.</li>
1.1       mike      386: 
1.159     mike      387:    <li>The root element, in the form of an <code><a href="semantics.html#the-html-element-0">html</a></code> <a href="#syntax-elements" title="syntax-elements">element</a>.</li>
1.1       mike      388: 
                    389:    <li>Any number of <a href="#syntax-comments" title="syntax-comments">comments</a> and
1.996     mike      390:    <a href="common-microsyntaxes.html#space-character" title="space character">space characters</a>.</li>
1.1       mike      391: 
                    392:   </ol><p>The various types of content mentioned above are described in the
1.123     mike      393:   next few sections.</p><p>In addition, there are some restrictions on how <a href="semantics.html#character-encoding-declaration" title="character encoding declaration">character encoding
1.1       mike      394:   declarations</a> are to be serialized, as discussed in the
1.123     mike      395:   section on that topic.</p><div class="note">
1.1       mike      396: 
1.159     mike      397:    <p>Space characters before the root <code><a href="semantics.html#the-html-element-0">html</a></code> element, and
                    398:    space characters at the start of the <code><a href="semantics.html#the-html-element-0">html</a></code> element and
                    399:    before the <code><a href="semantics.html#the-head-element-0">head</a></code> element, will be dropped when the
1.1       mike      400:    document is parsed; space characters <em>after</em> the root
1.159     mike      401:    <code><a href="semantics.html#the-html-element-0">html</a></code> element will be parsed as if they were at the end
1.996     mike      402:    of the <code><a href="sections.html#the-body-element-0">body</a></code> element. Thus, space characters around the
1.1       mike      403:    root element do not round-trip.</p>
                    404: 
                    405:    <p>It is suggested that newlines be inserted after the DOCTYPE,
                    406:    after any comments that are before the root element, after the
1.159     mike      407:    <code><a href="semantics.html#the-html-element-0">html</a></code> element's start tag (if it is not <a href="#syntax-tag-omission" title="syntax-tag-omission">omitted</a>), and after any comments
                    408:    that are inside the <code><a href="semantics.html#the-html-element-0">html</a></code> element but before the
                    409:    <code><a href="semantics.html#the-head-element-0">head</a></code> element.</p>
1.1       mike      410: 
1.123     mike      411:   </div><p>Many strings in the HTML syntax (e.g. the names of elements and
1.1       mike      412:   their attributes) are case-insensitive, but only for characters in
1.547     mike      413:   the ranges U+0041 to U+005A (LATIN CAPITAL LETTER A to LATIN CAPITAL
                    414:   LETTER Z) and U+0061 to U+007A (LATIN SMALL LETTER A to LATIN SMALL
1.1       mike      415:   LETTER Z). For convenience, in this section this is just referred to
1.1008    mike      416:   as "case-insensitive".</p><h4 id="the-doctype"><span class="secno">8.1.1 </span>The DOCTYPE</h4><p class="XXX annotation"><span><a href="http://www.w3.org/html/wg/tracker/issues/4">ISSUE-4</a> (html-versioning) and <a href="http://www.w3.org/html/wg/tracker/issues/84">ISSUE-84</a> (legacy-doctypes) block progress to Last Call</span></p><p>A <dfn id="syntax-doctype" title="syntax-doctype">DOCTYPE</dfn> is a <!-- mostly
1.884     mike      417:   useless but nonetheless --> required preamble.</p><p class="note">DOCTYPEs are required for legacy reasons. When
1.1       mike      418:   omitted, browsers tend to use a different rendering mode that is
                    419:   incompatible with some specifications. Including the DOCTYPE in a
                    420:   document ensures that the browser makes a best-effort attempt at
1.123     mike      421:   following the relevant specifications.</p><p>A DOCTYPE must consist of the following characters, in this
1.882     mike      422:   order:</p><ol class="brief"><li>A string that is an <a href="infrastructure.html#ascii-case-insensitive">ASCII case-insensitive</a> match for the string "<code title="">&lt;!DOCTYPE</code>".</li>
1.996     mike      423:    <li>One or more <a href="common-microsyntaxes.html#space-character" title="space character">space characters</a>.</li>
1.1011    mike      424:    <li>A string that is an <a href="infrastructure.html#ascii-case-insensitive">ASCII case-insensitive</a> match for the string "<code title="">html</code>".</li>
1.861     mike      425:    <li>Optionally, a <a href="#doctype-legacy-string">DOCTYPE legacy string</a> or an <a href="#obsolete-permitted-doctype-string">obsolete permitted DOCTYPE string</a> (defined below).</li>
1.996     mike      426:    <li>Zero or more <a href="common-microsyntaxes.html#space-character" title="space character">space characters</a>.</li>
1.588     mike      427:    <li>A U+003E GREATER-THAN SIGN character (&gt;).</li>
1.1011    mike      428:   </ol><p class="note">In other words, <code>&lt;!DOCTYPE html&gt;</code>,
1.861     mike      429:   case-insensitively.</p><hr><p>For the purposes of HTML generators that cannot output HTML
1.1       mike      430:   markup with the short DOCTYPE "<code title="">&lt;!DOCTYPE
1.1011    mike      431:   html&gt;</code>", a <dfn id="doctype-legacy-string">DOCTYPE legacy string</dfn> may be inserted
1.1       mike      432:   into the DOCTYPE (in the position defined above). This string must
1.996     mike      433:   consist of:</p><ol class="brief"><li>One or more <a href="common-microsyntaxes.html#space-character" title="space character">space characters</a>.</li>
1.1       mike      434:    <li>A string that is an <a href="infrastructure.html#ascii-case-insensitive">ASCII case-insensitive</a> match for the string "<code title="">SYSTEM</code>".</li>
1.996     mike      435:    <li>One or more <a href="common-microsyntaxes.html#space-character" title="space character">space characters</a>.</li>
1.1       mike      436:    <li>A U+0022 QUOTATION MARK or U+0027 APOSTROPHE character (the <i>quote mark</i>).</li>
1.996     mike      437:    <li>The literal string "<code><a href="urls.html#about:legacy-compat">about:legacy-compat</a></code>".</li>
1.856     mike      438:    <li>A matching U+0022 QUOTATION MARK or U+0027 APOSTROPHE character (i.e. the same character as in the earlier step labeled <i>quote mark</i>).</li>
1.1011    mike      439:   </ol><p class="note">In other words, <code>&lt;!DOCTYPE html SYSTEM
                    440:   "about:legacy-compat"&gt;</code> or <code>&lt;!DOCTYPE html SYSTEM
1.1004    mike      441:   'about:legacy-compat'&gt;</code>, case-insensitively except for the
                    442:   part in single or double quotes.</p><p>The <a href="#doctype-legacy-string">DOCTYPE legacy string</a> should not be used unless
1.1       mike      443:   the document is generated from a system that cannot output the
1.861     mike      444:   shorter string.</p><hr><!-- see the parser section before changing this bit --><p>To help authors transition from HTML4 and XHTML1, an
                    445:   <dfn id="obsolete-permitted-doctype-string">obsolete permitted DOCTYPE string</dfn> can be inserted into
                    446:   the DOCTYPE (in the position defined above). This string must
1.996     mike      447:   consist of:</p><ol class="brief"><li>One or more <a href="common-microsyntaxes.html#space-character" title="space character">space characters</a>.</li>
1.861     mike      448:    <li>A string that is an <a href="infrastructure.html#ascii-case-insensitive">ASCII case-insensitive</a> match for the string "<code title="">PUBLIC</code>".</li>
1.996     mike      449:    <li>One or more <a href="common-microsyntaxes.html#space-character" title="space character">space characters</a>.</li>
1.861     mike      450:    <li>A U+0022 QUOTATION MARK or U+0027 APOSTROPHE character (the <i>first quote mark</i>).</li>
                    451:    <li>The string from one of the cells in the first column of the table below. The row to which this cell belongs is the <i>selected row</i>.</li>
                    452:    <li>A matching U+0022 QUOTATION MARK or U+0027 APOSTROPHE character (i.e. the same character as in the earlier step labeled <i>first quote mark</i>).</li>
1.996     mike      453:    <li>If the cell in the second column of the <i>selected row</i> is not blank, one or more <a href="common-microsyntaxes.html#space-character" title="space character">space characters</a>.</li>
1.861     mike      454:    <li>If the cell in the second column of the <i>selected row</i> is not blank, a U+0022 QUOTATION MARK or U+0027 APOSTROPHE character (the <i>third quote mark</i>).</li>
                    455:    <li>If the cell in the second column of the <i>selected row</i> is not blank, the string from the cell in the second column of the <i>selected row</i>.</li>
                    456:    <li>If the cell in the second column of the <i>selected row</i> is not blank, a matching U+0022 QUOTATION MARK or U+0027 APOSTROPHE character (i.e. the same character as in the earlier step labeled <i>third quote mark</i>).</li>
                    457:   </ol><table><caption>
                    458:     Allowed values for public and system identifiers in an <a href="#obsolete-permitted-doctype-string">obsolete permitted DOCTYPE string</a>.
                    459:    </caption>
                    460:    <thead><tr><th> Public identifier
                    461:      </th><th> System identifier
                    462:    </th></tr></thead><tbody><tr><td> <code title="">-//W3C//DTD&#160;HTML&#160;4.0//EN</code>
                    463:      </td><td>
                    464:     </td></tr><tr><td> <code title="">-//W3C//DTD&#160;HTML&#160;4.0//EN</code>
                    465:      </td><td> <code title="">http://www.w3.org/TR/REC-html40/strict.dtd</code>
                    466:     </td></tr><tr><td> <code title="">-//W3C//DTD&#160;HTML&#160;4.01//EN</code>
                    467:      </td><td>
                    468:     </td></tr><tr><td> <code title="">-//W3C//DTD&#160;HTML&#160;4.01//EN</code>
                    469:      </td><td> <code title="">http://www.w3.org/TR/html4/strict.dtd</code>
                    470:     </td></tr><tr><td> <code title="">-//W3C//DTD&#160;XHTML&#160;1.0&#160;Strict//EN</code>
                    471:      </td><td> <code title="">http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd</code>
                    472:     </td></tr><tr><td> <code title="">-//W3C//DTD&#160;XHTML&#160;1.1//EN</code>
                    473:      </td><td> <code title="">http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd</code>
                    474:   </td></tr></tbody></table><p>A <a href="#syntax-doctype" title="syntax-doctype">DOCTYPE</a> containing an
                    475:   <a href="#obsolete-permitted-doctype-string">obsolete permitted DOCTYPE string</a> is an <dfn id="obsolete-permitted-doctype">obsolete
                    476:   permitted DOCTYPE</dfn>. Authors should not use <a href="#obsolete-permitted-doctype" title="obsolete permitted DOCTYPE">obsolete permitted
1.1008    mike      477:   DOCTYPEs</a>, as they are unnecessarily long.</p><h4 id="elements-0"><span class="secno">8.1.2 </span>Elements</h4><p>There are five different kinds of <dfn id="syntax-elements" title="syntax-elements">elements</dfn>: <a href="#void-elements">void elements</a>,
1.373     mike      478:   <a href="#raw-text-elements">raw text elements</a>, <a href="#rcdata-elements">RCDATA elements</a>,
                    479:   <a href="#foreign-elements">foreign elements</a>, and <a href="#normal-elements">normal elements</a>.</p><dl><dt><dfn id="void-elements">Void elements</dfn></dt>
1.1       mike      480: 
1.996     mike      481:    <dd><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="text-level-semantics.html#the-br-element">br</a></code>,
                    482:    <code><a href="tabular-data.html#the-col-element">col</a></code>, <code><a href="interactive-elements.html#the-command">command</a></code>, <code><a href="the-iframe-element.html#the-embed-element">embed</a></code>,
                    483:    <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>,
                    484:    <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#meta">meta</a></code>,
1.1015    mike      485:    <code><a href="the-iframe-element.html#the-param-element">param</a></code>, <code><a href="video.html#the-source-element">source</a></code>, <code><a href="video.html#the-track-element">track</a></code>,
1.973     mike      486:    <code><a href="text-level-semantics.html#the-wbr-element">wbr</a></code></dd>
1.1       mike      487: 
1.373     mike      488:    <dt><dfn id="raw-text-elements">Raw text elements</dfn></dt>
1.1       mike      489: 
1.996     mike      490:    <dd><code><a href="scripting-1.html#script">script</a></code>, <code><a href="semantics.html#the-style-element">style</a></code></dd> <!-- iframe and
1.91      mike      491:    noscript don't count as raw text for syntax purposes -->
1.1       mike      492: 
1.373     mike      493:    <dt><dfn id="rcdata-elements">RCDATA elements</dfn></dt>
1.1       mike      494: 
1.996     mike      495:    <dd><code><a href="the-button-element.html#the-textarea-element">textarea</a></code>, <code><a href="semantics.html#the-title-element-0">title</a></code></dd>
1.1       mike      496: 
1.373     mike      497:    <dt><dfn id="foreign-elements">Foreign elements</dfn></dt>
1.1       mike      498: 
1.996     mike      499:    <dd>Elements from the <a href="namespaces.html#mathml-namespace">MathML namespace</a>
                    500:    and the <a href="namespaces.html#svg-namespace">SVG namespace</a>.</dd>
1.1       mike      501: 
1.373     mike      502:    <dt><dfn id="normal-elements">Normal elements</dfn></dt>
1.1       mike      503: 
                    504:    <dd>All other allowed <a href="infrastructure.html#html-elements">HTML elements</a> are normal
                    505:    elements.</dd>
                    506: 
                    507:   </dl><p><dfn id="syntax-tags" title="syntax-tags">Tags</dfn> are used to delimit the start
1.373     mike      508:   and end of elements in the markup. <a href="#raw-text-elements" title="raw text
                    509:   elements">Raw text</a>, <a href="#rcdata-elements" title="RCDATA
                    510:   elements">RCDATA</a>, and <a href="#normal-elements" title="normal
                    511:   elements">normal</a> elements have a <a href="#syntax-start-tag" title="syntax-start-tag">start tag</a> to indicate where they
                    512:   begin, and an <a href="#syntax-end-tag" title="syntax-end-tag">end tag</a> to
                    513:   indicate where they end. The start and end tags of certain
                    514:   <a href="#normal-elements">normal elements</a> can be <a href="#syntax-tag-omission" title="syntax-tag-omission">omitted</a>, as described
1.1       mike      515:   later. Those that cannot be omitted must not be omitted. <a href="#void-elements">Void
                    516:   elements</a> only have a start tag; end tags must not be
1.373     mike      517:   specified for <a href="#void-elements">void elements</a>. <a href="#foreign-elements">Foreign
                    518:   elements</a> must either have a start tag and an end tag, or a
                    519:   start tag that is marked as self-closing, in which case they must
                    520:   not have an end tag.</p><p>The contents of the element must be placed between just after the
1.1       mike      521:   start tag (which <a href="#syntax-tag-omission" title="syntax-tag-omission">might be implied,
                    522:   in certain cases</a>) and just before the end tag (which again,
                    523:   <a href="#syntax-tag-omission" title="syntax-tag-omission">might be implied in certain
                    524:   cases</a>). The exact allowed contents of each individual element
1.1004    mike      525:   depend on the content model of that element, as described earlier in
                    526:   this specification. Elements must not contain content that their
1.1       mike      527:   content model disallows. In addition to the restrictions placed on
                    528:   the contents by those content models, however, the five types of
1.123     mike      529:   elements have additional <em>syntactic</em> requirements.</p><p><a href="#void-elements">Void elements</a> can't have any contents (since there's
1.1       mike      530:   no end tag, no content can be put between the start tag and the end
1.373     mike      531:   tag).</p><p><a href="#raw-text-elements">Raw text elements</a> can have <a href="#syntax-text" title="syntax-text">text</a>, though it has <a href="#cdata-rcdata-restrictions">restrictions</a> described
                    532:   below.</p><p><a href="#rcdata-elements">RCDATA elements</a> can have <a href="#syntax-text" title="syntax-text">text</a> and <a href="#syntax-charref" title="syntax-charref">character references</a>, but the text
                    533:   must not contain an <a href="#syntax-ambiguous-ampersand" title="syntax-ambiguous-ampersand">ambiguous ampersand</a>.
1.1       mike      534:   There are also <a href="#cdata-rcdata-restrictions">further
1.373     mike      535:   restrictions</a> described below.</p><p><a href="#foreign-elements">Foreign elements</a> whose start tag is marked as
                    536:   self-closing can't have any contents (since, again, as there's no
                    537:   end tag, no content can be put between the start tag and the end
                    538:   tag). <a href="#foreign-elements">Foreign elements</a> whose start tag is <em>not</em>
                    539:   marked as self-closing can have <a href="#syntax-text" title="syntax-text">text</a>, <a href="#syntax-charref" title="syntax-charref">character references</a>, <a href="#syntax-cdata" title="syntax-cdata">CDATA sections</a>, other <a href="#syntax-elements" title="syntax-elements">elements</a>, and <a href="#syntax-comments" title="syntax-comments">comments</a>, but the text must not
1.588     mike      540:   contain the character U+003C LESS-THAN SIGN (&lt;) or an <a href="#syntax-ambiguous-ampersand" title="syntax-ambiguous-ampersand">ambiguous ampersand</a>.</p><div class="note">
1.374     mike      541: 
                    542:    <p>The HTML syntax does not support namespace
                    543:    declarations, even in <a href="#foreign-elements">foreign elements</a>.</p>
                    544: 
                    545:    <p>For instance, consider the following HTML fragment:</p>
                    546: 
                    547:    <pre>&lt;p&gt;
                    548:  &lt;svg&gt;
                    549:   &lt;metadata&gt;
                    550:    &lt;!-- this is invalid --&gt;
                    551:    &lt;cdr:license xmlns:cdr="http://www.example.com/cdr/metadata" name="MIT"/&gt;
                    552:   &lt;/metadata&gt;
                    553:  &lt;/svg&gt;
                    554: &lt;/p&gt;</pre>
                    555: 
                    556:    <p>The innermost element, <code title="">cdr:license</code>, is
                    557:    actually in the SVG namespace, as the "<code title="">xmlns:cdr</code>" attribute has no effect (unlike in
                    558:    XML). In fact, as the comment in the fragment above says, the
                    559:    fragment is actually non-conforming. This is because the SVG
                    560:    specification does not define any elements called "<code title="">cdr:license</code>" in the SVG namespace.</p>
                    561: 
                    562:   </div><p><a href="#normal-elements">Normal elements</a> can have <a href="#syntax-text" title="syntax-text">text</a>, <a href="#syntax-charref" title="syntax-charref">character references</a>, other <a href="#syntax-elements" title="syntax-elements">elements</a>, and <a href="#syntax-comments" title="syntax-comments">comments</a>, but the text must not
1.588     mike      563:   contain the character U+003C LESS-THAN SIGN (&lt;) or an <a href="#syntax-ambiguous-ampersand" title="syntax-ambiguous-ampersand">ambiguous ampersand</a>. Some
                    564:   <a href="#normal-elements">normal elements</a> also have <a href="#element-restrictions">yet more restrictions</a> on what
1.1       mike      565:   content they are allowed to hold, beyond the restrictions imposed by
                    566:   the content model and those described in this paragraph. Those
1.123     mike      567:   restrictions are described below.</p><p>Tags contain a <dfn id="syntax-tag-name" title="syntax-tag-name">tag name</dfn>,
1.1       mike      568:   giving the element's name. HTML elements all have names that only
1.464     mike      569:   use characters in the range U+0030 DIGIT ZERO (0) to U+0039 DIGIT
                    570:   NINE (9), U+0061 LATIN SMALL LETTER A to U+007A LATIN SMALL LETTER
                    571:   Z, and U+0041 LATIN CAPITAL LETTER A to U+005A LATIN CAPITAL LETTER
                    572:   Z. In the HTML syntax, tag names, even those for <a href="#foreign-elements">foreign
1.462     mike      573:   elements</a>, may be written with any mix of lower- and uppercase
                    574:   letters that, when converted to all-lowercase, matches the element's
1.1008    mike      575:   tag name; tag names are case-insensitive.</p><h5 id="start-tags"><span class="secno">8.1.2.1 </span>Start tags</h5><p><dfn id="syntax-start-tag" title="syntax-start-tag">Start tags</dfn> must have the
1.123     mike      576:   following format:</p><ol><li>The first character of a start tag must be a U+003C LESS-THAN
1.588     mike      577:    SIGN character (&lt;).</li>
1.1       mike      578: 
                    579:    <li>The next few characters of a start tag must be the element's
                    580:    <a href="#syntax-tag-name" title="syntax-tag-name">tag name</a>.</li>
                    581: 
                    582:    <li>If there are to be any attributes in the next step, there must
1.996     mike      583:    first be one or more <a href="common-microsyntaxes.html#space-character" title="space character">space
1.1       mike      584:    characters</a>.</li>
                    585: 
                    586:    <li>Then, the start tag may have a number of attributes, the <a href="#syntax-attributes" title="syntax-attributes">syntax for which</a> is described
1.1004    mike      587:    below. Attributes must be separated from each other by one or more
1.996     mike      588:    <a href="common-microsyntaxes.html#space-character" title="space character">space characters</a>.</li>
1.1       mike      589: 
1.766     mike      590:    <li>After the attributes, or after the <a href="#syntax-tag-name" title="syntax-tag-name">tag name</a> if there are no attributes,
1.996     mike      591:    there may be one or more <a href="common-microsyntaxes.html#space-character" title="space character">space
1.766     mike      592:    characters</a>. (Some attributes are required to be followed by
                    593:    a space. See the <a href="#syntax-attributes" title="syntax-attributes">attributes
                    594:    section</a> below.)</li>
1.1       mike      595: 
                    596:    <li>Then, if the element is one of the <a href="#void-elements">void elements</a>,
1.373     mike      597:    or if the element is a <a href="#foreign-elements" title="foreign elements">foreign
1.588     mike      598:    element</a>, then there may be a single U+002F SOLIDUS character
                    599:    (/). This character has no effect on <a href="#void-elements">void elements</a>,
                    600:    but on <a href="#foreign-elements">foreign elements</a> it marks the start tag as
                    601:    self-closing.</li>
1.1       mike      602: 
                    603:    <li>Finally, start tags must be closed by a U+003E GREATER-THAN
1.588     mike      604:    SIGN character (&gt;).</li>
1.1       mike      605: 
1.1008    mike      606:   </ol><h5 id="end-tags"><span class="secno">8.1.2.2 </span>End tags</h5><p><dfn id="syntax-end-tag" title="syntax-end-tag">End tags</dfn> must have the
1.123     mike      607:   following format:</p><ol><li>The first character of an end tag must be a U+003C LESS-THAN
1.588     mike      608:    SIGN character (&lt;).</li>
1.1       mike      609: 
                    610:    <li>The second character of an end tag must be a U+002F SOLIDUS
1.588     mike      611:    character (/).</li>
1.1       mike      612: 
                    613:    <li>The next few characters of an end tag must be the element's
                    614:    <a href="#syntax-tag-name" title="syntax-tag-name">tag name</a>.</li>
                    615: 
1.996     mike      616:    <li>After the tag name, there may be one or more <a href="common-microsyntaxes.html#space-character" title="space
1.1       mike      617:    character">space characters</a>.</li>
                    618: 
1.588     mike      619:    <li>Finally, end tags must be closed by a U+003E GREATER-THAN SIGN
                    620:    character (&gt;).</li>
1.1       mike      621: 
1.1008    mike      622:   </ol><h5 id="attributes-0"><span class="secno">8.1.2.3 </span>Attributes</h5><p><dfn id="syntax-attributes" title="syntax-attributes">Attributes</dfn> for an element
1.123     mike      623:   are expressed inside the element's start tag.</p><p>Attributes have a name and a value. <dfn id="syntax-attribute-name" title="syntax-attribute-name">Attribute names</dfn> must consist of
1.996     mike      624:   one or more characters other than the <a href="common-microsyntaxes.html#space-character" title="space
1.1       mike      625:   character">space characters</a>, U+0000 NULL, U+0022 QUOTATION
                    626:   MARK ("), U+0027 APOSTROPHE ('), U+003E GREATER-THAN SIGN
                    627:   (&gt;), U+002F SOLIDUS (/), and U+003D EQUALS SIGN (=) characters,
                    628:   the control characters, and any characters that are not defined by
1.462     mike      629:   Unicode. In the HTML syntax, attribute names, even those for
                    630:   <a href="#foreign-elements">foreign elements</a>, may be written with any mix of lower-
                    631:   and uppercase letters that are an <a href="infrastructure.html#ascii-case-insensitive">ASCII
1.123     mike      632:   case-insensitive</a> match for the attribute's name.</p><p><dfn id="syntax-attribute-value" title="syntax-attribute-value">Attribute values</dfn> are a
1.1       mike      633:   mixture of <a href="#syntax-text" title="syntax-text">text</a> and <a href="#syntax-charref" title="syntax-charref">character references</a>, except with the
1.123     mike      634:   additional restriction that the text cannot contain an <a href="#syntax-ambiguous-ampersand" title="syntax-ambiguous-ampersand">ambiguous ampersand</a>.</p><p>Attributes can be specified in four different ways:</p><dl><dt>Empty attribute syntax</dt>
1.1       mike      635: 
                    636:    <dd>
                    637: 
                    638:     <p>Just the <a href="#syntax-attribute-name" title="syntax-attribute-name">attribute
1.837     mike      639:     name</a>. The value is implicitly the empty string.</p>
1.1       mike      640: 
                    641:     <div class="example">
                    642: 
1.996     mike      643:      <p>In the following example, the <code title="attr-fe-disabled"><a href="association-of-controls-and-forms.html#attr-fe-disabled">disabled</a></code> attribute is given with
1.1       mike      644:      the empty attribute syntax:</p>
                    645: 
                    646:      <pre>&lt;input <em>disabled</em>&gt;</pre>
                    647: 
                    648:     </div>
                    649: 
                    650:     <p>If an attribute using the empty attribute syntax is to be
1.996     mike      651:     followed by another attribute, then there must be a <a href="common-microsyntaxes.html#space-character">space
1.1       mike      652:     character</a> separating the two.</p>
                    653: 
                    654:    </dd>
                    655: 
1.2       mike      656:    <dt id="unquoted">Unquoted attribute value syntax</dt>
1.1       mike      657: 
                    658:    <dd>
                    659: 
                    660:     <p>The <a href="#syntax-attribute-name" title="syntax-attribute-name">attribute name</a>,
1.996     mike      661:     followed by zero or more <a href="common-microsyntaxes.html#space-character" title="space character">space
1.1       mike      662:     characters</a>, followed by a single U+003D EQUALS SIGN
1.996     mike      663:     character, followed by zero or more <a href="common-microsyntaxes.html#space-character" title="space
1.1       mike      664:     character">space characters</a>, followed by the <a href="#syntax-attribute-value" title="syntax-attribute-value">attribute value</a>, which, in
                    665:     addition to the requirements given above for attribute values,
1.996     mike      666:     must not contain any literal <a href="common-microsyntaxes.html#space-character" title="space character">space
1.588     mike      667:     characters</a>, any U+0022 QUOTATION MARK characters ("),
                    668:     U+0027 APOSTROPHE characters ('), U+003D EQUALS SIGN
                    669:     characters (=), U+003C LESS-THAN SIGN characters (&lt;), U+003E
                    670:     GREATER-THAN SIGN characters (&gt;), or U+0060 GRAVE ACCENT
                    671:     characters (`), and must not be the empty string.</p>
1.463     mike      672: 
                    673:     <!-- The ` character is in this list on a temporary basis, waiting
1.1003    mike      674:          for IE to fix its parsing bug whereby it treats ` as an
1.463     mike      675:          attribute value delimiter. Otherwise, escaping software that
                    676:          tries to be clever and not use quotes when it doesn't need to
                    677:          could be tricked by an attacker.
                    678: 
                    679:          Posit a site that allows the user to input text that is used
                    680:          verbatim in two attributes, such that the user can set the
                    681:          first attribute's value to:
                    682: 
                    683:             `
                    684: 
                    685:          ...and the second to:
                    686: 
                    687:             ` onload='...payload...' end=x
                    688: 
                    689:          ...with the assumption that the site is going to not quote
                    690:          the first one, and quote the second one with double quotes:
                    691: 
                    692:             <body title=` class="` onload='...payload...' end=x">
                    693: 
                    694:          In IE, this is treated as:
                    695: 
                    696:             <body title=' class="'
                    697:                   onload='...payload...'
                    698:                   end='x"'>
                    699: 
                    700:     -->
                    701: 
1.1       mike      702: 
                    703:     <div class="example">
                    704: 
1.996     mike      705:      <p>In the following example, the <code title="attr-input-value"><a href="the-input-element.html#attr-input-value">value</a></code> attribute is given
1.1       mike      706:      with the unquoted attribute value syntax:</p>
                    707: 
                    708:      <pre>&lt;input <em>value=yes</em>&gt;</pre>
                    709: 
                    710:     </div>
                    711: 
                    712:     <p>If an attribute using the unquoted attribute syntax is to be
1.101     mike      713:     followed by another attribute or by the optional U+002F SOLIDUS
1.464     mike      714:     character (/) allowed in step 6 of the <a href="#syntax-start-tag" title="syntax-start-tag">start tag</a> syntax above, then there
1.996     mike      715:     must be a <a href="common-microsyntaxes.html#space-character">space character</a> separating the two.</p>
1.1       mike      716: 
                    717:    </dd>
                    718: 
                    719:    <dt>Single-quoted attribute value syntax</dt>
                    720: 
                    721:    <dd>
                    722: 
                    723:     <p>The <a href="#syntax-attribute-name" title="syntax-attribute-name">attribute name</a>,
1.996     mike      724:     followed by zero or more <a href="common-microsyntaxes.html#space-character" title="space character">space
1.1       mike      725:     characters</a>, followed by a single U+003D EQUALS SIGN
1.996     mike      726:     character, followed by zero or more <a href="common-microsyntaxes.html#space-character" title="space
1.1       mike      727:     character">space characters</a>, followed by a single U+0027
1.588     mike      728:     APOSTROPHE character ('), followed by the <a href="#syntax-attribute-value" title="syntax-attribute-value">attribute value</a>, which, in
1.1       mike      729:     addition to the requirements given above for attribute values,
1.588     mike      730:     must not contain any literal U+0027 APOSTROPHE characters ('), and
                    731:     finally followed by a second single U+0027 APOSTROPHE character
                    732:     (').</p>
1.1       mike      733: 
                    734:     <div class="example">
                    735: 
1.996     mike      736:      <p>In the following example, the <code title="attr-input-type"><a href="the-input-element.html#attr-input-type">type</a></code> attribute is given with the
1.1       mike      737:      single-quoted attribute value syntax:</p>
                    738: 
                    739:      <pre>&lt;input <em>type='checkbox'</em>&gt;</pre>
                    740: 
                    741:     </div>
                    742: 
                    743:     <p>If an attribute using the single-quoted attribute syntax is to
1.996     mike      744:     be followed by another attribute, then there must be a <a href="common-microsyntaxes.html#space-character">space
1.1       mike      745:     character</a> separating the two.</p>
                    746: 
                    747:    </dd>
                    748: 
                    749:    <dt>Double-quoted attribute value syntax</dt>
                    750: 
                    751:    <dd>
                    752: 
                    753:     <p>The <a href="#syntax-attribute-name" title="syntax-attribute-name">attribute name</a>,
1.996     mike      754:     followed by zero or more <a href="common-microsyntaxes.html#space-character" title="space character">space
1.1       mike      755:     characters</a>, followed by a single U+003D EQUALS SIGN
1.996     mike      756:     character, followed by zero or more <a href="common-microsyntaxes.html#space-character" title="space
1.1       mike      757:     character">space characters</a>, followed by a single U+0022
1.588     mike      758:     QUOTATION MARK character ("), followed by the <a href="#syntax-attribute-value" title="syntax-attribute-value">attribute value</a>, which, in
1.1       mike      759:     addition to the requirements given above for attribute values,
1.588     mike      760:     must not contain any literal U+0022 QUOTATION MARK characters ("),
                    761:     and finally followed by a second single U+0022 QUOTATION MARK
                    762:     character (").</p>
1.1       mike      763: 
                    764:     <div class="example">
                    765: 
1.996     mike      766:      <p>In the following example, the <code title="attr-fe-name"><a href="association-of-controls-and-forms.html#attr-fe-name">name</a></code> attribute is given with the
1.1       mike      767:      double-quoted attribute value syntax:</p>
                    768: 
                    769:      <pre>&lt;input <em>name="be evil"</em>&gt;</pre>
                    770: 
                    771:     </div>
                    772: 
                    773:     <p>If an attribute using the double-quoted attribute syntax is to
1.996     mike      774:     be followed by another attribute, then there must be a <a href="common-microsyntaxes.html#space-character">space
1.1       mike      775:     character</a> separating the two.</p>
                    776: 
                    777:    </dd>
                    778: 
                    779:   </dl><p>There must never be two or more attributes on the same start tag
                    780:   whose names are an <a href="infrastructure.html#ascii-case-insensitive">ASCII case-insensitive</a> match for
1.462     mike      781:   each other.</p><hr><p>When a <a href="#foreign-elements" title="foreign elements">foreign element</a> has
                    782:   one of the namespaced attributes given by the local name and
                    783:   namespace of the first and second cells of a row from the following
                    784:   table, it must be written using the name given by the third cell
                    785:   from the same row.</p><table><thead><tr><th> Local name </th><th> Namespace </th><th> Attribute name
1.996     mike      786:    </th></tr></thead><tbody><tr><td> <code title="">actuate</code> </td><td> <a href="namespaces.html#xlink-namespace">XLink namespace</a> </td><td> <code title="">xlink:actuate</code>
                    787:     </td></tr><tr><td> <code title="">arcrole</code> </td><td> <a href="namespaces.html#xlink-namespace">XLink namespace</a> </td><td> <code title="">xlink:arcrole</code>
                    788:     </td></tr><tr><td> <code title="">href</code> </td><td> <a href="namespaces.html#xlink-namespace">XLink namespace</a> </td><td> <code title="">xlink:href</code>
                    789:     </td></tr><tr><td> <code title="">role</code> </td><td> <a href="namespaces.html#xlink-namespace">XLink namespace</a> </td><td> <code title="">xlink:role</code>
                    790:     </td></tr><tr><td> <code title="">show</code> </td><td> <a href="namespaces.html#xlink-namespace">XLink namespace</a> </td><td> <code title="">xlink:show</code>
                    791:     </td></tr><tr><td> <code title="">title</code> </td><td> <a href="namespaces.html#xlink-namespace">XLink namespace</a> </td><td> <code title="">xlink:title</code>
                    792:     </td></tr><tr><td> <code title="">type</code> </td><td> <a href="namespaces.html#xlink-namespace">XLink namespace</a> </td><td> <code title="">xlink:type</code>
                    793:     </td></tr><tr><td> <code title="">base</code> </td><td> <a href="namespaces.html#xml-namespace">XML namespace</a> <!-- attr-xml-base --> </td><td> <code title="">xml:base</code>
                    794:     </td></tr><tr><td> <code title="">lang</code> </td><td> <a href="namespaces.html#xml-namespace">XML namespace</a> </td><td> <code title="">xml:lang</code>
                    795:     </td></tr><tr><td> <code title="">space</code> </td><td> <a href="namespaces.html#xml-namespace">XML namespace</a> </td><td> <code title="">xml:space</code>
                    796:     </td></tr><tr><td> <code title="">xmlns</code> </td><td> <a href="namespaces.html#xmlns-namespace">XMLNS namespace</a> </td><td> <code title="">xmlns</code>
                    797:     </td></tr><tr><td> <code title="">xlink</code> </td><td> <a href="namespaces.html#xmlns-namespace">XMLNS namespace</a> </td><td> <code title="">xmlns:xlink</code>
1.671     mike      798:   </td></tr></tbody></table><p>No other namespaced attribute can be expressed in <a href="#syntax">the
1.1008    mike      799:   HTML syntax</a>.</p><h5 id="optional-tags"><span class="secno">8.1.2.4 </span>Optional tags</h5><p>Certain tags can be <dfn id="syntax-tag-omission" title="syntax-tag-omission">omitted</dfn>.</p><p class="note">Omitting an element's <a href="#syntax-start-tag" title="syntax-start-tag">start tag</a> does not mean the element
1.1       mike      800:   is not present; it is implied, but it is still there. An HTML
1.159     mike      801:   document always has a root <code><a href="semantics.html#the-html-element-0">html</a></code> element, even if the
1.1       mike      802:   string <code title="">&lt;html&gt;</code> doesn't appear anywhere in
1.159     mike      803:   the markup.</p><!-- <html> --><p>An <code><a href="semantics.html#the-html-element-0">html</a></code> element's <a href="#syntax-start-tag" title="syntax-start-tag">start tag</a> may be omitted if the
                    804:   first thing inside the <code><a href="semantics.html#the-html-element-0">html</a></code> element is not a <a href="#syntax-comments" title="syntax-comments">comment</a>.</p><!-- </html> --><p>An <code><a href="semantics.html#the-html-element-0">html</a></code> element's <a href="#syntax-end-tag" title="syntax-end-tag">end
                    805:   tag</a> may be omitted if the <code><a href="semantics.html#the-html-element-0">html</a></code> element is not
1.821     mike      806:   immediately followed by a <a href="#syntax-comments" title="syntax-comments">comment</a>.</p><!-- <head> --><p>A <code><a href="semantics.html#the-head-element-0">head</a></code> element's <a href="#syntax-start-tag" title="syntax-start-tag">start tag</a> may be omitted if the
                    807:   element is empty, or if the first thing inside the
1.159     mike      808:   <code><a href="semantics.html#the-head-element-0">head</a></code> element is an element.</p><!-- </head> --><p>A <code><a href="semantics.html#the-head-element-0">head</a></code> element's <a href="#syntax-end-tag" title="syntax-end-tag">end
                    809:   tag</a> may be omitted if the <code><a href="semantics.html#the-head-element-0">head</a></code> element is not
1.996     mike      810:   immediately followed by a <a href="common-microsyntaxes.html#space-character">space character</a> or a <a href="#syntax-comments" title="syntax-comments">comment</a>.</p><!-- <body> --><p>A <code><a href="sections.html#the-body-element-0">body</a></code> element's <a href="#syntax-start-tag" title="syntax-start-tag">start tag</a> may be omitted if the
                    811:   element is empty, or if the first thing inside the <code><a href="sections.html#the-body-element-0">body</a></code>
                    812:   element is not a <a href="common-microsyntaxes.html#space-character">space character</a> or a <a href="#syntax-comments" title="syntax-comments">comment</a>, except if the first thing
                    813:   inside the <code><a href="sections.html#the-body-element-0">body</a></code> element is a <code><a href="scripting-1.html#script">script</a></code> or
1.1       mike      814:   <code><a href="semantics.html#the-style-element">style</a></code> element. <!-- Note that even if the </head> end
1.872     mike      815:   tag is present, the parser makes <style type="text/css"> and <script type="text/javascript"> elements
1.1       mike      816:   between </head> and <body> end up in the <head> instead of implying
1.996     mike      817:   the <body> --></p><!-- </body> --><p>A <code><a href="sections.html#the-body-element-0">body</a></code> element's <a href="#syntax-end-tag" title="syntax-end-tag">end
                    818:   tag</a> may be omitted if the <code><a href="sections.html#the-body-element-0">body</a></code> element is not
                    819:   immediately followed by a <a href="#syntax-comments" title="syntax-comments">comment</a>.</p><!-- </li> --><p>A <code><a href="grouping-content.html#the-li-element">li</a></code> element's <a href="#syntax-end-tag" title="syntax-end-tag">end
                    820:   tag</a> may be omitted if the <code><a href="grouping-content.html#the-li-element">li</a></code> element is
                    821:   immediately followed by another <code><a href="grouping-content.html#the-li-element">li</a></code> element or if there
                    822:   is no more content in the parent element.</p><!-- </dt> --><p>A <code><a href="grouping-content.html#the-dt-element">dt</a></code> element's <a href="#syntax-end-tag" title="syntax-end-tag">end
                    823:   tag</a> may be omitted if the <code><a href="grouping-content.html#the-dt-element">dt</a></code> element is
                    824:   immediately followed by another <code><a href="grouping-content.html#the-dt-element">dt</a></code> element or a
                    825:   <code><a href="grouping-content.html#the-dd-element">dd</a></code> element.</p><!-- </dd> --><p>A <code><a href="grouping-content.html#the-dd-element">dd</a></code> element's <a href="#syntax-end-tag" title="syntax-end-tag">end
                    826:   tag</a> may be omitted if the <code><a href="grouping-content.html#the-dd-element">dd</a></code> element is
                    827:   immediately followed by another <code><a href="grouping-content.html#the-dd-element">dd</a></code> element or a
                    828:   <code><a href="grouping-content.html#the-dt-element">dt</a></code> element, or if there is no more content in the
                    829:   parent element.</p><!-- </p> --><p>A <code><a href="grouping-content.html#the-p-element">p</a></code> element's <a href="#syntax-end-tag" title="syntax-end-tag">end
                    830:   tag</a> may be omitted if the <code><a href="grouping-content.html#the-p-element">p</a></code> element is
                    831:   immediately followed by an <code><a href="sections.html#the-address-element">address</a></code>,
                    832:   <code><a href="sections.html#the-article-element">article</a></code>, <code><a href="sections.html#the-aside-element">aside</a></code>, <code><a href="grouping-content.html#the-blockquote-element">blockquote</a></code>,
1.1018    mike      833:   <code><a href="obsolete.html#dir">dir</a></code>, <code><a href="grouping-content.html#the-div-element">div</a></code>, <code><a href="grouping-content.html#the-dl-element">dl</a></code>,
                    834:   <code><a href="forms.html#the-fieldset-element">fieldset</a></code>, <code><a href="sections.html#the-footer-element">footer</a></code>, <code><a href="forms.html#the-form-element">form</a></code>,
                    835:   <code><a href="sections.html#the-h1-h2-h3-h4-h5-and-h6-elements">h1</a></code>, <code><a href="sections.html#the-h1-h2-h3-h4-h5-and-h6-elements">h2</a></code>, <code><a href="sections.html#the-h1-h2-h3-h4-h5-and-h6-elements">h3</a></code>, <code><a href="sections.html#the-h1-h2-h3-h4-h5-and-h6-elements">h4</a></code>,
                    836:   <code><a href="sections.html#the-h1-h2-h3-h4-h5-and-h6-elements">h5</a></code>, <code><a href="sections.html#the-h1-h2-h3-h4-h5-and-h6-elements">h6</a></code>, <code><a href="sections.html#the-header-element">header</a></code>,
                    837:   <code><a href="sections.html#the-hgroup-element">hgroup</a></code>, <code><a href="grouping-content.html#the-hr-element">hr</a></code>, <code><a href="interactive-elements.html#menus">menu</a></code>,
                    838:   <code><a href="sections.html#the-nav-element">nav</a></code>, <code><a href="grouping-content.html#the-ol-element">ol</a></code>, <code><a href="grouping-content.html#the-p-element">p</a></code>, <code><a href="grouping-content.html#the-pre-element">pre</a></code>,
1.996     mike      839:   <code><a href="sections.html#the-section-element">section</a></code>, <code><a href="tabular-data.html#the-table-element">table</a></code>, or <code><a href="grouping-content.html#the-ul-element">ul</a></code>,
1.1       mike      840:   element, or if there is no more content in the parent element and
1.123     mike      841:   the parent element is not an <code><a href="text-level-semantics.html#the-a-element">a</a></code> element.</p><!-- </rt> --><p>An <code><a href="text-level-semantics.html#the-rt-element">rt</a></code> element's <a href="#syntax-end-tag" title="syntax-end-tag">end
1.1       mike      842:   tag</a> may be omitted if the <code><a href="text-level-semantics.html#the-rt-element">rt</a></code> element is
                    843:   immediately followed by an <code><a href="text-level-semantics.html#the-rt-element">rt</a></code> or <code><a href="text-level-semantics.html#the-rp-element">rp</a></code>
1.123     mike      844:   element, or if there is no more content in the parent element.</p><!-- </rp> --><p>An <code><a href="text-level-semantics.html#the-rp-element">rp</a></code> element's <a href="#syntax-end-tag" title="syntax-end-tag">end
1.1       mike      845:   tag</a> may be omitted if the <code><a href="text-level-semantics.html#the-rp-element">rp</a></code> element is
                    846:   immediately followed by an <code><a href="text-level-semantics.html#the-rt-element">rt</a></code> or <code><a href="text-level-semantics.html#the-rp-element">rp</a></code>
1.123     mike      847:   element, or if there is no more content in the parent element.</p><!-- </optgroup> (the text assumes <optgroup> can only be inside a
1.1       mike      848:   <select>; commented out text below can handle the non-<select> case
1.996     mike      849:   if we ever allow it) --><p>An <code><a href="the-button-element.html#the-optgroup-element">optgroup</a></code> element's <a href="#syntax-end-tag" title="syntax-end-tag">end tag</a> may be omitted if the
                    850:   <code><a href="the-button-element.html#the-optgroup-element">optgroup</a></code> element <!--has an ancestor
1.1       mike      851:   <code>select</code> element and--> is immediately followed by
1.996     mike      852:   another <code><a href="the-button-element.html#the-optgroup-element">optgroup</a></code> element, or if <!--all of the elements
1.1       mike      853:   that are ancestors of the <code>optgroup</code> element, up to and
                    854:   including the first ancestor element that is not an
                    855:   <code>optgroup</code> element, have no more content--> there is no
1.123     mike      856:   more content in the parent element.</p><!-- so e.g. the max number of </optgroup>s are omitted here:
1.1       mike      857:    <select><optgroup></select>
                    858:    <p id=x><optgroup></optgroup>x</p>
                    859:    <p id=x><optgroup><optgroup></optgroup></optgroup>x</p>
                    860:    <p><optgroup id=x><optgroup></optgroup>x</p>
                    861:    <p><optgroup><optgroup id=x>x</p>
1.996     mike      862:   --><!-- </option> --><p>An <code><a href="the-button-element.html#the-option-element">option</a></code> element's <a href="#syntax-end-tag" title="syntax-end-tag">end
                    863:   tag</a> may be omitted if the <code><a href="the-button-element.html#the-option-element">option</a></code> element is
                    864:   immediately followed by another <code><a href="the-button-element.html#the-option-element">option</a></code> element, or if
                    865:   it is immediately followed by an <code><a href="the-button-element.html#the-optgroup-element">optgroup</a></code> element, or
1.123     mike      866:   if there is no more content in the parent element.</p><!-- <colgroup> --><p>A <code><a href="tabular-data.html#the-colgroup-element">colgroup</a></code> element's <a href="#syntax-start-tag" title="syntax-start-tag">start tag</a> may be omitted if the
1.1       mike      867:   first thing inside the <code><a href="tabular-data.html#the-colgroup-element">colgroup</a></code> element is a
                    868:   <code><a href="tabular-data.html#the-col-element">col</a></code> element, and if the element is not immediately
                    869:   preceded by another <code><a href="tabular-data.html#the-colgroup-element">colgroup</a></code> element whose <a href="#syntax-end-tag" title="syntax-end-tag">end tag</a> has been omitted. (It can't be
1.123     mike      870:   omitted if the element is empty.)</p><!-- </colgroup> --><p>A <code><a href="tabular-data.html#the-colgroup-element">colgroup</a></code> element's <a href="#syntax-end-tag" title="syntax-end-tag">end tag</a> may be omitted if the
1.1       mike      871:   <code><a href="tabular-data.html#the-colgroup-element">colgroup</a></code> element is not immediately followed by a
1.996     mike      872:   <a href="common-microsyntaxes.html#space-character">space character</a> or a <a href="#syntax-comments" title="syntax-comments">comment</a>.</p><!-- </thead> --><p>A <code><a href="tabular-data.html#the-thead-element">thead</a></code> element's <a href="#syntax-end-tag" title="syntax-end-tag">end
1.1       mike      873:   tag</a> may be omitted if the <code><a href="tabular-data.html#the-thead-element">thead</a></code> element is
                    874:   immediately followed by a <code><a href="tabular-data.html#the-tbody-element">tbody</a></code> or <code><a href="tabular-data.html#the-tfoot-element">tfoot</a></code>
1.123     mike      875:   element.</p><!-- <tbody> --><p>A <code><a href="tabular-data.html#the-tbody-element">tbody</a></code> element's <a href="#syntax-start-tag" title="syntax-start-tag">start tag</a> may be omitted if the
1.1       mike      876:   first thing inside the <code><a href="tabular-data.html#the-tbody-element">tbody</a></code> element is a
                    877:   <code><a href="tabular-data.html#the-tr-element">tr</a></code> element, and if the element is not immediately
                    878:   preceded by a <code><a href="tabular-data.html#the-tbody-element">tbody</a></code>, <code><a href="tabular-data.html#the-thead-element">thead</a></code>, or
                    879:   <code><a href="tabular-data.html#the-tfoot-element">tfoot</a></code> element whose <a href="#syntax-end-tag" title="syntax-end-tag">end
                    880:   tag</a> has been omitted. (It can't be omitted if the element is
1.123     mike      881:   empty.)</p><!-- </tbody> --><p>A <code><a href="tabular-data.html#the-tbody-element">tbody</a></code> element's <a href="#syntax-end-tag" title="syntax-end-tag">end
1.1       mike      882:   tag</a> may be omitted if the <code><a href="tabular-data.html#the-tbody-element">tbody</a></code> element is
                    883:   immediately followed by a <code><a href="tabular-data.html#the-tbody-element">tbody</a></code> or <code><a href="tabular-data.html#the-tfoot-element">tfoot</a></code>
1.123     mike      884:   element, or if there is no more content in the parent element.</p><!-- </tfoot> --><p>A <code><a href="tabular-data.html#the-tfoot-element">tfoot</a></code> element's <a href="#syntax-end-tag" title="syntax-end-tag">end
1.1       mike      885:   tag</a> may be omitted if the <code><a href="tabular-data.html#the-tfoot-element">tfoot</a></code> element is
                    886:   immediately followed by a <code><a href="tabular-data.html#the-tbody-element">tbody</a></code> element, or if there is
1.123     mike      887:   no more content in the parent element.</p><!-- </tr> --><p>A <code><a href="tabular-data.html#the-tr-element">tr</a></code> element's <a href="#syntax-end-tag" title="syntax-end-tag">end
1.1       mike      888:   tag</a> may be omitted if the <code><a href="tabular-data.html#the-tr-element">tr</a></code> element is
                    889:   immediately followed by another <code><a href="tabular-data.html#the-tr-element">tr</a></code> element, or if there
1.123     mike      890:   is no more content in the parent element.</p><!-- </td> --><p>A <code><a href="tabular-data.html#the-td-element">td</a></code> element's <a href="#syntax-end-tag" title="syntax-end-tag">end
1.1       mike      891:   tag</a> may be omitted if the <code><a href="tabular-data.html#the-td-element">td</a></code> element is
                    892:   immediately followed by a <code><a href="tabular-data.html#the-td-element">td</a></code> or <code><a href="tabular-data.html#the-th-element">th</a></code>
1.123     mike      893:   element, or if there is no more content in the parent element.</p><!-- </th> --><p>A <code><a href="tabular-data.html#the-th-element">th</a></code> element's <a href="#syntax-end-tag" title="syntax-end-tag">end
1.1       mike      894:   tag</a> may be omitted if the <code><a href="tabular-data.html#the-th-element">th</a></code> element is
                    895:   immediately followed by a <code><a href="tabular-data.html#the-td-element">td</a></code> or <code><a href="tabular-data.html#the-th-element">th</a></code>
1.123     mike      896:   element, or if there is no more content in the parent element.</p><p><strong>However</strong>, a <a href="#syntax-start-tag" title="syntax-start-tag">start
1.1008    mike      897:   tag</a> must never be omitted if it has any attributes.</p><h5 id="element-restrictions"><span class="secno">8.1.2.5 </span>Restrictions on content models</h5><p>For historical reasons, certain elements have extra restrictions
1.123     mike      898:   beyond even the restrictions given by their content model.</p><p>A <code><a href="tabular-data.html#the-table-element">table</a></code> element must not contain <code><a href="tabular-data.html#the-tr-element">tr</a></code>
1.1       mike      899:   elements, even though these elements are technically allowed inside
                    900:   <code><a href="tabular-data.html#the-table-element">table</a></code> elements according to the content models
                    901:   described in this specification. (If a <code><a href="tabular-data.html#the-tr-element">tr</a></code> element is
                    902:   put inside a <code><a href="tabular-data.html#the-table-element">table</a></code> in the markup, it will in fact imply
1.304     mike      903:   a <code><a href="tabular-data.html#the-tbody-element">tbody</a></code> start tag before it.)</p><p>A single <a href="#syntax-newlines" title="syntax-newlines">newline</a> may be
                    904:   placed immediately after the <a href="#syntax-start-tag" title="syntax-start-tag">start
1.996     mike      905:   tag</a> of <code><a href="grouping-content.html#the-pre-element">pre</a></code> and <code><a href="the-button-element.html#the-textarea-element">textarea</a></code>
1.1       mike      906:   elements. This does not affect the processing of the element. The
1.304     mike      907:   otherwise optional <a href="#syntax-newlines" title="syntax-newlines">newline</a>
1.381     mike      908:   <em>must</em> be included if the element's contents themselves start
                    909:   with a <a href="#syntax-newlines" title="syntax-newlines">newline</a> (because
                    910:   otherwise the leading newline in the contents would be treated like
                    911:   the optional newline, and ignored).</p><div class="example">
1.996     mike      912:    <p>The following two <code><a href="grouping-content.html#the-pre-element">pre</a></code> blocks are equivalent:</p>
1.1       mike      913:    <pre>&lt;pre&gt;Hello&lt;/pre&gt;</pre>
                    914:    <pre>&lt;pre&gt;<br>Hello&lt;/pre&gt;</pre>
1.1008    mike      915:   </div><h5 id="cdata-rcdata-restrictions"><span class="secno">8.1.2.6 </span>Restrictions on the contents of raw text and RCDATA elements</h5><p>The text in <a href="#raw-text-elements" title="raw text elements">raw text</a> and
1.889     mike      916:   <a href="#rcdata-elements">RCDATA elements</a> must not contain any occurrences of the
                    917:   string "<code title="">&lt;/</code>" (U+003C LESS-THAN SIGN, U+002F
                    918:   SOLIDUS) followed by characters that case-insensitively match the
                    919:   tag name of the element followed by one of U+0009 CHARACTER
                    920:   TABULATION, U+000A LINE FEED (LF), U+000C FORM FEED (FF), U+000D
                    921:   CARRIAGE RETURN (CR), U+0020 SPACE, U+003E GREATER-THAN SIGN (&gt;), or
1.1008    mike      922:   U+002F SOLIDUS (/).</p><h4 id="text-0"><span class="secno">8.1.3 </span>Text</h4><p><dfn id="syntax-text" title="syntax-text">Text</dfn> is allowed inside elements,
1.1005    mike      923:   attribute values, and comments. Text must consist of Unicode
                    924:   characters. Text must not contain U+0000 characters. Text must not
                    925:   contain permanently undefined Unicode characters (noncharacters).
                    926:   Text must not contain control characters other than <a href="common-microsyntaxes.html#space-character" title="space character">space characters</a>. Extra constraints
                    927:   are placed on what is and what is not allowed in text based on where
1.1008    mike      928:   the text is to be put, as described in the other sections.</p><h5 id="newlines"><span class="secno">8.1.3.1 </span>Newlines</h5><p><dfn id="syntax-newlines" title="syntax-newlines">Newlines</dfn> in HTML may be
1.1       mike      929:   represented either as U+000D CARRIAGE RETURN (CR) characters, U+000A
                    930:   LINE FEED (LF) characters, or pairs of U+000D CARRIAGE RETURN (CR),
1.882     mike      931:   U+000A LINE FEED (LF) characters in that order.</p><p>Where <a href="#syntax-charref" title="syntax-charref">character references</a>
                    932:   are allowed, a character reference of a U+000A LINE FEED (LF)
                    933:   character (but not a U+000D CARRIAGE RETURN (CR) character) also
1.1008    mike      934:   represents a <a href="#syntax-newlines" title="syntax-newlines">newline</a>.</p><h4 id="character-references"><span class="secno">8.1.4 </span>Character references</h4><p>In certain cases described in other sections, <a href="#syntax-text" title="syntax-text">text</a> may be mixed with <dfn id="syntax-charref" title="syntax-charref">character references</dfn>. These can be used
1.1       mike      935:   to escape characters that couldn't otherwise legally be included in
1.588     mike      936:   <a href="#syntax-text" title="syntax-text">text</a>.</p><p>Character references must start with a U+0026 AMPERSAND character
                    937:   (&amp;). Following this, there are three possible kinds of character
                    938:   references:</p><dl><dt>Named character references</dt>
1.1       mike      939: 
                    940:    <dd>The ampersand must be followed by one of the names given in the
                    941:    <a href="named-character-references.html#named-character-references">named character references</a> section, using the same
1.677     mike      942:    case. <span class="impl">The name must be one that is terminated by
                    943:    a U+003B SEMICOLON character (;).</span></dd>
1.1       mike      944: 
                    945: 
                    946:    <dt>Decimal numeric character reference</dt>
                    947: 
                    948:    <dd>The ampersand must be followed by a U+0023 NUMBER SIGN
1.588     mike      949:    character (#), followed by one or more digits in the range U+0030
                    950:    DIGIT ZERO (0) to U+0039 DIGIT NINE (9), representing a base-ten
                    951:    integer that corresponds to a Unicode code point that is allowed
                    952:    according to the definition below. The digits must then be followed
                    953:    by a U+003B SEMICOLON character (;).</dd>
1.1       mike      954: 
                    955: 
                    956:    <dt>Hexadecimal numeric character reference</dt>
                    957: 
                    958:    <dd>The ampersand must be followed by a U+0023 NUMBER SIGN
1.588     mike      959:    character (#), which must be followed by either a U+0078 LATIN
                    960:    SMALL LETTER X character (x) or a U+0058 LATIN CAPITAL LETTER X
                    961:    character (X), which must then be followed by one or more digits in
                    962:    the range U+0030 DIGIT ZERO (0) to U+0039 DIGIT NINE (9), U+0061
                    963:    LATIN SMALL LETTER A to U+0066 LATIN SMALL LETTER F, and U+0041
                    964:    LATIN CAPITAL LETTER A to U+0046 LATIN CAPITAL LETTER F,
1.464     mike      965:    representing a base-sixteen integer that corresponds to a Unicode
                    966:    code point that is allowed according to the definition below. The
                    967:    digits must then be followed by a U+003B SEMICOLON character
                    968:    (;).</dd>
1.378     mike      969: 
                    970:   </dl><p>The numeric character reference forms described above are allowed
1.882     mike      971:   to reference any Unicode code point other than U+0000, U+000D,
                    972:   permanently undefined Unicode characters (noncharacters), and
1.996     mike      973:   control characters other than <a href="common-microsyntaxes.html#space-character" title="space character">space
1.378     mike      974:   characters</a>.</p><p>An <dfn id="syntax-ambiguous-ampersand" title="syntax-ambiguous-ampersand">ambiguous
1.464     mike      975:   ampersand</dfn> is a U+0026 AMPERSAND character (&amp;) that is
1.897     mike      976:   followed by one or more characters in the range U+0030 DIGIT ZERO
                    977:   (0) to U+0039 DIGIT NINE (9), U+0061 LATIN SMALL LETTER A to U+007A
                    978:   LATIN SMALL LETTER Z, and U+0041 LATIN CAPITAL LETTER A to U+005A
                    979:   LATIN CAPITAL LETTER Z, followed by a U+003B SEMICOLON character
                    980:   (;), where these characters do not match any of the names given in
1.1008    mike      981:   the <a href="named-character-references.html#named-character-references">named character references</a> section.</p><h4 id="cdata-sections"><span class="secno">8.1.5 </span>CDATA sections</h4><p><dfn id="syntax-cdata" title="syntax-cdata">CDATA sections</dfn> must start with
1.1       mike      982:   the character sequence U+003C LESS-THAN SIGN, U+0021 EXCLAMATION
                    983:   MARK, U+005B LEFT SQUARE BRACKET, U+0043 LATIN CAPITAL LETTER C,
                    984:   U+0044 LATIN CAPITAL LETTER D, U+0041 LATIN CAPITAL LETTER A, U+0054
                    985:   LATIN CAPITAL LETTER T, U+0041 LATIN CAPITAL LETTER A, U+005B LEFT
                    986:   SQUARE BRACKET (<code title="">&lt;![CDATA[</code>). Following this
                    987:   sequence, the CDATA section may have <a href="#syntax-text" title="syntax-text">text</a>, with the additional restriction
                    988:   that the text must not contain the three character sequence U+005D
                    989:   RIGHT SQUARE BRACKET, U+005D RIGHT SQUARE BRACKET, U+003E
                    990:   GREATER-THAN SIGN (<code title="">]]&gt;</code>). Finally, the CDATA
                    991:   section must be ended by the three character sequence U+005D RIGHT
                    992:   SQUARE BRACKET, U+005D RIGHT SQUARE BRACKET, U+003E GREATER-THAN
1.724     mike      993:   SIGN (<code title="">]]&gt;</code>).</p><div class="example">
                    994: 
                    995:    <p>CDATA sections can only be used in foreign content (MathML or
                    996:    SVG). In this example, a CDATA section is used to escape the
                    997:    contents of an <code>ms</code> element:</p>
                    998: 
                    999:    <pre>&lt;p&gt;You can add a string to a number, but this stringifies the number:&lt;/p&gt;
                   1000: &lt;math&gt;
                   1001:  &lt;ms&gt;&lt;![CDATA[x&lt;y]]&gt;&lt;/ms&gt;
                   1002:  &lt;mo&gt;+&lt;/mo&gt;
                   1003:  &lt;mn&gt;3&lt;/mn&gt;
                   1004:  &lt;mo&gt;=&lt;/mo&gt;
                   1005:  &lt;ms&gt;&lt;![CDATA[x&lt;y3]]&gt;&lt;/ms&gt;
                   1006: &lt;/math&gt;</pre>
                   1007: 
1.1008    mike     1008:   </div><h4 id="comments"><span class="secno">8.1.6 </span>Comments</h4><p><dfn id="syntax-comments" title="syntax-comments">Comments</dfn> must start with the
1.1       mike     1009:   four character sequence U+003C LESS-THAN SIGN, U+0021 EXCLAMATION
                   1010:   MARK, U+002D HYPHEN-MINUS, U+002D HYPHEN-MINUS (<code title="">&lt;!--</code>). Following this sequence, the comment may
                   1011:   have <a href="#syntax-text" title="syntax-text">text</a>, with the additional
                   1012:   restriction that the text must not start with a single U+003E
1.588     mike     1013:   GREATER-THAN SIGN character (&gt;), nor start with a U+002D
                   1014:   HYPHEN-MINUS character (-) followed by a U+003E GREATER-THAN SIGN
                   1015:   (&gt;) character, nor contain two consecutive U+002D HYPHEN-MINUS
                   1016:   characters (<code title="">--</code>), nor end with a U+002D
                   1017:   HYPHEN-MINUS character (-). Finally, the comment must be ended by
1.1       mike     1018:   the three character sequence U+002D HYPHEN-MINUS, U+002D
1.996     mike     1019:   HYPHEN-MINUS, U+003E GREATER-THAN SIGN (<code title="">--&gt;</code>).</p></body></html>

Webmaster