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

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

Webmaster