Another abandoned server code base... this is kind of an ancestor of taskrambler.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

2232 lines
118 KiB

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html lang="en-US-x-Hixie" ><head><title>2.5 Common microsyntaxes &#8212; HTML5 </title><style type="text/css">
pre { margin-left: 2em; white-space: pre-wrap; }
h2 { margin: 3em 0 1em 0; }
h3 { margin: 2.5em 0 1em 0; }
h4 { margin: 2.5em 0 0.75em 0; }
h5, h6 { margin: 2.5em 0 1em; }
h1 + h2, h1 + h2 + h2 { margin: 0.75em 0 0.75em; }
h2 + h3, h3 + h4, h4 + h5, h5 + h6 { margin-top: 0.5em; }
p { margin: 1em 0; }
hr:not(.top) { display: block; background: none; border: none; padding: 0; margin: 2em 0; height: auto; }
dl, dd { margin-top: 0; margin-bottom: 0; }
dt { margin-top: 0.75em; margin-bottom: 0.25em; clear: left; }
dt + dt { margin-top: 0; }
dd dt { margin-top: 0.25em; margin-bottom: 0; }
dd p { margin-top: 0; }
dd dl + p { margin-top: 1em; }
dd table + p { margin-top: 1em; }
p + * > li, dd li { margin: 1em 0; }
dt, dfn { font-weight: bold; font-style: normal; }
dt dfn { font-style: italic; }
pre, code { font-size: inherit; font-family: monospace; font-variant: normal; }
pre strong { color: black; font: inherit; font-weight: bold; background: yellow; }
pre em { font-weight: bolder; font-style: normal; }
@media screen { code { color: orangered; } code :link, code :visited { color: inherit; } }
var sub { vertical-align: bottom; font-size: smaller; position: relative; top: 0.1em; }
table { border-collapse: collapse; border-style: hidden hidden none hidden; }
table thead, table tbody { border-bottom: solid; }
table tbody th:first-child { border-left: solid; }
table tbody th { text-align: left; }
table td, table th { border-left: solid; border-right: solid; border-bottom: solid thin; vertical-align: top; padding: 0.2em; }
blockquote { margin: 0 0 0 2em; border: 0; padding: 0; font-style: italic; }
.bad, .bad *:not(.XXX) { color: gray; border-color: gray; background: transparent; }
.matrix, .matrix td { border: none; text-align: right; }
.matrix { margin-left: 2em; }
.dice-example { border-collapse: collapse; border-style: hidden solid solid hidden; border-width: thin; margin-left: 3em; }
.dice-example caption { width: 30em; font-size: smaller; font-style: italic; padding: 0.75em 0; text-align: left; }
.dice-example td, .dice-example th { border: solid thin; width: 1.35em; height: 1.05em; text-align: center; padding: 0; }
.toc dfn, h1 dfn, h2 dfn, h3 dfn, h4 dfn, h5 dfn, h6 dfn { font: inherit; }
img.extra { float: right; }
pre.idl { border: solid thin; background: #EEEEEE; color: black; padding: 0.5em 1em; }
pre.idl :link, pre.idl :visited { color: inherit; background: transparent; }
pre.css { border: solid thin; background: #FFFFEE; color: black; padding: 0.5em 1em; }
pre.css:first-line { color: #AAAA50; }
dl.domintro { color: green; margin: 2em 0 2em 2em; padding: 0.5em 1em; border: none; background: #DDFFDD; }
hr + dl.domintro, div.impl + dl.domintro { margin-top: 2.5em; margin-bottom: 1.5em; }
dl.domintro dt, dl.domintro dt * { color: black; text-decoration: none; }
dl.domintro dd { margin: 0.5em 0 1em 2em; padding: 0; }
dl.domintro dd p { margin: 0.5em 0; }
dl.switch { padding-left: 2em; }
dl.switch > dt { text-indent: -1.5em; }
dl.switch > dt:before { content: '\21AA'; padding: 0 0.5em 0 0; display: inline-block; width: 1em; text-align: right; line-height: 0.5em; }
dl.triple { padding: 0 0 0 1em; }
dl.triple dt, dl.triple dd { margin: 0; display: inline }
dl.triple dt:after { content: ':'; }
dl.triple dd:after { content: '\A'; white-space: pre; }
.diff-old { text-decoration: line-through; color: silver; background: transparent; }
.diff-chg, .diff-new { text-decoration: underline; color: green; background: transparent; }
a .diff-new { border-bottom: 1px blue solid; }
h2 { page-break-before: always; }
h1, h2, h3, h4, h5, h6 { page-break-after: avoid; }
h1 + h2, hr + h2.no-toc { page-break-before: auto; }
p > span:not([title=""]):not([class="XXX"]):not([class="impl"]):not([class="note"]),
li > span:not([title=""]):not([class="XXX"]):not([class="impl"]):not([class="note"]), { border-bottom: solid #9999CC; }
div.head { margin: 0 0 1em; padding: 1em 0 0 0; }
div.head p { margin: 0; }
div.head h1 { margin: 0; }
div.head .logo { float: right; margin: 0 1em; }
div.head .logo img { border: none } /* remove border from top image */
div.head dl { margin: 1em 0; }
div.head p.copyright, div.head p.alt { font-size: x-small; font-style: oblique; margin: 0; }
body > .toc > li { margin-top: 1em; margin-bottom: 1em; }
body > .toc.brief > li { margin-top: 0.35em; margin-bottom: 0.35em; }
body > .toc > li > * { margin-bottom: 0.5em; }
body > .toc > li > * > li > * { margin-bottom: 0.25em; }
.toc, .toc li { list-style: none; }
.brief { margin-top: 1em; margin-bottom: 1em; line-height: 1.1; }
.brief li { margin: 0; padding: 0; }
.brief li p { margin: 0; padding: 0; }
.category-list { margin-top: -0.75em; margin-bottom: 1em; line-height: 1.5; }
.category-list::before { content: '\21D2\A0'; font-size: 1.2em; font-weight: 900; }
.category-list li { display: inline; }
.category-list li:not(:last-child)::after { content: ', '; }
.category-list li > span, .category-list li > a { text-transform: lowercase; }
.category-list li * { text-transform: none; } /* don't affect <code> nested in <a> */
.XXX { color: #E50000; background: white; border: solid red; padding: 0.5em; margin: 1em 0; }
.XXX > :first-child { margin-top: 0; }
p .XXX { line-height: 3em; }
.annotation { border: solid thin black; background: #0C479D; color: white; position: relative; margin: 8px 0 20px 0; }
.annotation:before { position: absolute; left: 0; top: 0; width: 100%; height: 100%; margin: 6px -6px -6px 6px; background: #333333; z-index: -1; content: ''; }
.annotation :link, .annotation :visited { color: inherit; }
.annotation :link:hover, .annotation :visited:hover { background: transparent; }
.annotation span { border: none ! important; }
.note { color: green; background: transparent; font-family: sans-serif; }
.warning { color: red; background: transparent; }
.note, .warning { font-weight: bolder; font-style: italic; }
p.note, div.note { padding: 0.5em 2em; }
span.note { padding: 0 2em; }
.note p:first-child, .warning p:first-child { margin-top: 0; }
.note p:last-child, .warning p:last-child { margin-bottom: 0; }
.warning:before { font-style: normal; }
p.note:before { content: 'Note: '; }
p.warning:before { content: '\26A0 Warning! '; }
.bookkeeping:before { display: block; content: 'Bookkeeping details'; font-weight: bolder; font-style: italic; }
.bookkeeping { font-size: 0.8em; margin: 2em 0; }
.bookkeeping p { margin: 0.5em 2em; display: list-item; list-style: square; }
.bookkeeping dt { margin: 0.5em 2em 0; }
.bookkeeping dd { margin: 0 3em 0.5em; }
h4 { position: relative; z-index: 3; }
h4 + .element, h4 + div + .element { margin-top: -2.5em; padding-top: 2em; }
.element {
background: #EEEEFF;
color: black;
margin: 0 0 1em 0.15em;
padding: 0 1em 0.25em 0.75em;
border-left: solid #9999FF 0.25em;
position: relative;
z-index: 1;
}
.element:before {
position: absolute;
z-index: 2;
top: 0;
left: -1.15em;
height: 2em;
width: 0.9em;
background: #EEEEFF;
content: ' ';
border-style: none none solid solid;
border-color: #9999FF;
border-width: 0.25em;
}
.example { display: block; color: #222222; background: #FCFCFC; border-left: double; margin-left: 2em; padding-left: 1em; }
td > .example:only-child { margin: 0 0 0 0.1em; }
ul.domTree, ul.domTree ul { padding: 0 0 0 1em; margin: 0; }
ul.domTree li { padding: 0; margin: 0; list-style: none; position: relative; }
ul.domTree li li { list-style: none; }
ul.domTree li:first-child::before { position: absolute; top: 0; height: 0.6em; left: -0.75em; width: 0.5em; border-style: none none solid solid; content: ''; border-width: 0.1em; }
ul.domTree li:not(:last-child)::after { position: absolute; top: 0; bottom: -0.6em; left: -0.75em; width: 0.5em; border-style: none none solid solid; content: ''; border-width: 0.1em; }
ul.domTree span { font-style: italic; font-family: serif; }
ul.domTree .t1 code { color: purple; font-weight: bold; }
ul.domTree .t2 { font-style: normal; font-family: monospace; }
ul.domTree .t2 .name { color: black; font-weight: bold; }
ul.domTree .t2 .value { color: blue; font-weight: normal; }
ul.domTree .t3 code, .domTree .t4 code, .domTree .t5 code { color: gray; }
ul.domTree .t7 code, .domTree .t8 code { color: green; }
ul.domTree .t10 code { color: teal; }
body.dfnEnabled dfn { cursor: pointer; }
.dfnPanel {
display: inline;
position: absolute;
z-index: 10;
height: auto;
width: auto;
padding: 0.5em 0.75em;
font: small sans-serif, Droid Sans Fallback;
background: #DDDDDD;
color: black;
border: outset 0.2em;
}
.dfnPanel * { margin: 0; padding: 0; font: inherit; text-indent: 0; }
.dfnPanel :link, .dfnPanel :visited { color: black; }
.dfnPanel p { font-weight: bolder; }
.dfnPanel * + p { margin-top: 0.25em; }
.dfnPanel li { list-style-position: inside; }
#configUI { position: absolute; z-index: 20; top: 10em; right: 1em; width: 11em; font-size: small; }
#configUI p { margin: 0.5em 0; padding: 0.3em; background: #EEEEEE; color: black; border: inset thin; }
#configUI p label { display: block; }
#configUI #updateUI, #configUI .loginUI { text-align: center; }
#configUI input[type=button] { display: block; margin: auto; }
fieldset { margin: 1em; padding: 0.5em 1em; }
fieldset > legend + * { margin-top: 0; }
fieldset > :last-child { margin-bottom: 0; }
fieldset p { margin: 0.5em 0; }
.stability {
position: fixed;
bottom: 0;
left: 0; right: 0;
margin: 0 auto 0 auto !important;
z-index: 1000;
width: 50%;
background: maroon; color: yellow;
-webkit-border-radius: 1em 1em 0 0;
-moz-border-radius: 1em 1em 0 0;
border-radius: 1em 1em 0 0;
-moz-box-shadow: 0 0 1em #500;
-webkit-box-shadow: 0 0 1em #500;
box-shadow: 0 0 1em red;
padding: 0.5em 1em;
text-align: center;
}
.stability strong {
display: block;
}
.stability input {
appearance: none; margin: 0; border: 0; padding: 0.25em 0.5em; background: transparent; color: black;
position: absolute; top: -0.5em; right: 0; font: 1.25em sans-serif; text-align: center;
}
.stability input:hover {
color: white;
text-shadow: 0 0 2px black;
}
.stability input:active {
padding: 0.3em 0.45em 0.2em 0.55em;
}
.stability :link, .stability :visited,
.stability :link:hover, .stability :visited:hover {
background: transparent;
color: white;
}
</style><link href="data:text/css,.impl%20%7B%20display:%20none;%20%7D%0Ahtml%20%7B%20border:%20solid%20yellow;%20%7D%20.domintro:before%20%7B%20display:%20none;%20%7D" id="author" rel="alternate stylesheet" title="Author documentation only"><link href="data:text/css,.impl%20%7B%20background:%20%23FFEEEE;%20%7D%20.domintro:before%20%7B%20background:%20%23FFEEEE;%20%7D" id="highlight" rel="alternate stylesheet" title="Highlight implementation
requirements"><link href="http://www.w3.org/StyleSheets/TR/W3C-WD" rel="stylesheet" type="text/css"><style type="text/css">
.applies thead th > * { display: block; }
.applies thead code { display: block; }
.applies tbody th { whitespace: nowrap; }
.applies td { text-align: center; }
.applies .yes { background: yellow; }
.matrix, .matrix td { border: hidden; text-align: right; }
.matrix { margin-left: 2em; }
.dice-example { border-collapse: collapse; border-style: hidden solid solid hidden; border-width: thin; margin-left: 3em; }
.dice-example caption { width: 30em; font-size: smaller; font-style: italic; padding: 0.75em 0; text-align: left; }
.dice-example td, .dice-example th { border: solid thin; width: 1.35em; height: 1.05em; text-align: center; padding: 0; }
td.eg { border-width: thin; text-align: center; }
#table-example-1 { border: solid thin; border-collapse: collapse; margin-left: 3em; }
#table-example-1 * { font-family: "Essays1743", serif; line-height: 1.01em; }
#table-example-1 caption { padding-bottom: 0.5em; }
#table-example-1 thead, #table-example-1 tbody { border: none; }
#table-example-1 th, #table-example-1 td { border: solid thin; }
#table-example-1 th { font-weight: normal; }
#table-example-1 td { border-style: none solid; vertical-align: top; }
#table-example-1 th { padding: 0.5em; vertical-align: middle; text-align: center; }
#table-example-1 tbody tr:first-child td { padding-top: 0.5em; }
#table-example-1 tbody tr:last-child td { padding-bottom: 1.5em; }
#table-example-1 tbody td:first-child { padding-left: 2.5em; padding-right: 0; width: 9em; }
#table-example-1 tbody td:first-child::after { content: leader(". "); }
#table-example-1 tbody td { padding-left: 2em; padding-right: 2em; }
#table-example-1 tbody td:first-child + td { width: 10em; }
#table-example-1 tbody td:first-child + td ~ td { width: 2.5em; }
#table-example-1 tbody td:first-child + td + td + td ~ td { width: 1.25em; }
.apple-table-examples { border: none; border-collapse: separate; border-spacing: 1.5em 0em; width: 40em; margin-left: 3em; }
.apple-table-examples * { font-family: "Times", serif; }
.apple-table-examples td, .apple-table-examples th { border: none; white-space: nowrap; padding-top: 0; padding-bottom: 0; }
.apple-table-examples tbody th:first-child { border-left: none; width: 100%; }
.apple-table-examples thead th:first-child ~ th { font-size: smaller; font-weight: bolder; border-bottom: solid 2px; text-align: center; }
.apple-table-examples tbody th::after, .apple-table-examples tfoot th::after { content: leader(". ") }
.apple-table-examples tbody th, .apple-table-examples tfoot th { font: inherit; text-align: left; }
.apple-table-examples td { text-align: right; vertical-align: top; }
.apple-table-examples.e1 tbody tr:last-child td { border-bottom: solid 1px; }
.apple-table-examples.e1 tbody + tbody tr:last-child td { border-bottom: double 3px; }
.apple-table-examples.e2 th[scope=row] { padding-left: 1em; }
.apple-table-examples sup { line-height: 0; }
.details-example img { vertical-align: top; }
#base64-table {
white-space: nowrap;
font-size: 0.6em;
column-width: 6em;
column-count: 5;
column-gap: 1em;
-moz-column-width: 6em;
-moz-column-count: 5;
-moz-column-gap: 1em;
-webkit-column-width: 6em;
-webkit-column-count: 5;
-webkit-column-gap: 1em;
}
#base64-table thead { display: none; }
#base64-table * { border: none; }
#base64-table tbody td:first-child:after { content: ':'; }
#base64-table tbody td:last-child { text-align: right; }
#named-character-references-table {
white-space: nowrap;
font-size: 0.6em;
column-width: 30em;
column-gap: 1em;
-moz-column-width: 30em;
-moz-column-gap: 1em;
-webkit-column-width: 30em;
-webkit-column-gap: 1em;
}
#named-character-references-table > table > tbody > tr > td:first-child + td,
#named-character-references-table > table > tbody > tr > td:last-child { text-align: center; }
#named-character-references-table > table > tbody > tr > td:last-child:hover > span { position: absolute; top: auto; left: auto; margin-left: 0.5em; line-height: 1.2; font-size: 5em; border: outset; padding: 0.25em 0.5em; background: white; width: 1.25em; height: auto; text-align: center; }
#named-character-references-table > table > tbody > tr#entity-CounterClockwiseContourIntegral > td:first-child { font-size: 0.5em; }
.glyph.control { color: red; }
@font-face {
font-family: 'Essays1743';
src: url('http://www.whatwg.org/specs/web-apps/current-work/fonts/Essays1743.ttf');
}
@font-face {
font-family: 'Essays1743';
font-weight: bold;
src: url('http://www.whatwg.org/specs/web-apps/current-work/fonts/Essays1743-Bold.ttf');
}
@font-face {
font-family: 'Essays1743';
font-style: italic;
src: url('http://www.whatwg.org/specs/web-apps/current-work/fonts/Essays1743-Italic.ttf');
}
@font-face {
font-family: 'Essays1743';
font-style: italic;
font-weight: bold;
src: url('http://www.whatwg.org/specs/web-apps/current-work/fonts/Essays1743-BoldItalic.ttf');
}
</style><style type="text/css">
.domintro:before { display: table; margin: -1em -0.5em -0.5em auto; width: auto; content: 'This box is non-normative. Implementation requirements are given below this box.'; color: black; font-style: italic; border: solid 2px; background: white; padding: 0 0.25em; }
</style><script type="text/javascript">
function getCookie(name) {
var params = location.search.substr(1).split("&");
for (var index = 0; index < params.length; index++) {
if (params[index] == name)
return "1";
var data = params[index].split("=");
if (data[0] == name)
return unescape(data[1]);
}
var cookies = document.cookie.split("; ");
for (var index = 0; index < cookies.length; index++) {
var data = cookies[index].split("=");
if (data[0] == name)
return unescape(data[1]);
}
return null;
}
</script>
<script src="link-fixup.js" type="text/javascript"></script>
<link href="style.css" rel="stylesheet"><link href="infrastructure.html" title="2 Common infrastructure" rel="prev">
<link href="spec.html#contents" title="Table of contents" rel="index">
<link href="urls.html" title="2.6 URLs" rel="next">
</head><body><div class="head" id="head">
<div id="multipage-common">
<p class="stability" id="wip"><strong>This is a work in
progress!</strong> For the latest updates from the HTML WG, possibly
including important bug fixes, please look at the <a href="http://dev.w3.org/html5/spec/Overview.html">editor's draft</a> instead.
There may also be a more
<a href="http://www.w3.org/TR/html5">up-to-date Working Draft</a>
with changes based on resolution of Last Call issues.
<input onclick="closeWarning(this.parentNode)" type="button" value="&#9587;&#8413;"></p>
<script type="text/javascript">
function closeWarning(element) {
element.parentNode.removeChild(element);
var date = new Date();
date.setDate(date.getDate()+4);
document.cookie = 'hide-obsolescence-warning=1; expires=' + date.toGMTString();
}
if (getCookie('hide-obsolescence-warning') == '1')
setTimeout(function () { document.getElementById('wip').parentNode.removeChild(document.getElementById('wip')); }, 2000);
</script></div>
<p><a href="http://www.w3.org/"><img alt="W3C" height="48" src="http://www.w3.org/Icons/w3c_home" width="72"></a></p>
<h1>HTML5</h1>
</div><div>
<a href="infrastructure.html" class="prev">2 Common infrastructure</a> &#8211;
<a href="spec.html#contents">Table of contents</a> &#8211;
<a href="urls.html" class="next">2.6 URLs</a>
<ol class="toc"><li><ol><li><a href="common-microsyntaxes.html#common-microsyntaxes"><span class="secno">2.5 </span>Common microsyntaxes</a>
<ol><li><a href="common-microsyntaxes.html#common-parser-idioms"><span class="secno">2.5.1 </span>Common parser idioms</a></li><li><a href="common-microsyntaxes.html#boolean-attributes"><span class="secno">2.5.2 </span>Boolean attributes</a></li><li><a href="common-microsyntaxes.html#keywords-and-enumerated-attributes"><span class="secno">2.5.3 </span>Keywords and enumerated attributes</a></li><li><a href="common-microsyntaxes.html#numbers"><span class="secno">2.5.4 </span>Numbers</a>
<ol><li><a href="common-microsyntaxes.html#non-negative-integers"><span class="secno">2.5.4.1 </span>Non-negative integers</a></li><li><a href="common-microsyntaxes.html#signed-integers"><span class="secno">2.5.4.2 </span>Signed integers</a></li><li><a href="common-microsyntaxes.html#real-numbers"><span class="secno">2.5.4.3 </span>Real numbers</a></li><li><a href="common-microsyntaxes.html#percentages-and-dimensions"><span class="secno">2.5.4.4 </span>Percentages and lengths</a></li><li><a href="common-microsyntaxes.html#lists-of-integers"><span class="secno">2.5.4.5 </span>Lists of integers</a></li><li><a href="common-microsyntaxes.html#lists-of-dimensions"><span class="secno">2.5.4.6 </span>Lists of dimensions</a></li></ol></li><li><a href="common-microsyntaxes.html#dates-and-times"><span class="secno">2.5.5 </span>Dates and times</a>
<ol><li><a href="common-microsyntaxes.html#months"><span class="secno">2.5.5.1 </span>Months</a></li><li><a href="common-microsyntaxes.html#dates"><span class="secno">2.5.5.2 </span>Dates</a></li><li><a href="common-microsyntaxes.html#times"><span class="secno">2.5.5.3 </span>Times</a></li><li><a href="common-microsyntaxes.html#local-dates-and-times"><span class="secno">2.5.5.4 </span>Local dates and times</a></li><li><a href="common-microsyntaxes.html#global-dates-and-times"><span class="secno">2.5.5.5 </span>Global dates and times</a></li><li><a href="common-microsyntaxes.html#weeks"><span class="secno">2.5.5.6 </span>Weeks</a></li><li><a href="common-microsyntaxes.html#vaguer-moments-in-time"><span class="secno">2.5.5.7 </span>Vaguer moments in time</a></li></ol></li><li><a href="common-microsyntaxes.html#colors"><span class="secno">2.5.6 </span>Colors</a></li><li><a href="common-microsyntaxes.html#space-separated-tokens"><span class="secno">2.5.7 </span>Space-separated tokens</a></li><li><a href="common-microsyntaxes.html#comma-separated-tokens"><span class="secno">2.5.8 </span>Comma-separated tokens</a></li><li><a href="common-microsyntaxes.html#syntax-references"><span class="secno">2.5.9 </span>References</a></li><li><a href="common-microsyntaxes.html#mq"><span class="secno">2.5.10 </span>Media queries</a></li></ol></li></ol></li></ol></div>
<h3 id="common-microsyntaxes"><span class="secno">2.5 </span>Common microsyntaxes</h3><p>There are various places in HTML that accept particular data
types, such as dates or numbers. This section describes what the
conformance criteria for content in those formats is, and how to
parse them.</p><div class="impl">
<p class="note">Implementors are strongly urged to carefully examine
any third-party libraries they might consider using to implement the
parsing of syntaxes described below. For example, date libraries are
likely to implement error handling behavior that differs from what
is required in this specification, since error-handling behavior is
often not defined in specifications that describe date syntaxes
similar to those used in this specification, and thus
implementations tend to vary greatly in how they handle errors.</p>
</div><div class="impl">
<h4 id="common-parser-idioms"><span class="secno">2.5.1 </span>Common parser idioms</h4>
<p>The <dfn id="space-character" title="space character">space characters</dfn>, for the
purposes of this specification, are U+0020 SPACE, U+0009 CHARACTER
TABULATION (tab), U+000A LINE FEED (LF), U+000C FORM FEED (FF), and
U+000D CARRIAGE RETURN (CR).</p>
<p>The <dfn id="white_space" title="White_Space">White_Space characters</dfn> are
those that have the Unicode property "White_Space" in the Unicode
<code title="">PropList.txt</code> data file. <a href="references.html#refsUNICODE">[UNICODE]</a></p>
<p class="note">This should not be confused with the "White_Space"
value (abbreviated "WS") of the "Bidi_Class" property in the <code title="">Unicode.txt</code> data file.</p>
<p>The <dfn id="alphanumeric-ascii-characters">alphanumeric ASCII characters</dfn> are those in the
ranges U+0030 DIGIT ZERO (0) to U+0039 DIGIT NINE (9), U+0041 LATIN
CAPITAL LETTER A to U+005A LATIN CAPITAL LETTER Z, U+0061 LATIN
SMALL LETTER A to U+007A LATIN SMALL LETTER Z.</p>
<p>Some of the micro-parsers described below follow the pattern of
having an <var title="">input</var> variable that holds the string
being parsed, and having a <var title="">position</var> variable
pointing at the next character to parse in <var title="">input</var>.</p>
<p>For parsers based on this pattern, a step that requires the user
agent to <dfn id="collect-a-sequence-of-characters">collect a sequence of characters</dfn> means that the
following algorithm must be run, with <var title="">characters</var>
being the set of characters that can be collected:</p>
<ol><li><p>Let <var title="">input</var> and <var title="">position</var> be the same variables as those of the same
name in the algorithm that invoked these steps.</p></li>
<li><p>Let <var title="">result</var> be the empty string.</p></li>
<li><p>While <var title="">position</var> doesn't point past the
end of <var title="">input</var> and the character at <var title="">position</var> is one of the <var title="">characters</var>, append that character to the end of <var title="">result</var> and advance <var title="">position</var> to
the next character in <var title="">input</var>.</p></li>
<li><p>Return <var title="">result</var>.</p></li>
</ol><p>The step <dfn id="skip-whitespace">skip whitespace</dfn> means that the user agent
must <a href="#collect-a-sequence-of-characters">collect a sequence of characters</a> that are <a href="#space-character" title="space character">space characters</a>. The step <dfn id="skip-white_space-characters">skip
White_Space characters</dfn> means that the user agent must
<a href="#collect-a-sequence-of-characters">collect a sequence of characters</a> that are
<a href="#white_space">White_Space</a> characters. In both cases, the collected
characters are not used. <a href="references.html#refsUNICODE">[UNICODE]</a></p>
<p>When a user agent is to <dfn id="strip-line-breaks">strip line breaks</dfn> from a
string, the user agent must remove any U+000A LINE FEED (LF) and
U+000D CARRIAGE RETURN (CR) characters from that string.</p>
<p>When a user agent is to <dfn id="strip-leading-and-trailing-whitespace">strip leading and trailing
whitespace</dfn> from a string, the user agent must remove all <a href="#space-character" title="space character">space characters</a> that are at the
start or end of the string.</p>
<p>The <dfn id="code-point-length">code-point length</dfn> of a string is the number of
Unicode code points in that string.</p>
</div><h4 id="boolean-attributes"><span class="secno">2.5.2 </span>Boolean attributes</h4><p>A number of attributes are <dfn id="boolean-attribute" title="boolean attribute">boolean
attributes</dfn>. The presence of a boolean attribute on an element
represents the true value, and the absence of the attribute
represents the false value.</p><p>If the attribute is present, its value must either be the empty
string or a value that is an <a href="infrastructure.html#ascii-case-insensitive">ASCII case-insensitive</a>
match for the attribute's canonical name, with no leading or
trailing whitespace.</p><p class="note">The values "true" and "false" are not allowed on
boolean attributes. To represent a false value, the attribute has to
be omitted altogether.</p><div class="example">
<p>Here is an example of a checkbox that is checked and disabled.
The <code title="attr-input-checked"><a href="the-input-element.html#attr-input-checked">checked</a></code> and <code title="attr-fe-disabled"><a href="association-of-controls-and-forms.html#attr-fe-disabled">disabled</a></code> attributes are the
boolean attributes.</p>
<pre>&lt;label&gt;&lt;input type=checkbox checked name=cheese disabled&gt; Cheese&lt;/label&gt;</pre>
<p>This could be equivalently written as this:
</p><pre>&lt;label&gt;&lt;input type=checkbox checked=checked name=cheese disabled=disabled&gt; Cheese&lt;/label&gt;</pre>
<p>You can also mix styles; the following is still equivalent:</p>
<pre>&lt;label&gt;&lt;input type='checkbox' checked name=cheese disabled=""&gt; Cheese&lt;/label&gt;</pre>
</div><h4 id="keywords-and-enumerated-attributes"><span class="secno">2.5.3 </span>Keywords and enumerated attributes</h4><p>Some attributes are defined as taking one of a finite set of
keywords. Such attributes are called <dfn id="enumerated-attribute" title="enumerated
attribute">enumerated attributes</dfn>. The keywords are each
defined to map to a particular <em>state</em> (several keywords
might map to the same state, in which case some of the keywords are
synonyms of each other; additionally, some of the keywords can be
said to be non-conforming, and are only in the specification for
historical reasons). In addition, two default states can be
given. The first is the <i>invalid value default</i>, the second
is the <i>missing value default</i>.</p><p>If an enumerated attribute is specified, the attribute's value
must be an <a href="infrastructure.html#ascii-case-insensitive">ASCII case-insensitive</a> match for one of the
given keywords that are not said to be non-conforming, with no
leading or trailing whitespace.</p><p>When the attribute is specified, if its value is an <a href="infrastructure.html#ascii-case-insensitive">ASCII
case-insensitive</a> match for one of the given keywords then
that keyword's state is the state that the attribute represents. If
the attribute value matches none of the given keywords, but the
attribute has an <i>invalid value default</i>, then the attribute
represents that state. Otherwise, if the attribute value matches
none of the keywords but there is a <i>missing value default</i>
state defined, then <em>that</em> is the state represented by the
attribute. Otherwise, there is no default, and invalid values must
be ignored.</p><p>When the attribute is <em>not</em> specified, if there is a
<i>missing value default</i> state defined, then that is the state
represented by the (missing) attribute. Otherwise, the absence of
the attribute means that there is no state represented.</p><p class="note">The empty string can be a valid keyword.</p><h4 id="numbers"><span class="secno">2.5.4 </span>Numbers</h4><h5 id="non-negative-integers"><span class="secno">2.5.4.1 </span>Non-negative integers</h5><p>A string is a <dfn id="valid-non-negative-integer">valid non-negative integer</dfn> if it
consists of one or more characters in the range U+0030 DIGIT ZERO
(0) to U+0039 DIGIT NINE (9).</p><p>A <a href="#valid-non-negative-integer">valid non-negative integer</a> represents the number
that is represented in base ten by that string of digits.</p><div class="impl">
<p>The <dfn id="rules-for-parsing-non-negative-integers">rules for parsing non-negative integers</dfn> are as
given in the following algorithm. When invoked, the steps must be
followed in the order given, aborting at the first step that returns
a value. This algorithm will return either zero, a positive integer,
or an error.</p>
<ol><li><p>Let <var title="">input</var> be the string being
parsed.</p></li>
<li><p>Let <var title="">position</var> be a pointer into <var title="">input</var>, initially pointing at the start of the
string.</p></li>
<li><p><a href="#skip-whitespace">Skip whitespace</a>.</p></li>
<li><p>If <var title="">position</var> is past the end of <var title="">input</var>, return an error.</p></li>
<li><p>If the character indicated by <var title="">position</var>
is a U+002B PLUS SIGN character (+), advance <var title="">position</var> to the next character. (The "<code title="">+</code>" is ignored, but it is not conforming.)</p></li>
<li><p>If <var title="">position</var> is past the end of <var title="">input</var>, return an error.</p></li>
<li><p>If the character indicated by <var title="">position</var>
is not one of U+0030 DIGIT ZERO (0) to U+0039 DIGIT NINE (9), then
return an error.</p></li>
<li><p><a href="#collect-a-sequence-of-characters">Collect a sequence of characters</a> in the range
U+0030 DIGIT ZERO (0) to U+0039 DIGIT NINE (9), and interpret the
resulting sequence as a base-ten integer. Let <var title="">value</var> be that integer.</p></li>
<li><p>Return <var title="">value</var>.</p></li>
</ol></div><h5 id="signed-integers"><span class="secno">2.5.4.2 </span>Signed integers</h5><p>A string is a <dfn id="valid-integer">valid integer</dfn> if it consists of one or
more characters in the range U+0030 DIGIT ZERO (0) to U+0039 DIGIT
NINE (9), optionally prefixed with a U+002D HYPHEN-MINUS character
(-).</p><p>A <a href="#valid-integer">valid integer</a> without a U+002D HYPHEN-MINUS (-)
prefix represents the number that is represented in base ten by that
string of digits. A <a href="#valid-integer">valid integer</a> <em>with</em> a
U+002D HYPHEN-MINUS (-) prefix represents the number represented in
base ten by the string of digits that follows the U+002D
HYPHEN-MINUS, subtracted from zero.</p><div class="impl">
<p>The <dfn id="rules-for-parsing-integers">rules for parsing integers</dfn> are similar to the
<a href="#rules-for-parsing-non-negative-integers" title="rules for parsing non-negative integers">rules for
non-negative integers</a>, and are as given in the following
algorithm. When invoked, the steps must be followed in the order
given, aborting at the first step that returns a value. This
algorithm will return either an integer or an error.</p>
<ol><li><p>Let <var title="">input</var> be the string being
parsed.</p></li>
<li><p>Let <var title="">position</var> be a pointer into <var title="">input</var>, initially pointing at the start of the
string.</p></li>
<li><p>Let <var title="">sign</var> have the value
"positive".</p></li>
<li><p><a href="#skip-whitespace">Skip whitespace</a>.</p></li>
<li><p>If <var title="">position</var> is past the end of <var title="">input</var>, return an error.</p></li>
<li>
<p>If the character indicated by <var title="">position</var> (the
first character) is a U+002D HYPHEN-MINUS character (-):</p>
<ol><li>Let <var title="">sign</var> be "negative".</li>
<li>Advance <var title="">position</var> to the next
character.</li>
<li>If <var title="">position</var> is past the end of <var title="">input</var>, return an error.</li>
</ol><p>Otherwise, if the character indicated by <var title="">position</var> (the first character) is a U+002B PLUS
SIGN character (+):</p>
<ol><li>Advance <var title="">position</var> to the next
character. (The "<code title="">+</code>" is ignored, but it is
not conforming.)</li>
<li>If <var title="">position</var> is past the end of <var title="">input</var>, return an error.</li>
</ol></li>
<li><p>If the character indicated by <var title="">position</var>
is not one of U+0030 DIGIT ZERO (0) to U+0039 DIGIT NINE (9), then
return an error.</p></li>
<li><p><a href="#collect-a-sequence-of-characters">Collect a sequence of characters</a> in the range
U+0030 DIGIT ZERO (0) to U+0039 DIGIT NINE (9), and interpret the
resulting sequence as a base-ten integer. Let <var title="">value</var> be that integer.</p></li>
<li><p>If <var title="">sign</var> is "positive", return <var title="">value</var>, otherwise return the result of subtracting
<var title="">value</var> from zero.</p></li>
</ol></div><h5 id="real-numbers"><span class="secno">2.5.4.3 </span>Real numbers</h5><p>A string is a <dfn id="valid-floating-point-number">valid floating point number</dfn> if it
consists of:</p><ol class="brief"><li>Optionally, a U+002D HYPHEN-MINUS character (-).</li>
<li>A series of one or more characters in the range U+0030 DIGIT
ZERO (0) to U+0039 DIGIT NINE (9).</li>
<li>Optionally:
<ol><li>A single U+002E FULL STOP character (.).</li>
<li>A series of one or more characters in the range U+0030 DIGIT
ZERO (0) to U+0039 DIGIT NINE (9).</li>
</ol></li>
<li>Optionally:
<ol><li>Either a U+0065 LATIN SMALL LETTER E character (e) or a
U+0045 LATIN CAPITAL LETTER E character (E).</li>
<li>Optionally, a U+002D HYPHEN-MINUS character (-) or U+002B
PLUS SIGN character (+).</li>
<li>A series of one or more characters in the range U+0030 DIGIT
ZERO (0) to U+0039 DIGIT NINE (9).</li>
</ol></li>
</ol><p>A <a href="#valid-floating-point-number">valid floating point number</a> represents the number
obtained by multiplying the significand by ten raised to the power
of the exponent, where the significand is the first number,
interpreted as base ten (including the decimal point and the number
after the decimal point, if any, and interpreting the significand as
a negative number if the whole string starts with a U+002D
HYPHEN-MINUS character (-) and the number is not zero), and where
the exponent is the number after the E, if any (interpreted as a
negative number if there is a U+002D HYPHEN-MINUS character (-)
between the E and the number and the number is not zero, or else
ignoring a U+002B PLUS SIGN character (+) between the E and the
number if there is one). If there is no E, then the exponent is
treated as zero.</p><p class="note">The Infinity and Not-a-Number (NaN) values are not
<a href="#valid-floating-point-number" title="valid floating point number">valid floating point
numbers</a>.</p><div class="impl">
<p>The <dfn id="best-representation-of-the-number-as-a-floating-point-number" title="best representation of the number as a floating
point number">best representation of the number <var title="">n</var> as a floating point number</dfn> is the string
obtained from applying the JavaScript operator ToString to <var title="">n</var>. The JavaScript operator ToString is not uniquely
determined. When there are multiple possible strings that could be
obtained from the JavaScript operator ToString for a particular
value, the user agent must always return the same string for that
value (though it may differ from the value used by other user
agents).</p>
<p>The <dfn id="rules-for-parsing-floating-point-number-values">rules for parsing floating point number values</dfn> are
as given in the following algorithm. This algorithm must be aborted
at the first step that returns something. This algorithm will return
either a number or an error.</p>
<ol><li><p>Let <var title="">input</var> be the string being
parsed.</p></li>
<li><p>Let <var title="">position</var> be a pointer into <var title="">input</var>, initially pointing at the start of the
string.</p></li>
<li><p>Let <var title="">value</var> have the value 1.</p></li>
<li><p>Let <var title="">divisor</var> have the value 1.</p></li>
<li><p>Let <var title="">exponent</var> have the value 1.</p></li>
<li><p><a href="#skip-whitespace">Skip whitespace</a>.</p></li>
<li><p>If <var title="">position</var> is past the end of <var title="">input</var>, return an error.</p></li>
<li>
<p>If the character indicated by <var title="">position</var> is a
U+002D HYPHEN-MINUS character (-):</p>
<ol><li>Change <var title="">value</var> and <var title="">divisor</var> to &#8722;1.</li>
<li>Advance <var title="">position</var> to the next
character.</li>
<li>If <var title="">position</var> is past the end of <var title="">input</var>, return an error.</li>
</ol><p>Otherwise, if the character indicated by <var title="">position</var> (the first character) is a U+002B PLUS
SIGN character (+):</p>
<ol><li>Advance <var title="">position</var> to the next
character. (The "<code title="">+</code>" is ignored, but it is
not conforming.)</li>
<li>If <var title="">position</var> is past the end of <var title="">input</var>, return an error.</li>
</ol></li>
<li><p>If the character indicated by <var title="">position</var>
is not one of U+0030 DIGIT ZERO (0) to U+0039 DIGIT NINE (9), then
return an error.</p></li>
<li><p><a href="#collect-a-sequence-of-characters">Collect a sequence of characters</a> in the range
U+0030 DIGIT ZERO (0) to U+0039 DIGIT NINE (9), and interpret the
resulting sequence as a base-ten integer. Multiply <var title="">value</var> by that integer.</p></li>
<li>If <var title="">position</var> is past the end of <var title="">input</var>, jump to the step labeled
<i>conversion</i>.</li>
<li><p>If the character indicated by <var title="">position</var>
is a U+002E FULL STOP (.), run these substeps:</p>
<ol><li><p>Advance <var title="">position</var> to the next
character.</p></li>
<li><p>If <var title="">position</var> is past the end of <var title="">input</var>, or if the character indicated by <var title="">position</var> is not one of U+0030 DIGIT ZERO (0) to
U+0039 DIGIT NINE (9), U+0065 LATIN SMALL LETTER E (e), or U+0045
LATIN CAPITAL LETTER E (E), then jump to the step labeled
<i>conversion</i>.</p></li>
<li><p>If the character indicated by <var title="">position</var>
is a U+0065 LATIN SMALL LETTER E character (e) or a U+0045 LATIN
CAPITAL LETTER E character (E), skip the remainder of these
substeps.</p>
</li><li><p><i>Fraction loop</i>: Multiply <var title="">divisor</var>
by ten.</p></li>
<li>Add the value of the character indicated by <var title="">position</var>, interpreted as a base-ten digit (0..9)
and divided by <var title="">divisor</var>, to <var title="">value</var>.</li>
<li><p>Advance <var title="">position</var> to the next
character.</p></li>
<li><p>If <var title="">position</var> is past the end of <var title="">input</var>, then jump to the step labeled
<i>conversion</i>.</p></li>
<li><p>If the character indicated by <var title="">position</var>
is one of U+0030 DIGIT ZERO (0) to U+0039 DIGIT NINE (9), jump
back to the step labeled <i>fraction loop</i> in these
substeps.</p></li>
</ol></li>
<li><p>If the character indicated by <var title="">position</var>
is a U+0065 LATIN SMALL LETTER E character (e) or a U+0045 LATIN
CAPITAL LETTER E character (E), run these substeps:</p>
<ol><li><p>Advance <var title="">position</var> to the next
character.</p></li>
<li><p>If <var title="">position</var> is past the end of <var title="">input</var>, then jump to the step labeled
<i>conversion</i>.</p></li>
<li>
<p>If the character indicated by <var title="">position</var> is
a U+002D HYPHEN-MINUS character (-):</p>
<ol><li>Change <var title="">exponent</var> to &#8722;1.</li>
<li>Advance <var title="">position</var> to the next
character.</li>
<li><p>If <var title="">position</var> is past the end of <var title="">input</var>, then jump to the step labeled
<i>conversion</i>.</p></li>
</ol><p>Otherwise, if the character indicated by <var title="">position</var> is a U+002B PLUS SIGN character (+):</p>
<ol><li>Advance <var title="">position</var> to the next
character.</li>
<li><p>If <var title="">position</var> is past the end of <var title="">input</var>, then jump to the step labeled
<i>conversion</i>.</p></li>
</ol></li>
<li><p>If the character indicated by <var title="">position</var>
is not one of U+0030 DIGIT ZERO (0) to U+0039 DIGIT NINE (9),
then jump to the step labeled <i>conversion</i>.</p></li>
<li><p><a href="#collect-a-sequence-of-characters">Collect a sequence of characters</a> in the range
U+0030 DIGIT ZERO (0) to U+0039 DIGIT NINE (9), and interpret the
resulting sequence as a base-ten integer. Multiply <var title="">exponent</var> by that integer.</p></li>
<li><p>Multiply <var title="">value</var> by ten raised to the
<var title="">exponent</var>th power.</p></li>
</ol></li>
<li><p><i>Conversion</i>: Let <var title="">S</var> be the set of
finite IEEE 754 double-precision floating point values except
&#8722;0, but with two special values added: 2<sup title="">1024</sup> and &#8722;2<sup title="">1024</sup>.</p></li>
<li><p>Let <var title="">rounded-value</var> be the number in <var title="">S</var> that is closest to <var title="">value</var>,
selecting the number with an even significand if there are two
equally close values. (The two special values 2<sup title="">1024</sup> and &#8722;2<sup title="">1024</sup> are
considered to have even significands for this purpose.)</p></li>
<li><p>If <var title="">rounded-value</var> is 2<sup title="">1024</sup> or &#8722;2<sup title="">1024</sup>, return an
error.</p></li>
<li><p>Return <var title="">rounded-value</var>.</p></li>
</ol></div><div class="impl">
<h5 id="percentages-and-dimensions"><span class="secno">2.5.4.4 </span>Percentages and lengths</h5>
<p>The <dfn id="rules-for-parsing-dimension-values">rules for parsing dimension values</dfn> are as given in
the following algorithm. When invoked, the steps must be followed in
the order given, aborting at the first step that returns a
value. This algorithm will return either a number greater than or
equal to 1.0, or an error; if a number is returned, then it is
further categorized as either a percentage or a length.</p>
<ol><li><p>Let <var title="">input</var> be the string being
parsed.</p></li>
<li><p>Let <var title="">position</var> be a pointer into <var title="">input</var>, initially pointing at the start of the
string.</p></li>
<li><p><a href="#skip-whitespace">Skip whitespace</a>.</p></li>
<li><p>If <var title="">position</var> is past the end of <var title="">input</var>, return an error.</p></li>
<li><p>If the character indicated by <var title="">position</var>
is a U+002B PLUS SIGN character (+), advance <var title="">position</var> to the next character.</p></li>
<li><p><a href="#collect-a-sequence-of-characters">Collect a sequence of characters</a> that are
U+0030 DIGIT ZERO (0) characters, and discard them.</p></li>
<li><p>If <var title="">position</var> is past the end of <var title="">input</var>, return an error.</p></li>
<li><p>If the character indicated by <var title="">position</var>
is not one of U+0031 DIGIT ONE (1) to U+0039 DIGIT NINE (9), then
return an error.</p></li>
<li><p><a href="#collect-a-sequence-of-characters">Collect a sequence of characters</a> in the range
U+0030 DIGIT ZERO (0) to U+0039 DIGIT NINE (9), and interpret the
resulting sequence as a base-ten integer. Let <var title="">value</var> be that number.</p></li>
<li><p>If <var title="">position</var> is past the end of <var title="">input</var>, return <var title="">value</var> as a
length.</p></li>
<li>
<p>If the character indicated by <var title="">position</var> is a
U+002E FULL STOP character (.):</p>
<ol><li><p>Advance <var title="">position</var> to the next
character.</p></li>
<li><p>If <var title="">position</var> is past the end of <var title="">input</var>, or if the character indicated by <var title="">position</var> is not one of U+0030 DIGIT ZERO (0) to
U+0039 DIGIT NINE (9), then return <var title="">value</var> as a
length.</p></li>
<li><p>Let <var title="">divisor</var> have the value 1.</p></li>
<li><p><i>Fraction loop</i>: Multiply <var title="">divisor</var>
by ten.</p></li>
<li>Add the value of the character indicated by <var title="">position</var>, interpreted as a base-ten digit (0..9)
and divided by <var title="">divisor</var>, to <var title="">value</var>.</li>
<li><p>Advance <var title="">position</var> to the next
character.</p></li>
<li><p>If <var title="">position</var> is past the end of <var title="">input</var>, then return <var title="">value</var> as a
length.</p></li>
<li><p>If the character indicated by <var title="">position</var>
is one of U+0030 DIGIT ZERO (0) to U+0039 DIGIT NINE (9), return
to the step labeled <i>fraction loop</i> in these
substeps.</p></li>
</ol></li>
<li><p>If <var title="">position</var> is past the end of <var title="">input</var>, return <var title="">value</var> as a
length.</p></li>
<li><p>If the character indicated by <var title="">position</var>
is a U+0025 PERCENT SIGN character (%), return <var title="">value</var> as a percentage.</p></li>
<li><p>Return <var title="">value</var> as a length.</p></li>
</ol></div><h5 id="lists-of-integers"><span class="secno">2.5.4.5 </span>Lists of integers</h5><p>A <dfn id="valid-list-of-integers">valid list of integers</dfn> is a number of <a href="#valid-integer" title="valid integer">valid integers</a> separated by U+002C
COMMA characters, with no other characters (e.g. no <a href="#space-character" title="space character">space characters</a>). In addition, there
might be restrictions on the number of integers that can be given,
or on the range of values allowed.</p><div class="impl">
<p>The <dfn id="rules-for-parsing-a-list-of-integers">rules for parsing a list of integers</dfn> are as
follows:</p>
<ol><li><p>Let <var title="">input</var> be the string being
parsed.</p></li>
<li><p>Let <var title="">position</var> be a pointer into <var title="">input</var>, initially pointing at the start of the
string.</p></li>
<li><p>Let <var title="">numbers</var> be an initially empty list
of integers. This list will be the result of this
algorithm.</p></li>
<li><p>If there is a character in the string <var title="">input</var> at position <var title="">position</var>, and
it is either a U+0020 SPACE, U+002C COMMA, or U+003B SEMICOLON
character, then advance <var title="">position</var> to the next
character in <var title="">input</var>, or to beyond the end of the
string if there are no more characters.</p></li>
<li><p>If <var title="">position</var> points to beyond the end of
<var title="">input</var>, return <var title="">numbers</var> and
abort.</p></li>
<li><p>If the character in the string <var title="">input</var> at
position <var title="">position</var> is a U+0020 SPACE, U+002C
COMMA, or U+003B SEMICOLON character, then return to step 4.</p></li>
<li><p>Let <var title="">negated</var> be false.</p></li>
<li><p>Let <var title="">value</var> be 0.</p></li>
<li><p>Let <var title="">started</var> be false. This variable is
set to true when the parser sees a number or a U+002D HYPHEN-MINUS
character (-).</p></li>
<li><p>Let <var title="">got number</var> be false. This variable
is set to true when the parser sees a number.</p></li>
<li><p>Let <var title="">finished</var> be false. This variable is
set to true to switch parser into a mode where it ignores
characters until the next separator.</p></li>
<li><p>Let <var title="">bogus</var> be false.</p></li>
<li><p><i>Parser</i>: If the character in the string <var title="">input</var> at position <var title="">position</var>
is:</p>
<dl class="switch"><dt>A U+002D HYPHEN-MINUS character</dt>
<dd>
<p>Follow these substeps:</p>
<ol><li>If <var title="">got number</var> is true, let <var title="">finished</var> be true.</li>
<li>If <var title="">finished</var> is true, skip to the next
step in the overall set of steps.</li>
<li>If <var title="">started</var> is true, let <var title="">negated</var> be false.</li>
<li>Otherwise, if <var title="">started</var> is false and if <var title="">bogus</var> is false, let <var title="">negated</var>
be true.</li>
<li>Let <var title="">started</var> be true.</li>
</ol></dd>
<dt>A character in the range U+0030 DIGIT ZERO (0) to U+0039 DIGIT
NINE (9)</dt>
<dd>
<p>Follow these substeps:</p>
<ol><li>If <var title="">finished</var> is true, skip to the next
step in the overall set of steps.</li>
<li>Multiply <var title="">value</var> by ten.</li>
<li>Add the value of the digit, interpreted in base ten, to
<var title="">value</var>.</li>
<li>Let <var title="">started</var> be true.</li>
<li>Let <var title="">got number</var> be true.</li>
</ol></dd>
<dt>A U+0020 SPACE character</dt>
<dt>A U+002C COMMA character</dt>
<dt>A U+003B SEMICOLON character</dt>
<dd>
<p>Follow these substeps:</p>
<ol><li>If <var title="">got number</var> is false, return the <var title="">numbers</var> list and abort. This happens if an entry
in the list has no digits, as in "<code title="">1,2,x,4</code>".</li>
<li>If <var title="">negated</var> is true, then negate <var title="">value</var>.</li>
<li>Append <var title="">value</var> to the <var title="">numbers</var> list.</li>
<li>Jump to step 4 in the overall set of steps.</li>
</ol></dd>
<dt>A character in the range U+0001 to U+001F, U+0021 to U+002B, U+002D to U+002F, U+003A, U+003C to U+0040, U+005B to U+0060, <!-- A-Z --> U+007b to U+007F
(i.e. any other non-alphabetic ASCII character)</dt>
<dd>
<p>Follow these substeps:</p>
<ol><li>If <var title="">got number</var> is true, let <var title="">finished</var> be true.</li>
<li>If <var title="">finished</var> is true, skip to the next
step in the overall set of steps.</li>
<li>Let <var title="">negated</var> be false.</li>
</ol></dd>
<dt>Any other character</dt>
<dd>
<p>Follow these substeps:</p>
<ol><li>If <var title="">finished</var> is true, skip to the next
step in the overall set of steps.</li>
<li>Let <var title="">negated</var> be false.</li>
<li>Let <var title="">bogus</var> be true.</li>
<li>If <var title="">started</var> is true, then return the
<var title="">numbers</var> list, and abort. (The value in <var title="">value</var> is not appended to the list first; it is
dropped.)</li>
</ol></dd>
</dl></li>
<li><p>Advance <var title="">position</var> to the next character
in <var title="">input</var>, or to beyond the end of the string if
there are no more characters.</p></li>
<li><p>If <var title="">position</var> points to a character (and
not to beyond the end of <var title="">input</var>), jump to the
big <i>Parser</i> step above.</p></li>
<li><p>If <var title="">negated</var> is true, then negate <var title="">value</var>.</p></li>
<li><p>If <var title="">got number</var> is true, then append <var title="">value</var> to the <var title="">numbers</var> list.</p></li>
<li><p>Return the <var title="">numbers</var> list and
abort.</p></li>
</ol></div><div class="impl">
<h5 id="lists-of-dimensions"><span class="secno">2.5.4.6 </span>Lists of dimensions</h5>
<p>The <dfn id="rules-for-parsing-a-list-of-dimensions">rules for parsing a list of dimensions</dfn> are as
follows. These rules return a list of zero or more pairs consisting
of a number and a unit, the unit being one of <i>percentage</i>,
<i>relative</i>, and <i>absolute</i>.</p>
<ol><li><p>Let <var title="">raw input</var> be the string being
parsed.</p></li>
<li><p>If the last character in <var title="">raw input</var> is a
U+002C COMMA character (,), then remove that character from <var title="">raw input</var>.</p></li>
<li><p><a href="#split-a-string-on-commas" title="split a string on commas">Split the string <var title="">raw input</var> on commas</a>. Let <var title="">raw
tokens</var> be the resulting list of tokens.</p></li>
<li><p>Let <var title="">result</var> be an empty list of
number/unit pairs.</p></li>
<li>
<p>For each token in <var title="">raw tokens</var>, run the
following substeps:</p>
<ol><li><p>Let <var title="">input</var> be the token.</p></li>
<li><p>Let <var title="">position</var> be a pointer into <var title="">input</var>, initially pointing at the start of the
string.</p></li>
<li><p>Let <var title="">value</var> be the number 0.</p></li>
<li><p>Let <var title="">unit</var> be <i>absolute</i>.</p></li>
<li><p>If <var title="">position</var> is past the end of <var title="">input</var>, set <var title="">unit</var> to
<i>relative</i> and jump to the last substep.</p></li>
<li><p>If the character at <var title="">position</var> is a
character in the range U+0030 DIGIT ZERO (0) to U+0039 DIGIT NINE
(9), <a href="#collect-a-sequence-of-characters">collect a sequence of characters</a> in the range
U+0030 DIGIT ZERO (0) to U+0039 DIGIT NINE (9), interpret the
resulting sequence as an integer in base ten, and increment <var title="">value</var> by that integer.</p></li>
<li>
<p>If the character at <var title="">position</var> is a U+002E
FULL STOP character (.), run these substeps:</p>
<ol><li><p><a href="#collect-a-sequence-of-characters">Collect a sequence of characters</a> consisting
of <a href="#space-character" title="space character">space characters</a> and
characters in the range U+0030 DIGIT ZERO (0) to U+0039 DIGIT
NINE (9). Let <var title="">s</var> be the resulting
sequence.</p></li>
<li><p>Remove all <a href="#space-character" title="space character">space
characters</a> in <var title="">s</var>.</p></li>
<li>
<p>If <var title="">s</var> is not the empty string, run these
subsubsteps:</p>
<ol><li><p>Let <var title="">length</var> be the number of
characters in <var title="">s</var> (after the spaces were
removed).</p></li>
<li><p>Let <var title="">fraction</var> be the result of
interpreting <var title="">s</var> as a base-ten integer, and
then dividing that number by <span title="">10<sup title=""><var title="">length</var></sup></span>.</p></li>
<li><p>Increment <var title="">value</var> by <var title="">fraction</var>.</p></li>
</ol></li>
</ol></li>
<li><p><a href="#skip-whitespace">Skip whitespace</a>.</p></li>
<li>
<p>If the character at <var title="">position</var> is a U+0025
PERCENT SIGN character (%), then set <var title="">unit</var> to
<i>percentage</i>.</p>
<p>Otherwise, if the character at <var title="">position</var>
is a U+002A ASTERISK character (*), then set <var title="">unit</var> to <i>relative</i>.</p>
</li>
<li><p>Add an entry to <var title="">result</var> consisting of
the number given by <var title="">value</var> and the unit given
by <var title="">unit</var>.</p></li>
</ol></li>
<li><p>Return the list <var title="">result</var>.</p></li>
</ol></div><h4 id="dates-and-times"><span class="secno">2.5.5 </span>Dates and times</h4><p>In the algorithms below, the <dfn id="number-of-days-in-month-month-of-year-year">number of days in month <var title="">month</var> of year <var title="">year</var></dfn> is:
<em>31</em> if <var title="">month</var> is 1, 3, 5, 7, 8, 10, or
12; <em>30</em> if <var title="">month</var> is 4, 6, 9, or 11;
<em>29</em> if <var title="">month</var> is 2 and <var title="">year</var> is a number divisible by 400, or if <var title="">year</var> is a number divisible by 4 but not by 100; and
<em>28</em> otherwise. This takes into account leap years in the
Gregorian calendar. <a href="references.html#refsGREGORIAN">[GREGORIAN]</a></p><p>The <dfn id="concept-datetime-digit" title="concept-datetime-digit">digits</dfn> in the date
and time syntaxes defined in this section must be characters in the
range U+0030 DIGIT ZERO (0) to U+0039 DIGIT NINE (9), used to
express numbers in base ten.</p><div class="impl">
<p class="note">While the formats described here are intended to be
subsets of the corresponding ISO8601 formats, this specification
defines parsing rules in much more detail than ISO8601.
Implementors are therefore encouraged to carefully examine any date
parsing libraries before using them to implement the parsing rules
described below; ISO8601 libraries might not parse dates and times
in exactly the same manner. <a href="references.html#refsISO8601">[ISO8601]</a></p>
</div><h5 id="months"><span class="secno">2.5.5.1 </span>Months</h5><p>A <dfn id="concept-month" title="concept-month">month</dfn> consists of a specific
proleptic Gregorian date with no time-zone information and no date
information beyond a year and a month. <a href="references.html#refsGREGORIAN">[GREGORIAN]</a></p><p>A string is a <dfn id="valid-month-string">valid month string</dfn> representing a year
<var title="">year</var> and month <var title="">month</var> if it
consists of the following components in the given order:</p><ol><li>Four or more <a href="#concept-datetime-digit" title="concept-datetime-digit">digits</a>, representing <var title="">year</var>, where <var title="">year</var>&#160;&gt;&#160;0</li>
<li>A U+002D HYPHEN-MINUS character (-)</li>
<li>Two <a href="#concept-datetime-digit" title="concept-datetime-digit">digits</a>,
representing the month <var title="">month</var>, in the range
1&#160;&#8804;&#160;<var title="">month</var>&#160;&#8804;&#160;12</li>
</ol><div class="impl">
<p>The rules to <dfn id="parse-a-month-string">parse a month string</dfn> are as follows. This
will return either a year and month, or nothing. If at any point the
algorithm says that it "fails", this means that it is aborted at
that point and returns nothing.</p>
<ol><li><p>Let <var title="">input</var> be the string being
parsed.</p></li>
<li><p>Let <var title="">position</var> be a pointer into <var title="">input</var>, initially pointing at the start of the
string.</p></li>
<li><p><a href="#parse-a-month-component">Parse a month component</a> to obtain <var title="">year</var> and <var title="">month</var>. If this returns
nothing, then fail.</p>
</li><li><p>If <var title="">position</var> is <em>not</em> beyond the
end of <var title="">input</var>, then fail.</p></li>
<li><p>Return <var title="">year</var> and <var title="">month</var>.</p></li>
</ol><p>The rules to <dfn id="parse-a-month-component">parse a month component</dfn>, given an <var title="">input</var> string and a <var title="">position</var>, are
as follows. This will return either a year and a month, or
nothing. If at any point the algorithm says that it "fails", this
means that it is aborted at that point and returns nothing.</p>
<ol><li><p><a href="#collect-a-sequence-of-characters">Collect a sequence of characters</a> in the range
U+0030 DIGIT ZERO (0) to U+0039 DIGIT NINE (9). If the collected
sequence is not at least four characters long, then
fail. Otherwise, interpret the resulting sequence as a base-ten
integer. Let that number be the <var title="">year</var>.</p></li>
<li><p>If <var title="">year</var> is not a number greater than
zero, then fail.</p></li>
<li><p>If <var title="">position</var> is beyond the end of <var title="">input</var> or if the character at <var title="">position</var> is not a U+002D HYPHEN-MINUS character,
then fail. Otherwise, move <var title="">position</var> forwards
one character.</p></li>
<li><p><a href="#collect-a-sequence-of-characters">Collect a sequence of characters</a> in the range
U+0030 DIGIT ZERO (0) to U+0039 DIGIT NINE (9). If the collected
sequence is not exactly two characters long, then fail. Otherwise,
interpret the resulting sequence as a base-ten integer. Let that
number be the <var title="">month</var>.</p></li>
<li><p>If <var title="">month</var> is not a number in the range
1&#160;&#8804;&#160;<var title="">month</var>&#160;&#8804;&#160;12, then
fail.</p></li>
<li><p>Return <var title="">year</var> and <var title="">month</var>.</p></li>
</ol></div><h5 id="dates"><span class="secno">2.5.5.2 </span>Dates</h5><p>A <dfn id="concept-date" title="concept-date">date</dfn> consists of a specific
proleptic Gregorian date with no time-zone information, consisting
of a year, a month, and a day. <a href="references.html#refsGREGORIAN">[GREGORIAN]</a></p><p>A string is a <dfn id="valid-date-string">valid date string</dfn> representing a year
<var title="">year</var>, month <var title="">month</var>, and day
<var title="">day</var> if it consists of the following components
in the given order:</p><ol><li>A <a href="#valid-month-string">valid month string</a>, representing <var title="">year</var> and <var title="">month</var></li>
<li>A U+002D HYPHEN-MINUS character (-)</li>
<li>Two <a href="#concept-datetime-digit" title="concept-datetime-digit">digits</a>,
representing <var title="">day</var>, in the range
1&#160;&#8804;&#160;<var title="">day</var>&#160;&#8804;&#160;<var title="">maxday</var> where <var title="">maxday</var> is the <a href="#number-of-days-in-month-month-of-year-year" title="number of days in month month of year year">number of days
in the month <var title="">month</var> and year <var title="">year</var></a></li>
</ol><div class="impl">
<p>The rules to <dfn id="parse-a-date-string">parse a date string</dfn> are as follows. This
will return either a date, or nothing. If at any point the algorithm
says that it "fails", this means that it is aborted at that point
and returns nothing.</p>
<ol><li><p>Let <var title="">input</var> be the string being
parsed.</p></li>
<li><p>Let <var title="">position</var> be a pointer into <var title="">input</var>, initially pointing at the start of the
string.</p></li>
<li><p><a href="#parse-a-date-component">Parse a date component</a> to obtain <var title="">year</var>, <var title="">month</var>, and <var title="">day</var>. If this returns nothing, then fail.</p>
</li><li><p>If <var title="">position</var> is <em>not</em> beyond the
end of <var title="">input</var>, then fail.</p></li>
<li><p>Let <var title="">date</var> be the date with year <var title="">year</var>, month <var title="">month</var>, and day <var title="">day</var>.</p></li>
<li><p>Return <var title="">date</var>.</p></li>
</ol><p>The rules to <dfn id="parse-a-date-component">parse a date component</dfn>, given an <var title="">input</var> string and a <var title="">position</var>, are
as follows. This will return either a year, a month, and a day, or
nothing. If at any point the algorithm says that it "fails", this
means that it is aborted at that point and returns nothing.</p>
<ol><li><p><a href="#parse-a-month-component">Parse a month component</a> to obtain <var title="">year</var> and <var title="">month</var>. If this returns
nothing, then fail.</p></li>
<li><p>Let <var title="">maxday</var> be the <a href="#number-of-days-in-month-month-of-year-year">number of days
in month <var title="">month</var> of year <var title="">year</var></a>.</p></li>
<li><p>If <var title="">position</var> is beyond the end of <var title="">input</var> or if the character at <var title="">position</var> is not a U+002D HYPHEN-MINUS character,
then fail. Otherwise, move <var title="">position</var> forwards
one character.</p></li>
<li><p><a href="#collect-a-sequence-of-characters">Collect a sequence of characters</a> in the range
U+0030 DIGIT ZERO (0) to U+0039 DIGIT NINE (9). If the collected
sequence is not exactly two characters long, then fail. Otherwise,
interpret the resulting sequence as a base-ten integer. Let that
number be the <var title="">day</var>.</p></li>
<li><p>If <var title="">day</var> is not a number in the range
1&#160;&#8804;&#160;<var title="">day</var>&#160;&#8804;&#160;<var title="">maxday</var>, then fail.</p></li>
<li><p>Return <var title="">year</var>, <var title="">month</var>,
and <var title="">day</var>.</p></li>
</ol></div><h5 id="times"><span class="secno">2.5.5.3 </span>Times</h5><p>A <dfn id="concept-time" title="concept-time">time</dfn> consists of a specific
time with no time-zone information, consisting of an hour, a minute,
a second, and a fraction of a second.</p><p>A string is a <dfn id="valid-time-string">valid time string</dfn> representing an hour
<var title="">hour</var>, a minute <var title="">minute</var>, and a
second <var title="">second</var> if it consists of the following
components in the given order:</p><ol><li>Two <a href="#concept-datetime-digit" title="concept-datetime-digit">digits</a>,
representing <var title="">hour</var>, in the range
0&#160;&#8804;&#160;<var title="">hour</var>&#160;&#8804;&#160;23</li>
<li>A U+003A COLON character (:)</li>
<li>Two <a href="#concept-datetime-digit" title="concept-datetime-digit">digits</a>,
representing <var title="">minute</var>, in the range
0&#160;&#8804;&#160;<var title="">minute</var>&#160;&#8804;&#160;59</li>
<li>Optionally (required if <var title="">second</var> is
non-zero):
<ol><li>A U+003A COLON character (:)</li>
<li>Two <a href="#concept-datetime-digit" title="concept-datetime-digit">digits</a>,
representing the integer part of <var title="">second</var>, in
the range 0&#160;&#8804;&#160;<var title="">s</var>&#160;&#8804;&#160;59</li>
<li>Optionally (required if <var title="">second</var> is not an
integer):
<ol><li>A 002E FULL STOP character (.)</li>
<li>One or more <a href="#concept-datetime-digit" title="concept-datetime-digit">digits</a>, representing the
fractional part of <var title="">second</var></li>
</ol></li>
</ol></li>
</ol><p class="note">The <var title="">second</var> component cannot be
60 or 61; leap seconds cannot be represented.</p><div class="impl">
<p>The rules to <dfn id="parse-a-time-string">parse a time string</dfn> are as follows. This
will return either a time, or nothing. If at any point the algorithm
says that it "fails", this means that it is aborted at that point
and returns nothing.</p>
<ol><li><p>Let <var title="">input</var> be the string being
parsed.</p></li>
<li><p>Let <var title="">position</var> be a pointer into <var title="">input</var>, initially pointing at the start of the
string.</p></li>
<li><p><a href="#parse-a-time-component">Parse a time component</a> to obtain <var title="">hour</var>, <var title="">minute</var>, and <var title="">second</var>. If this returns nothing, then fail.</p>
</li><li><p>If <var title="">position</var> is <em>not</em> beyond the
end of <var title="">input</var>, then fail.</p></li>
<li><p>Let <var title="">time</var> be the time with hour <var title="">hour</var>, minute <var title="">minute</var>, and second
<var title="">second</var>.</p></li>
<li><p>Return <var title="">time</var>.</p></li>
</ol><p>The rules to <dfn id="parse-a-time-component">parse a time component</dfn>, given an <var title="">input</var> string and a <var title="">position</var>, are
as follows. This will return either an hour, a minute, and a second,
or nothing. If at any point the algorithm says that it "fails", this
means that it is aborted at that point and returns nothing.</p>
<ol><li><p><a href="#collect-a-sequence-of-characters">Collect a sequence of characters</a> in the range
U+0030 DIGIT ZERO (0) to U+0039 DIGIT NINE (9). If the collected
sequence is not exactly two characters long, then fail. Otherwise,
interpret the resulting sequence as a base-ten integer. Let that
number be the <var title="">hour</var>.</p></li>
<li>If <var title="">hour</var> is not a number in the range
0&#160;&#8804;&#160;<var title="">hour</var>&#160;&#8804;&#160;23, then
fail.</li>
<li><p>If <var title="">position</var> is beyond the end of <var title="">input</var> or if the character at <var title="">position</var> is not a U+003A COLON character, then
fail. Otherwise, move <var title="">position</var> forwards one
character.</p></li>
<li><p><a href="#collect-a-sequence-of-characters">Collect a sequence of characters</a> in the range
U+0030 DIGIT ZERO (0) to U+0039 DIGIT NINE (9). If the collected
sequence is not exactly two characters long, then fail. Otherwise,
interpret the resulting sequence as a base-ten integer. Let that
number be the <var title="">minute</var>.</p></li>
<li>If <var title="">minute</var> is not a number in the range
0&#160;&#8804;&#160;<var title="">minute</var>&#160;&#8804;&#160;59, then
fail.</li>
<li><p>Let <var title="">second</var> be a string with the value
"0".</p></li>
<li>
<p>If <var title="">position</var> is not beyond the end of
<var title="">input</var> and the character at <var title="">position</var> is a U+003A COLON, then run these
substeps:</p>
<ol><li><p>Advance <var title="">position</var> to the next character
in <var title="">input</var>.</p></li>
<li><p>If <var title="">position</var> is beyond the end of <var title="">input</var>, or at the last character in <var title="">input</var>, or if the next <em>two</em> characters in
<var title="">input</var> starting at <var title="">position</var> are not two characters both in the range
U+0030 DIGIT ZERO (0) to U+0039 DIGIT NINE (9), then
fail.</p></li>
<li><p><a href="#collect-a-sequence-of-characters">Collect a sequence of characters</a> that are
either characters in the range U+0030 DIGIT ZERO (0) to U+0039
DIGIT NINE (9) or U+002E FULL STOP characters. If the collected
sequence has more than one U+002E FULL STOP characters, or if the
last character in the sequence is a U+002E FULL STOP character,
then fail. Otherwise, let the collected string be <var title="">second</var> instead of its previous value.</p></li>
</ol></li>
<li><p>Interpret <var title="">second</var> as a base-ten number
(possibly with a fractional part). Let <var title="">second</var>
be that number instead of the string version.</p></li>
<li><p>If <var title="">second</var> is not a number in the range
0&#160;&#8804;&#160;<var title="">second</var>&#160;&lt;&#160;60, then
fail.</p></li>
<li><p>Return <var title="">hour</var>, <var title="">minute</var>,
and <var title="">second</var>.</p></li>
</ol></div><h5 id="local-dates-and-times"><span class="secno">2.5.5.4 </span>Local dates and times</h5><p>A <dfn id="concept-datetime-local" title="concept-datetime-local">local date and time</dfn>
consists of a specific proleptic Gregorian date, consisting of a
year, a month, and a day, and a time, consisting of an hour, a
minute, a second, and a fraction of a second, but expressed without
a time zone. <a href="references.html#refsGREGORIAN">[GREGORIAN]</a></p><p>A string is a <dfn id="valid-local-date-and-time-string">valid local date and time string</dfn>
representing a date and time if it consists of the following
components in the given order:</p><ol><li>A <a href="#valid-date-string">valid date string</a> representing the date.</li>
<li>A U+0054 LATIN CAPITAL LETTER T character (T).</li>
<li>A <a href="#valid-time-string">valid time string</a> representing the time.</li>
</ol><div class="impl">
<p>The rules to <dfn id="parse-a-local-date-and-time-string">parse a local date and time string</dfn> are as
follows. This will return either a date and time, or nothing. If at
any point the algorithm says that it "fails", this means that it is
aborted at that point and returns nothing.</p>
<ol><li><p>Let <var title="">input</var> be the string being
parsed.</p></li>
<li><p>Let <var title="">position</var> be a pointer into <var title="">input</var>, initially pointing at the start of the
string.</p></li>
<li><p><a href="#parse-a-date-component">Parse a date component</a> to obtain <var title="">year</var>, <var title="">month</var>, and <var title="">day</var>. If this returns nothing, then fail.</p>
</li><li><p>If <var title="">position</var> is beyond the end of <var title="">input</var> or if the character at <var title="">position</var> is not a U+0054 LATIN CAPITAL LETTER T
character (T) then fail. Otherwise, move <var title="">position</var> forwards one character.</p></li>
<li><p><a href="#parse-a-time-component">Parse a time component</a> to obtain <var title="">hour</var>, <var title="">minute</var>, and <var title="">second</var>. If this returns nothing, then fail.</p>
</li><li><p>If <var title="">position</var> is <em>not</em> beyond the
end of <var title="">input</var>, then fail.</p></li>
<li><p>Let <var title="">date</var> be the date with year <var title="">year</var>, month <var title="">month</var>, and day <var title="">day</var>.</p></li>
<li><p>Let <var title="">time</var> be the time with hour <var title="">hour</var>, minute <var title="">minute</var>, and second
<var title="">second</var>.</p></li>
<li><p>Return <var title="">date</var> and <var title="">time</var>.</p></li>
</ol></div><h5 id="global-dates-and-times"><span class="secno">2.5.5.5 </span>Global dates and times</h5><p>A <dfn id="concept-datetime" title="concept-datetime">global date and time</dfn>
consists of a specific proleptic Gregorian date, consisting of a
year, a month, and a day, and a time, consisting of an hour, a
minute, a second, and a fraction of a second, expressed with a
time-zone offset, consisting of a signed number of hours and
minutes. <a href="references.html#refsGREGORIAN">[GREGORIAN]</a></p><p>A string is a <dfn id="valid-global-date-and-time-string">valid global date and time string</dfn>
representing a date, time, and a time-zone offset if it consists of
the following components in the given order:</p><ol><li>A <a href="#valid-date-string">valid date string</a> representing the date</li>
<li>A U+0054 LATIN CAPITAL LETTER T character (T)</li>
<li>A <a href="#valid-time-string">valid time string</a> representing the time</li>
<li>Either:
<ul><li>A U+005A LATIN CAPITAL LETTER Z character (Z), allowed only
if the time zone is UTC</li>
<li>Or:
<ol><li>Either a U+002B PLUS SIGN character (+) or, if the
time-zone offset is not zero, a U+002D HYPHEN-MINUS character
(-), representing the sign of the time-zone offset</li>
<li>Two <a href="#concept-datetime-digit" title="concept-datetime-digit">digits</a>,
representing the hours component <var title="">hour</var> of
the time-zone offset, in the range 0&#160;&#8804;&#160;<var title="">hour</var>&#160;&#8804;&#160;23</li>
<li>A U+003A COLON character (:)</li>
<li>Two <a href="#concept-datetime-digit" title="concept-datetime-digit">digits</a>,
representing the minutes component <var title="">minute</var>
of the time-zone offset, in the range 0&#160;&#8804;&#160;<var title="">minute</var>&#160;&#8804;&#160;59</li>
</ol></li>
</ul></li>
</ol><p class="note">This format allows for time-zone offsets from -23:59
to +23:59. In practice, however, the range of offsets of actual time
zones is -12:00 to +14:00, and the minutes component of offsets of
actual time zones is always either 00, 30, or 45.</p><p>Times in dates before the formation of UTC in the mid twentieth
century must be expressed and interpreted in terms of UT1
(contemporary Earth solar time at the 0&#176; longitude), not UTC
(the approximation of UT1 that ticks in SI seconds). Time before the
formation of time zones must be expressed and interpeted as UT1
times with explicit time zones that approximate the contemporary
difference between the appropriate local time and the time observed
at the location of Greenwich, London.</p><div class="example">
<p>The following are some examples of dates written as <a href="#valid-global-date-and-time-string" title="valid global date and time string">valid global date and
time strings</a>.</p>
<dl><dt>"<code>0037-12-13T00:00Z</code>"</dt>
<dd>Midnight in areas using London time on the birthday of Nero
(the Roman Emperor). See below for further discussion on which
date this actually corresponds to.</dd>
<dt>"<code>1979-10-14T12:00:00.001-04:00</code>"</dt>
<dd>One millisecond after noon on October 14th 1979, in the time
zone in use on the east coast of the USA during daylight saving
time.</dd>
<dt>"<code>8592-01-01T02:09+02:09</code>"</dt>
<dd>Midnight UTC on the 1st of January, 8592. The time zone
associated with that time is two hours and nine minutes ahead of
UTC, which is not currently a real time zone, but is nonetheless
allowed.</dd>
</dl><p>Several things are notable about these dates:</p>
<ul><li>Years with fewer than four digits have to be
zero-padded. The date "37-12-13" would not be a valid date.</li>
<li>To unambiguously identify a moment in time prior to the
introduction of the Gregorian calendar (insofar as moments in time
before the formation of UTC can be unambiguously identified), the
date has to be first converted to the Gregorian calendar from the
calendar in use at the time (e.g. from the Julian calendar). The
date of Nero's birth is the 15th of December 37, in the Julian
Calendar, which is the 13th of December 37 in the proleptic
Gregorian Calendar.</li>
<li>The time and time-zone offset components are not optional.</li>
<li>Dates before the year one can't be represented as a datetime
in this version of HTML.</li>
<li>Times of specific events in ancient times are, at best,
approximations, since time was not well coordinated or measured
until relatively recent decades.</li>
<li>Time-zone offsets differ based on daylight savings time.</li>
</ul></div><div class="impl">
<p>The <dfn id="best-representation-of-the-global-date-and-time-string">best representation of the global date and time
string</dfn> <var title="">datetime</var> is the <a href="#valid-global-date-and-time-string">valid global
date and time string</a> representing <var title="">datetime</var>, with the <a href="#valid-time-string">valid time string</a>
component being given in its shortest possible form, with the last
character of the string not being a U+005A LATIN CAPITAL LETTER Z
character (Z), even if the time zone is UTC, and with a U+002B PLUS
SIGN character (+) representing the sign of the time-zone offset
when the time zone is UTC.</p>
<p>The rules to <dfn id="parse-a-global-date-and-time-string">parse a global date and time string</dfn> are
as follows. This will return either a time in UTC, with associated
time-zone offset information for round-tripping or display purposes,
or nothing. If at any point the algorithm says that it "fails", this
means that it is aborted at that point and returns nothing.</p>
<ol><li><p>Let <var title="">input</var> be the string being
parsed.</p></li>
<li><p>Let <var title="">position</var> be a pointer into <var title="">input</var>, initially pointing at the start of the
string.</p></li>
<li><p><a href="#parse-a-date-component">Parse a date component</a> to obtain <var title="">year</var>, <var title="">month</var>, and <var title="">day</var>. If this returns nothing, then fail.</p>
</li><li><p>If <var title="">position</var> is beyond the end of <var title="">input</var> or if the character at <var title="">position</var> is not a U+0054 LATIN CAPITAL LETTER T
character (T) then fail. Otherwise, move <var title="">position</var> forwards one character.</p></li>
<li><p><a href="#parse-a-time-component">Parse a time component</a> to obtain <var title="">hour</var>, <var title="">minute</var>, and <var title="">second</var>. If this returns nothing, then fail.</p>
</li><li><p>If <var title="">position</var> is beyond the end of <var title="">input</var>, then fail.</p></li>
<li><p><a href="#parse-a-time-zone-offset-component">Parse a time-zone offset component</a> to obtain
<var title="">timezone<sub title="">hours</sub></var> and <var title="">timezone<sub title="">minutes</sub></var>. If this returns
nothing, then fail.</p>
</li><li><p>If <var title="">position</var> is <em>not</em> beyond the
end of <var title="">input</var>, then fail.</p></li>
<li><p>Let <var title="">time</var> be the moment in time at year
<var title="">year</var>, month <var title="">month</var>, day <var title="">day</var>, hours <var title="">hour</var>, minute <var title="">minute</var>, second <var title="">second</var>,
subtracting <var title="">timezone<sub title="">hours</sub></var>
hours and <var title="">timezone<sub title="">minutes</sub></var>
minutes. That moment in time is a moment in the UTC
time zone.</p></li>
<li><p>Let <var title="">timezone</var> be <var title="">timezone<sub title="">hours</sub></var> hours and <var title="">timezone<sub title="">minutes</sub></var> minutes from
UTC.</p></li>
<li><p>Return <var title="">time</var> and <var title="">timezone</var>.</p></li>
</ol><p>The rules to <dfn id="parse-a-time-zone-offset-component">parse a time-zone offset component</dfn>, given
an <var title="">input</var> string and a <var title="">position</var>, are as follows. This will return either
time-zone hours and time-zone minutes, or nothing. If at any point
the algorithm says that it "fails", this means that it is aborted at
that point and returns nothing.</p>
<ol><li>
<p>If the character at <var title="">position</var> is a U+005A
LATIN CAPITAL LETTER Z character (Z), then:</p>
<ol><li><p>Let <var title="">timezone<sub title="">hours</sub></var>
be 0.</p></li>
<li><p>Let <var title="">timezone<sub title="">minutes</sub></var> be 0.</p></li>
<li><p>Advance <var title="">position</var> to the next character
in <var title="">input</var>.</p></li>
</ol><p>Otherwise, if the character at <var title="">position</var> is
either a U+002B PLUS SIGN (+) or a U+002D HYPHEN-MINUS (-),
then:</p>
<ol><li><p>If the character at <var title="">position</var> is a
U+002B PLUS SIGN (+), let <var title="">sign</var> be
"positive". Otherwise, it's a U+002D HYPHEN-MINUS (-); let <var title="">sign</var> be "negative".</p></li>
<li><p>Advance <var title="">position</var> to the next character
in <var title="">input</var>.</p></li>
<li><p><a href="#collect-a-sequence-of-characters">Collect a sequence of characters</a> in the range
U+0030 DIGIT ZERO (0) to U+0039 DIGIT NINE (9). If the collected
sequence is not exactly two characters long, then
fail. Otherwise, interpret the resulting sequence as a base-ten
integer. Let that number be the <var title="">timezone<sub title="">hours</sub></var>.</p></li>
<li>If <var title="">timezone<sub title="">hours</sub></var> is
not a number in the range 0&#160;&#8804;&#160;<var title="">timezone<sub title="">hours</sub></var>&#160;&#8804;&#160;23, then fail.</li>
<li>If <var title="">sign</var> is "negative", then negate <var title="">timezone<sub title="">hours</sub></var>.</li>
<li><p>If <var title="">position</var> is beyond the end of <var title="">input</var> or if the character at <var title="">position</var> is not a U+003A COLON character, then
fail. Otherwise, move <var title="">position</var> forwards one
character.</p></li>
<li><p><a href="#collect-a-sequence-of-characters">Collect a sequence of characters</a> in the range
U+0030 DIGIT ZERO (0) to U+0039 DIGIT NINE (9). If the collected
sequence is not exactly two characters long, then
fail. Otherwise, interpret the resulting sequence as a base-ten
integer. Let that number be the <var title="">timezone<sub title="">minutes</sub></var>.</p></li>
<li>If <var title="">timezone<sub title="">minutes</sub></var> is
not a number in the range 0&#160;&#8804;&#160;<var title="">timezone<sub title="">minutes</sub></var>&#160;&#8804;&#160;59, then fail.</li>
<li>If <var title="">sign</var> is "negative", then negate <var title="">timezone<sub title="">minutes</sub></var>.</li>
</ol><p>Otherwise, fail.</p>
</li>
<li><p>Return <var title="">timezone<sub title="">hours</sub></var>
and <var title="">timezone<sub title="">minutes</sub></var>.</p></li>
</ol></div><h5 id="weeks"><span class="secno">2.5.5.6 </span>Weeks</h5><p>A <dfn id="concept-week" title="concept-week">week</dfn> consists of a week-year
number and a week number representing a seven-day period starting on
a Monday. Each week-year in this calendaring system has either 52 or
53 such seven-day periods, as defined below. The seven-day period
starting on the Gregorian date Monday December 29th 1969
(1969-12-29) is defined as week number 1 in week-year
1970. Consecutive weeks are numbered sequentially. The week before
the number 1 week in a week-year is the last week in the previous
week-year, and vice versa. <a href="references.html#refsGREGORIAN">[GREGORIAN]</a></p><p>A week-year with a number <var title="">year</var> has 53 weeks
if it corresponds to either a year <var title="">year</var> in the
proleptic Gregorian calendar that has a Thursday as its first day
(January 1st), or a year <var title="">year</var> in the proleptic
Gregorian calendar that has a Wednesday as its first day (January
1st) and where <var title="">year</var> is a number divisible by
400, or a number divisible by 4 but not by 100. All other week-years
have 52 weeks.</p><p>The <dfn id="week-number-of-the-last-day">week number of the last day</dfn> of a week-year with 53
weeks is 53; the week number of the last day of a week-year with 52
weeks is 52.</p><p class="note">The week-year number of a particular day can be
different than the number of the year that contains that day in the
proleptic Gregorian calendar. The first week in a week-year <var title="">y</var> is the week that contains the first Thursday of
the Gregorian year <var title="">y</var>.</p><p>A string is a <dfn id="valid-week-string">valid week string</dfn> representing a
week-year <var title="">year</var> and week <var title="">week</var>
if it consists of the following components in the given order:</p><ol><li>Four or more <a href="#concept-datetime-digit" title="concept-datetime-digit">digits</a>, representing <var title="">year</var>, where <var title="">year</var>&#160;&gt;&#160;0</li>
<li>A U+002D HYPHEN-MINUS character (-)</li>
<li>A U+0057 LATIN CAPITAL LETTER W character (W)</li>
<li>Two <a href="#concept-datetime-digit" title="concept-datetime-digit">digits</a>,
representing the week <var title="">week</var>, in the range
1&#160;&#8804;&#160;<var title="">week</var>&#160;&#8804;&#160;<var title="">maxweek</var>, where <var title="">maxweek</var> is the
<a href="#week-number-of-the-last-day">week number of the last day</a> of week-year <var title="">year</var></li>
</ol><div class="impl">
<p>The rules to <dfn id="parse-a-week-string">parse a week string</dfn> are as follows. This
will return either a week-year number and week number, or
nothing. If at any point the algorithm says that it "fails", this
means that it is aborted at that point and returns nothing.</p>
<ol><li><p>Let <var title="">input</var> be the string being
parsed.</p></li>
<li><p>Let <var title="">position</var> be a pointer into <var title="">input</var>, initially pointing at the start of the
string.</p></li>
<li><p><a href="#collect-a-sequence-of-characters">Collect a sequence of characters</a> in the range
U+0030 DIGIT ZERO (0) to U+0039 DIGIT NINE (9). If the collected
sequence is not at least four characters long, then
fail. Otherwise, interpret the resulting sequence as a base-ten
integer. Let that number be the <var title="">year</var>.</p></li>
<li><p>If <var title="">year</var> is not a number greater than
zero, then fail.</p></li>
<li><p>If <var title="">position</var> is beyond the end of <var title="">input</var> or if the character at <var title="">position</var> is not a U+002D HYPHEN-MINUS character,
then fail. Otherwise, move <var title="">position</var> forwards
one character.</p></li>
<li><p>If <var title="">position</var> is beyond the end of <var title="">input</var> or if the character at <var title="">position</var> is not a U+0057 LATIN CAPITAL LETTER W
character (W), then fail. Otherwise, move <var title="">position</var> forwards one character.</p></li>
<li><p><a href="#collect-a-sequence-of-characters">Collect a sequence of characters</a> in the range
U+0030 DIGIT ZERO (0) to U+0039 DIGIT NINE (9). If the collected
sequence is not exactly two characters long, then fail. Otherwise,
interpret the resulting sequence as a base-ten integer. Let that
number be the <var title="">week</var>.</p></li>
<li><p>Let <var title="">maxweek</var> be the <a href="#week-number-of-the-last-day">week number of
the last day</a> of year <var title="">year</var>.</p></li>
<li><p>If <var title="">week</var> is not a number in the range
1&#160;&#8804;&#160;<var title="">week</var>&#160;&#8804;&#160;<var title="">maxweek</var>, then fail.</p></li>
<li><p>If <var title="">position</var> is <em>not</em> beyond the
end of <var title="">input</var>, then fail.</p></li>
<li><p>Return the week-year number <var title="">year</var> and the
week number <var title="">week</var>.</p></li>
</ol></div><h5 id="vaguer-moments-in-time"><span class="secno">2.5.5.7 </span>Vaguer moments in time</h5><p>A string is a <dfn id="valid-date-or-time-string">valid date or time string</dfn> if it is also
one of the following:</p><ul><li>A <a href="#valid-date-string">valid date string</a>.</li>
<li>A <a href="#valid-time-string">valid time string</a>.</li>
<li>A <a href="#valid-global-date-and-time-string">valid global date and time string</a>.</li>
</ul><p>A string is a <dfn id="valid-date-or-time-string-in-content">valid date or time string in content</dfn> if
it consists of zero or more <a href="#white_space">White_Space</a> characters,
followed by a <a href="#valid-date-or-time-string">valid date or time string</a>, followed by
zero or more further <a href="#white_space">White_Space</a> characters.</p><hr><p>A string is a <dfn id="valid-date-string-with-optional-time">valid date string with optional time</dfn> if
it is also one of the following:</p><ul><li>A <a href="#valid-date-string">valid date string</a>.</li>
<li>A <a href="#valid-global-date-and-time-string">valid global date and time string</a>.</li>
</ul><p>A string is a <dfn id="valid-date-string-in-content-with-optional-time">valid date string in content with optional
time</dfn> if it consists of zero or more <a href="#white_space">White_Space</a>
characters, followed by a <a href="#valid-date-string-with-optional-time">valid date string with optional
time</a>, followed by zero or more further
<a href="#white_space">White_Space</a> characters.</p><div class="impl">
<hr><p>The rules to <dfn id="parse-a-date-or-time-string">parse a date or time string</dfn> are as
follows. The algorithm is invoked with a flag indicating if the
<i>in attribute</i> variant or the <i>in content</i> variant is to
be used. The algorithm will return either a <a href="#concept-date" title="concept-date">date</a>, a <a href="#concept-time" title="concept-time">time</a>, a <a href="#concept-datetime" title="concept-datetime">global date and time</a>, or nothing. If
at any point the algorithm says that it "fails", this means that it
is aborted at that point and returns nothing.</p>
<ol><li><p>Let <var title="">input</var> be the string being
parsed.</p></li>
<li><p>Let <var title="">position</var> be a pointer into <var title="">input</var>, initially pointing at the start of the
string.</p></li>
<li><p>For the <i>in content</i> variant: <a href="#skip-white_space-characters">skip White_Space
characters</a>.</p></li>
<li><p>Set <var title="">start position</var> to the same position
as <var title="">position</var>.</p></li>
<li><p>Set the <var title="">date present</var> and <var title="">time present</var> flags to true.</p></li>
<li><p><a href="#parse-a-date-component">Parse a date component</a> to obtain <var title="">year</var>, <var title="">month</var>, and <var title="">day</var>. If this fails, then set the <var title="">date
present</var> flag to false.</p>
</li><li>
<p>If <var title="">date present</var> is true, and <var title="">position</var> is not beyond the end of <var title="">input</var>, and the character at <var title="">position</var> is a U+0054 LATIN CAPITAL LETTER T
character (T), then advance <var title="">position</var> to the
next character in <var title="">input</var>.</p>
<p>Otherwise, if <var title="">date present</var> is true, and
either <var title="">position</var> is beyond the end of <var title="">input</var> or the character at <var title="">position</var> is not a U+0054 LATIN CAPITAL LETTER T
character (T), then set <var title="">time present</var> to
false.</p>
<p>Otherwise, if <var title="">date present</var> is false, set
<var title="">position</var> back to the same position as <var title="">start position</var>.</p>
</li>
<li><p>If the <var title="">time present</var> flag is true, then
<a href="#parse-a-time-component">parse a time component</a> to obtain <var title="">hour</var>, <var title="">minute</var>, and <var title="">second</var>. If this returns nothing, then fail.</p></li>
<li><p>If the <var title="">date present</var> and <var title="">time present</var> flags are both true, but <var title="">position</var> is beyond the end of <var title="">input</var>, then fail.</p></li>
<li><p>If the <var title="">date present</var> and <var title="">time present</var> flags are both true, <a href="#parse-a-time-zone-offset-component">parse a
time-zone offset component</a> to obtain <var title="">timezone<sub title="">hours</sub></var> and <var title="">timezone<sub title="">minutes</sub></var>. If this returns
nothing, then fail.</p>
</li><li><p>For the <i>in content</i> variant: <a href="#skip-white_space-characters">skip White_Space
characters</a>.</p></li>
<li><p>If <var title="">position</var> is <em>not</em> beyond the
end of <var title="">input</var>, then fail.</p></li>
<li>
<p>If the <var title="">date present</var> flag is true and the
<var title="">time present</var> flag is false, then let <var title="">date</var> be the date with year <var title="">year</var>, month <var title="">month</var>, and day <var title="">day</var>, and return <var title="">date</var>.</p>
<p>Otherwise, if the <var title="">time present</var> flag is true
and the <var title="">date present</var> flag is false, then let
<var title="">time</var> be the time with hour <var title="">hour</var>, minute <var title="">minute</var>, and second
<var title="">second</var>, and return <var title="">time</var>.</p>
<p>Otherwise, let <var title="">time</var> be the moment in time
at year <var title="">year</var>, month <var title="">month</var>,
day <var title="">day</var>, hours <var title="">hour</var>,
minute <var title="">minute</var>, second <var title="">second</var>, subtracting <var title="">timezone<sub title="">hours</sub></var> hours and <var title="">timezone<sub title="">minutes</sub></var> minutes, that moment in time being a
moment in the UTC time zone; let <var title="">timezone</var> be
<var title="">timezone<sub title="">hours</sub></var> hours and
<var title="">timezone<sub title="">minutes</sub></var> minutes
from UTC; and return <var title="">time</var> and <var title="">timezone</var>.</p>
</li>
</ol></div><h4 id="colors"><span class="secno">2.5.6 </span>Colors</h4><p>A <dfn id="simple-color">simple color</dfn> consists of three 8-bit numbers in the
range 0..255, representing the red, green, and blue components of
the color respectively, in the sRGB color space. <a href="references.html#refsSRGB">[SRGB]</a></p><p>A string is a <dfn id="valid-simple-color">valid simple color</dfn> if it is exactly
seven characters long, and the first character is a U+0023 NUMBER
SIGN character (#), and the remaining six characters are all in the
range U+0030 DIGIT ZERO (0) to U+0039 DIGIT NINE (9), U+0041 LATIN
CAPITAL LETTER A to U+0046 LATIN CAPITAL LETTER F, U+0061 LATIN
SMALL LETTER A to U+0066 LATIN SMALL LETTER F, with the first two
digits representing the red component, the middle two digits
representing the green component, and the last two digits
representing the blue component, in hexadecimal.</p><p>A string is a <dfn id="valid-lowercase-simple-color">valid lowercase simple color</dfn> if it is a
<a href="#valid-simple-color">valid simple color</a> and doesn't use any characters in
the range U+0041 LATIN CAPITAL LETTER A to U+0046 LATIN CAPITAL
LETTER F.</p><div class="impl">
<p>The <dfn id="rules-for-parsing-simple-color-values">rules for parsing simple color values</dfn> are as given
in the following algorithm. When invoked, the steps must be followed
in the order given, aborting at the first step that returns a
value. This algorithm will return either a <a href="#simple-color">simple color</a>
or an error.</p>
<ol><li><p>Let <var title="">input</var> be the string being
parsed.</p></li>
<li><p>If <var title="">input</var> is not exactly seven characters
long, then return an error.</p></li>
<li><p>If the first character in <var title="">input</var> is not a
U+0023 NUMBER SIGN character (#), then return an error.</p></li>
<li><p>If the last six characters of <var title="">input</var> are
not all in the range U+0030 DIGIT ZERO (0) to U+0039 DIGIT NINE
(9), U+0041 LATIN CAPITAL LETTER A to U+0046 LATIN CAPITAL LETTER
F, U+0061 LATIN SMALL LETTER A to U+0066 LATIN SMALL LETTER F, then
return an error.</p></li>
<li><p>Let <var title="">result</var> be a <a href="#simple-color">simple
color</a>.</p>
</li><li><p>Interpret the second and third characters as a hexadecimal
number and let the result be the red component of <var title="">result</var>.</p>
</li><li><p>Interpret the fourth and fifth characters as a hexadecimal
number and let the result be the green component of <var title="">result</var>.</p>
</li><li><p>Interpret the sixth and seventh characters as a hexadecimal
number and let the result be the blue component of <var title="">result</var>.</p>
</li><li><p>Return <var title="">result</var>.</p>
</li></ol><p>The <dfn id="rules-for-serializing-simple-color-values">rules for serializing simple color values</dfn> given a
<a href="#simple-color">simple color</a> are as given in the following
algorithm:</p>
<ol><li><p>Let <var title="">result</var> be a string consisting of a
single U+0023 NUMBER SIGN character (#).</p></li>
<li><p>Convert the red, green, and blue components in turn to
two-digit hexadecimal numbers using the digits U+0030 DIGIT ZERO
(0) to U+0039 DIGIT NINE (9) and U+0061 LATIN SMALL LETTER A
to U+0066 LATIN SMALL LETTER F, zero-padding if necessary, and
append these numbers to <var title="">result</var>, in the order
red, green, blue.</p>
</li><li><p>Return <var title="">result</var>, which will be a
<a href="#valid-lowercase-simple-color">valid lowercase simple color</a>.</p></li>
</ol><hr><p>Some obsolete legacy attributes parse colors in a more
complicated manner, using the <dfn id="rules-for-parsing-a-legacy-color-value">rules for parsing a legacy color
value</dfn>, which are given in the following algorithm. When
invoked, the steps must be followed in the order given, aborting at
the first step that returns a value. This algorithm will return
either a <a href="#simple-color">simple color</a> or an error.</p>
<ol><li><p>Let <var title="">input</var> be the string being
parsed.</p></li>
<li><p>If <var title="">input</var> is the empty string, then
return an error.</p></li>
<li><p><a href="#strip-leading-and-trailing-whitespace">Strip leading and trailing whitespace</a> from <var title="">input</var>.</p></li>
<li><p>If <var title="">input</var> is an <a href="infrastructure.html#ascii-case-insensitive">ASCII
case-insensitive</a> match for the string "<code title="">transparent</code>", then return an error.</p></li>
<li>
<p>If <var title="">input</var> is an <a href="infrastructure.html#ascii-case-insensitive">ASCII
case-insensitive</a> match for one of the keywords listed in
the <a href="http://www.w3.org/TR/css3-color/#svg-color">SVG color
keywords</a> section of the CSS3 Color specification,
then return the <a href="#simple-color">simple color</a> corresponding to that
keyword. <a href="references.html#refsCSSCOLOR">[CSSCOLOR]</a></p>
<p class="note"><a href="http://www.w3.org/TR/css3-color/#css2-system">CSS2 System
Colors</a> are not recognised.</p>
</li>
<li>
<p>If <var title="">input</var> is four characters long, and the
first character in <var title="">input</var> is a U+0023 NUMBER
SIGN character (#), and the last three characters of <var title="">input</var> are all in the range U+0030 DIGIT ZERO (0)
to U+0039 DIGIT NINE (9), U+0041 LATIN CAPITAL LETTER A to U+0046
LATIN CAPITAL LETTER F, and U+0061 LATIN SMALL LETTER A to U+0066
LATIN SMALL LETTER F, then run these substeps:</p>
<ol><li><p>Let <var title="">result</var> be a <a href="#simple-color">simple
color</a>.</p>
</li><li><p>Interpret the second character of <var title="">input</var> as a hexadecimal digit; let the red
component of <var title="">result</var> be the resulting number
multiplied by 17.</p>
</li><li><p>Interpret the third character of <var title="">input</var>
as a hexadecimal digit; let the green component of <var title="">result</var> be the resulting number multiplied by
17.</p>
</li><li><p>Interpret the fourth character of <var title="">input</var> as a hexadecimal digit; let the blue
component of <var title="">result</var> be the resulting number
multiplied by 17.</p>
</li><li><p>Return <var title="">result</var>.</p>
</li></ol></li>
<li><p>Replace any characters in <var title="">input</var> that
have a Unicode code point greater than U+FFFF (i.e. any characters
that are not in the basic multilingual plane) with the
two-character string "<code title="">00</code>".</p></li>
<li><p>If <var title="">input</var> is longer than 128 characters,
truncate <var title="">input</var>, leaving only the first 128
characters.</p></li>
<li><p>If the first character in <var title="">input</var> is a
U+0023 NUMBER SIGN character (#), remove it.</p></li>
<li><p>Replace any character in <var title="">input</var> that is
not in the range U+0030 DIGIT ZERO (0) to U+0039 DIGIT NINE (9),
U+0041 LATIN CAPITAL LETTER A to U+0046 LATIN CAPITAL LETTER F, and
U+0061 LATIN SMALL LETTER A to U+0066 LATIN SMALL LETTER F with the
character U+0030 DIGIT ZERO (0).</p></li>
<li><p>While <var title="">input</var>'s length is zero or not a
multiple of three, append a U+0030 DIGIT ZERO (0) character to <var title="">input</var>.</p></li>
<li><p>Split <var title="">input</var> into three strings of equal
length, to obtain three components. Let <var title="">length</var>
be the length of those components (one third the length of <var title="">input</var>).</p></li>
<li><p>If <var title="">length</var> is greater than 8, then remove
the leading <span title=""><var title="">length</var>-8</span>
characters in each component, and let <var title="">length</var> be
8.</p></li>
<li><p>While <var title="">length</var> is greater than two and the
first character in each component is a U+0030 DIGIT ZERO (0)
character, remove that character and reduce <var title="">length</var> by one.</p></li>
<li><p>If <var title="">length</var> is <em>still</em> greater than
two, truncate each component, leaving only the first two
characters in each.</p></li>
<li><p>Let <var title="">result</var> be a <a href="#simple-color">simple
color</a>.</p>
</li><li><p>Interpret the first component as a hexadecimal number; let
the red component of <var title="">result</var> be the resulting
number.</p></li>
<li><p>Interpret the second component as a hexadecimal number; let
the green component of <var title="">result</var> be the resulting
number.</p></li>
<li><p>Interpret the third component as a hexadecimal number; let
the blue component of <var title="">result</var> be the resulting
number.</p></li>
<li><p>Return <var title="">result</var>.</p>
</li></ol></div><hr><h4 id="space-separated-tokens"><span class="secno">2.5.7 </span>Space-separated tokens</h4><p>A <dfn id="set-of-space-separated-tokens">set of space-separated tokens</dfn> is a string containing
zero or more words (known as tokens) separated by one or more <a href="#space-character" title="space character">space characters</a>, where words consist
of any string of one or more characters, none of which are <a href="#space-character" title="space character">space characters</a>.</p><p>A string containing a <a href="#set-of-space-separated-tokens">set of space-separated tokens</a>
may have leading or trailing <a href="#space-character" title="space character">space
characters</a>.</p><p>An <dfn id="unordered-set-of-unique-space-separated-tokens">unordered set of unique space-separated tokens</dfn> is a
<a href="#set-of-space-separated-tokens">set of space-separated tokens</a> where none of the tokens
are duplicated.</p><p>An <dfn id="ordered-set-of-unique-space-separated-tokens">ordered set of unique space-separated tokens</dfn> is a
<a href="#set-of-space-separated-tokens">set of space-separated tokens</a> where none of the tokens
are duplicated but where the order of the tokens is meaningful.</p><p><a href="#set-of-space-separated-tokens" title="set of space-separated tokens">Sets of
space-separated tokens</a> sometimes have a defined set of
allowed values. When a set of allowed values is defined, the tokens
must all be from that list of allowed values; other values are
non-conforming. If no such set of allowed values is provided, then
all values are conforming.</p><p class="note">How tokens in a <a href="#set-of-space-separated-tokens">set of space-separated
tokens</a> are to be compared (e.g. case-sensitively or not) is
defined on a per-set basis.</p><div class="impl">
<p>When a user agent has to <dfn id="split-a-string-on-spaces">split a string on spaces</dfn>, it
must use the following algorithm:</p>
<ol><li><p>Let <var title="">input</var> be the string being
parsed.</p></li>
<li><p>Let <var title="">position</var> be a pointer into <var title="">input</var>, initially pointing at the start of the
string.</p></li>
<li><p>Let <var title="">tokens</var> be a list of tokens,
initially empty.</p></li>
<li><p><a href="#skip-whitespace">Skip whitespace</a></p></li>
<li><p>While <var title="">position</var> is not past the end of
<var title="">input</var>:</p>
<ol><li><p><a href="#collect-a-sequence-of-characters">Collect a sequence of characters</a> that are not
<a href="#space-character" title="space character">space characters</a>.</p></li>
<li><p>Add the string collected in the previous step to <var title="">tokens</var>.</p></li>
<li><p><a href="#skip-whitespace">Skip whitespace</a></p></li>
</ol></li>
<li><p>Return <var title="">tokens</var>.</p></li>
</ol><p>When a user agent has to <dfn id="remove-a-token-from-a-string">remove a token from a string</dfn>,
it must use the following algorithm:</p>
<ol><li><p>Let <var title="">input</var> be the string being
modified.</p></li>
<li><p>Let <var title="">token</var> be the token being removed. It
will not contain any <a href="#space-character" title="space character">space
characters</a>.</p></li>
<li><p>Let <var title="">output</var> be the output string,
initially empty.</p></li>
<li><p>Let <var title="">position</var> be a pointer into <var title="">input</var>, initially pointing at the start of the
string.</p></li>
<li><p><i>Loop</i>: If <var title="">position</var> is beyond the
end of <var title="">input</var>, abort these steps.</p></li>
<li><p>If the character at <var title="">position</var> is a
<a href="#space-character">space character</a>:</p>
<ol><li><p>Append the character at <var title="">position</var> to
the end of <var title="">output</var>.</p></li>
<li><p>Advance <var title="">position</var> so it points at the
next character in <var title="">input</var>.</p></li>
<li><p>Return to the step labeled <i>loop</i>.</p></li>
</ol></li>
<li><p>Otherwise, the character at <var title="">position</var> is
the first character of a token. <a href="#collect-a-sequence-of-characters">Collect a sequence of
characters</a> that are not <a href="#space-character" title="space character">space
characters</a>, and let that be <var title="">s</var>.</p></li>
<li><p>If <var title="">s</var> is exactly equal to <var title="">token</var> (this is a <a href="infrastructure.html#case-sensitive">case-sensitive</a>
comparison), then:</p>
<ol><li><p><a href="#skip-whitespace">Skip whitespace</a> (in <var title="">input</var>).</p></li>
<li><p>Remove any <a href="#space-character" title="space character">space
characters</a> currently at the end of <var title="">output</var>.</p></li>
<li><p>If <var title="">position</var> is not past the end of
<var title="">input</var>, and <var title="">output</var> is not
the empty string, append a single U+0020 SPACE character at the
end of <var title="">output</var>.</p></li>
</ol></li>
<li><p>Otherwise, append <var title="">s</var> to the end of <var title="">output</var>.</p></li>
<li><p>Return to the step labeled <i>loop</i>.</p></li>
</ol><p class="note">This causes any occurrences of the token to be
removed from the string, and any spaces that were surrounding the
token to be collapsed to a single space, except at the start and end
of the string, where such spaces are removed.</p>
</div><h4 id="comma-separated-tokens"><span class="secno">2.5.8 </span>Comma-separated tokens</h4><p>A <dfn id="set-of-comma-separated-tokens">set of comma-separated tokens</dfn> is a string containing
zero or more tokens each separated from the next by a single U+002C
COMMA character (,), where tokens consist of any string of zero or
more characters, neither beginning nor ending with <a href="#space-character" title="space character">space characters</a>, nor containing any
U+002C COMMA characters (,), and optionally surrounded by <a href="#space-character" title="space character">space characters</a>.</p><p class="example">For instance, the string "<code title="">&#160;a&#160;,b,,d&#160;d&#160;</code>" consists of four
tokens: "a", "b", the empty string, and "d&#160;d". Leading and
trailing whitespace around each token doesn't count as part of the
token, and the empty string can be a token.</p><p><a href="#set-of-comma-separated-tokens" title="set of comma-separated tokens">Sets of
comma-separated tokens</a> sometimes have further restrictions on
what consists a valid token. When such restrictions are defined, the
tokens must all fit within those restrictions; other values are
non-conforming. If no such restrictions are specified, then all
values are conforming.</p><div class="impl">
<p>When a user agent has to <dfn id="split-a-string-on-commas">split a string on commas</dfn>, it
must use the following algorithm:</p>
<ol><li><p>Let <var title="">input</var> be the string being
parsed.</p></li>
<li><p>Let <var title="">position</var> be a pointer into <var title="">input</var>, initially pointing at the start of the
string.</p></li>
<li><p>Let <var title="">tokens</var> be a list of tokens,
initially empty.</p></li>
<li><p><i>Token</i>: If <var title="">position</var> is past the
end of <var title="">input</var>, jump to the last step.</p></li>
<li><p><a href="#collect-a-sequence-of-characters">Collect a sequence of characters</a> that are not
U+002C COMMA characters (,). Let <var title="">s</var> be the resulting sequence (which might be the
empty string).</p></li>
<li><p>Remove any leading or trailing sequence of <a href="#space-character" title="space character">space characters</a> from <var title="">s</var>.</p></li>
<li><p>Add <var title="">s</var> to <var title="">tokens</var>.</p></li>
<li><p>If <var title="">position</var> is not past the end of <var title="">input</var>, then the character at <var title="">position</var> is a U+002C COMMA character (,); advance
<var title="">position</var> past that character.</p></li>
<li><p>Jump back to the step labeled <i>token</i>.</p></li>
<li><p>Return <var title="">tokens</var>.</p></li>
</ol></div><h4 id="syntax-references"><span class="secno">2.5.9 </span>References</h4><p>A <dfn id="valid-hash-name-reference">valid hash-name reference</dfn> to an element of type <var title="">type</var> is a string consisting of a U+0023 NUMBER SIGN
character (#) followed by a string which exactly matches the value
of the <code title="">name</code> attribute of an element with type
<var title="">type</var> in the document.</p><div class="impl">
<p>The <dfn id="rules-for-parsing-a-hash-name-reference">rules for parsing a hash-name reference</dfn> to an
element of type <var title="">type</var> are as follows:</p>
<ol><li><p>If the string being parsed does not contain a U+0023 NUMBER
SIGN character, or if the first such character in the string is the
last character in the string, then return null and abort these
steps.</p></li>
<li><p>Let <var title="">s</var> be the string from the character
immediately after the first U+0023 NUMBER SIGN character in the
string being parsed up to the end of that string.</p></li>
<li><p>Return the first element of type <var title="">type</var>
that has an <code title="attr-id"><a href="elements.html#the-id-attribute">id</a></code> attribute whose value
is a <a href="infrastructure.html#case-sensitive">case-sensitive</a> match for <var title="">s</var> or
a <code title="">name</code> attribute whose value is a
<a href="infrastructure.html#compatibility-caseless">compatibility caseless</a> match for <var title="">s</var>.</p></li>
</ol></div><h4 id="mq"><span class="secno">2.5.10 </span>Media queries</h4><p>A string is a <dfn id="valid-media-query">valid media query</dfn> if it matches the
<code title="">media_query_list</code> production of the Media
Queries specification. <a href="references.html#refsMQ">[MQ]</a></p><p>A string <dfn id="matches-the-environment">matches the environment</dfn> of the user if it is
the empty string, a string consisting of only <a href="#space-character" title="space
character">space characters</a>, or is a media query that matches
the user's environment according to the definitions given in the
Media Queries specification. <a href="references.html#refsMQ">[MQ]</a></p></body></html>