HTML: The Markup Language

9. Datatypes # T

This section defines datatypes that are referenced by attribute definitions in the HTML elements, Common attributes, and Forms attributes sections.

9.01. String #

For any attribute definition in this document that references the string datatype, a string is defined as normal character data.

The Attributes section of this document describes additional restrictions on strings in attribute values — in particular, restrictions for the following cases:

9.02. Token #

For any attribute definition in this document that references the token datatype, a token is defined as a string that does not contain any space characters.

9.03. Tokens #

A space-separated list of zero or more token instances.

9.04. Browsing-context name #

Any string, with the following restrictions:
  • must not start with a "_" character
  • must be at least one character long

9.05. Browsing-context name or keyword #

Any string that is either of the following:

9.06. ID #

Any string, with the following restrictions:

Previous versions of HTML placed greater restrictions on the content of ID values (for example, they did not permit ID values to begin with a number).

9.07. IDREF #

Any string, with the following restrictions:

9.08. IDREFS #

A space-separated list of one or more IDREF instances.

9.09. Name #

Any string, with the following restrictions:

9.10. Hash-name reference #

A valid hash-name reference to an element of type type is a string that starts with a "#" character, followed by a string which exactly matches the value of the name attribute of an element in the document with type type.

9.11. Integer #

One or more characters in the range 0—9, optionally prefixed with a "-" character.

9.12. Positive integer #

Any non-negative integer, with the following restriction:
  • must be greater than zero

9.13. Non-negative integer #

One or more characters in the range 0—9.

9.14. Float #

A float consists of the following parts, in exactly the following order:
  1. Optionally, the first character may be a "-" character.
  2. One or more characters in the range "0—9".
  3. Optionally, the following parts, in exactly the following order:
    1. a "." character
    2. one or more characters in the range "0—9"
  4. Optionally, the following parts, in exactly the following order:
    1. a "e" character or "E" character
    2. optionally, a "-" character or "+" character
    3. One or more characters in the range "0—9".

9.15. Positive float #

A non-negative float, with the following restriction:
  • must be greater than zero

9.16. Non-negative float #

A float, with the following restriction:
  • the first character may not be a "-" character

9.17. Date-time #

A valid date-time, as defined in RFC 3339 [RFC3339], with these additional qualifications:
  • the literal letters T and Z in the date/time syntax must always be uppercase
  • a date-fullyear is defined as four or more digits representing a number greater than 0

Examples:

1990-12-31T23:59:60Z
1996-12-19T16:39:57-08:00

9.18. Date or time #

Any one of the following:

9.19. URI #

An IRI-reference, as defined in RFC 3987 [RFC3987].

The empty string is a valid IRI-reference, so the empty string is allowed as the value of any attribute for which this reference lists URI as the allowed datatype.

Example:

http://example.org/hello

9.20. Absolute URI #

An IRI, as defined in RFC 3987 [RFC3987].

Examples:

/hello
#canvas
http://example.org/

9.21. Sizes #

An unordered set of unique space-separated tokens, each of which must be one of the following:
  • the literal string "any"
  • two valid non-negative integers that do not have a leading "0" character and that are separated by a single "x" character.

9.22. MIME type #

A string that identifies a valid MIME media type, as defined in RFC 2046 [RFC2046].

9.23. Character encoding name #

For documents in the HTML syntax: a case-insensitive match for any character set name given in a Name or Alias field labeled as “preferred MIME name” in the IANA Character Sets registry [IANACHARSET], if there is one; or if none of the Alias fields are so labeled, a case-insensitive match for a Name field in the registry.

For documents in the XML syntax, any case-insensitive match for the string "UTF-8".

9.24. Meta-charset string #

The following parts, in exactly the following order:
  1. The literal string "text/html;".
  2. Optionally, one or more space characters.
  3. The literal string "charset=".
  4. A character encoding name.

9.25. Refresh value #

Any one of the following:

9.26. Default-style name #

9.27. Media-query list #

A valid media query list, as defined in Media Queries [MQ].

9.28. Language tag #

A valid language tag, as defined in BCP 47 [BCP47].

9.29. Key-label list #

An ordered set of unique space-separated tokens, each of which must be exactly one Unicode code point in length.

9.30. Zero #

The literal string "0".

9.31. Rectangle #

A comma-separated list of four integers, in exactly the following order:
  1. an integer representing the distance in CSS pixels from the left edge of the image to the left side of the rectangle
  2. an integer representing the distance in CSS pixels from the top edge of the image to the top side of the rectangle
  3. an integer, greater than the value of the first integer in this list, representing the distance in CSS pixels from the left edge of the image to the right side of the rectangle
  4. an integer, greater than the value of the second integer in this list, representing the distance in CSS pixels from the top edge of the image to the bottom side of the rectangle

9.32. Circle #

A comma-separated list of three numbers, in exactly the following order:
  1. an integer representing the distance in CSS pixels from the left edge of the image to the center of the circle
  2. an integer representing the distance in CSS pixels from the top edge of the image to the center of the circle
  3. a non-negative integer, representing the radius of the circle, in CSS pixels

9.33. Polygon #

A comma-separated list of at least six integers, with the total number of integers in the list being even (that is, six or eight or ten numbers, and so on). Each pair of integers represents a coordinate, in CSS pixels, given as the distances from, respectively, the left and the top of the image; all the coordinates together represent the points of the polygon, in order.

9.34. Sandbox allow list #

An unordered set of unique space-separated tokens, each of which is a case-insensitive match for one of the following literal strings:
  • "allow-same-origin"
  • "allow-forms"
  • "allow-scripts"
  • "allow-top-navigation"

9.35. MIME-type list #

A set of comma-separated tokens, each of which is a valid mime type, with no parameters.

9.36. Character-encoding name list #

A set of comma-separated tokens, each of which is a valid character encoding name that specifies an ASCII-compatible character encoding.

9.37. Pattern #

A regular expression that must match the JavaScript Pattern production [ECMA262].

9.38. Local date-time #

The following parts, in exactly the following order:
  1. A date.
  2. The literal string "T".
  3. A time.

Example:

1985-04-12T23:20:50.52
1996-12-19T16:39:57

9.39. Date #

A valid full-date, as defined in RFC 3339 [RFC3339], with the additional qualification that the year component is a date-fullyear as described in this reference.

Example:

1996-12-19

9.40. Month #

The following parts, in exactly the following order:
  1. A date-fullyear.
  2. The literal string "-".
  3. A date-month, as defined in RFC 3339 [RFC3339].

Example:

1996-12

9.41. Week #

The following parts, in exactly the following order:
  1. A date-fullyear.
  2. The literal string "-W".
  3. A date-week, as defined in RFC 3339 [RFC3339].

Example:

1996-W16

9.42. Time #

A valid partial-time, as defined in RFC 3339 [RFC3339].

Examples:

23:20:50.52
17:39:57

9.43. E-mail address #

Any string that matches the following ABNF [ABNF] production:

1*( atext / "." ) "@" ldh-str 1*( "." ldh-str )

…where atext is as defined in RFC 5322 [RFC5322], and ldh-str is as defined in RFC 1034 [RFC1034].

Examples:

foo-bar.baz@example.com

9.44. E-mail address list #

A set of comma-separated tokens, each of which is a valid email address.

9.45. Color #

A string exactly seven characters long, consisting of the following parts, in exactly the following order:
  1. A "#" character.
  2. Six characters in the range 0–9, a–f, and A–F.