A type in HTML (as in many other languages), defines a set of rules which every value of this type must obey. We can say in other words that a value of certain type must obey the rules set by that type. For example, we can define a type named "digit" and say that every value of this type should be composed of a single number from 0 to 9. In this case, numbers like 49 don't belong to this type, as well as, among other values, letters.
These rules are necessary in HTML to set values to attributes. All attributes from all elements allow values from an HTML type.
Below there is a list of all types present in HTML. Enclosed between brackets is the case sensitivity information, which reference is at the bottom of this page.
"cdata" values are composed by a sequence of characters from the document's character set that may include character references.
This type takes as values single characters from the document's character set. Single characters may be specified with a character reference (e.g., "&").
Possible values for the "charset" type are the names of character encodings (e.g., "ISO 8859-1", "UTF-8" or "EUC-JP").
A "color" value may either be a hexadecimal number (prefixed by a number sign) or one of the following sixteen color names. The color names are case-insensitive.
The hexadecimal numbers are constructed with the RGB (red, green, blue) format. This means that the two first characters describe the red value, the two second ones the green and the two third ones the blue.
"content-type" values can be obtained from the list of MIME types.
A "datetime" value refers to a point in the timeline. The format must be as follows: YYYY-MM-DDThh:mm:ssTZD, where:
The value for the time zone designator (TZD) must be one of the following:
The "frame-target" type is used for values in the "target" attribute of the HTML tag. It accepts any text value that begins with a letter ([A-Z] or [a-z]), with the exception of the special values listed below, that have special meanings.
An "idref" value is a reference to an ID token defined in other attributes.
The "langcode" type accepts values referring to a specific language acording to the language codes table.
The "length" type accepts two types of values: a number of pixels (e.g., "20") or a percentage of the available space (e.g., "50%").
The possible values for this type are:
The possible values for the "media-descriptor" type are listed below:
Values of this type may be "lenght" or "relative lenght". A relative lenght behaves exactly like percentage values but over the space that's left. In other words, the browser first assigns the space for all lenght values and then divides what's left between the relative lenghts.
The notation for this value is "i*", where i is an integer. The sum of all the "i" values is equivalent to 100%. For example if we have these three definitions: "1*", "3*" and "4*", and a space of 80 pixels, the first value will take 10 pixels, the second 30 and the third 40.
A "name" value must begin with a letter ([A-Z] or [a-z]) and may be followed by letters, digits ([0-9]), hyphens ("-"), underscores ("_"), colons (":"), and periods (".").
A "number" value must contain at least one digit ([0-9]).
Values for the "pixel" type are integers representing the number of pixels of the canvas (screen, paper).
The style sheet data is a specific type and is not evaluated by browsers as HTML markup.
This type accepts as values text strings that are suposed to be "human readable", mostly used to be shown to the visitor, somewhere in the browser.
To know how to construct a value for this type, see the reference for URI and URL definitions. In general, these values are case-sensitive, but there may be URIs, or parts of them, where case doesn't matter (like machine names). Howerver, identifying these cases may not be easy, and so the recommendation is to consider them as case-sensitives to avoid errors.
This is the reference for the case-sensitivity of each type. It will help you understand how browsers will read the values you use in each attribute.
Diseño y desarrollo: Latitud29.com