head elementhtml
element.
title element.
HTMLElement.
The head element collects the
document's metadata.
title elementhead element containing no other
title elements.
HTMLElement.
The title element represents the
document's title or name. Authors should use titles that identify their
documents even when they are used out of context, for example in a user's
history or bookmarks, or in search results. The document's title is often
different from its first header, since the first header does not have to
stand alone when taken out of context.
There must be no more than one title
element per document.
The title element must not contain
any elements.
Here are some examples of appropriate titles, contrasted with the top-level headers that might be used on those same pages.
<title>Introduction to The Mating Rituals of Bees</title>
...
<h1>Introduction</h1>
<p>This companion guide to the highly successful
<cite>Introduction to Medieval Bee-Keeping</cite> book is...
The next page might be a part of the same site. Note how the title describes the subject matter unambiguously, while the first header assumes the reader knowns what the context is and therefore won't wonder if the dances are Salsa or Waltz:
<title>Dances used during bee mating rituals</title>
...
<h1>The Dances</h1>
The string to use as the document's title is given by the document.title DOM attribute. User
agents should use the document's title when referring to the document in
their user interface.
base elementhead element containing no other
base elements.
href
target
interface HTMLBaseElement : HTMLElement {
attribute DOMString href;
attribute DOMString target;
};
The base element allows authors to
specify the document's base URI for the purposes of resolving relative
URIs, and the name of the default browsing
context for the purposes of following
hyperlinks.
There must be no more than one base
element per document.
A base element must have either an
href attribute, a
target
attribute, or both.
The href content
attribute, if specified, must contain a URI (or IRI).
A base element, if it has an href attribute, must come
before any other elements in the tree that have attributes with URIs
(except the html element and its manifest
attribute).
User agents must use the value of the href attribute of the first base element that is both a child of the head element and has an href attribute, if there is such an element, as
the document entity's base URI for the purposes of section 5.1.1 of RFC
3986 ("Establishing a Base URI": "Base URI Embedded in Content"). This
base URI from RFC 3986 is referred to by the algorithm given in XML Base,
which is a normative part of this specification. [RFC3986]
If the base URI given by this attribute is a relative URI, it must be
resolved relative to the higher-level base URIs (i.e. the base URI from
the encapsulating entity or the URI used to retrieve the entity) to obtain
an absolute base URI. All xml:base
attributes must be ignored when resolving relative URIs in this href attribute.
If there are multiple base
elements with href attributes, all but
the first are ignored.
The target
attribute, if specified, must contain a valid browsing
context name or keyword. User agents use this name when following hyperlinks.
A base element, if it has a target attribute, must
come before any elements in the tree that represent hyperlinks.
The href and target DOM attributes
must reflect the content attributes of the same
name.
link elementnoscript element that is a
child of a head element.
href
rel
media
hreflang
type
sizes
title attribute has special semantics on this
element.
interface HTMLLinkElement : HTMLElement {
attribute boolean disabled;
attribute DOMString href;
attribute DOMString rel;
readonly attribute DOMTokenList relList;
attribute DOMString media;
attribute DOMString hreflang;
attribute DOMString type;
attribute DOMString sizes;
};
The LinkStyle interface must also be implemented by this
element, the styling processing model defines
how. [CSSOM]
The link element allows authors to link
their document to other resources.
The destination of the link is given by the href attribute, which must be
present and must contain a URI (or IRI). If the href attribute is absent,
then the element does not define a link.
The type of link indicated (the relationship) is given by the value of
the rel attribute,
which must be present, and must have a value that is a set of space-separated tokens. The allowed values and their meanings are defined in a
later section. If the rel attribute is absent, or if the value used is
not allowed according to the definitions in this specification, then the
element does not define a link.
Two categories of links can be created using the link element. Links to external resources are links to resources
that are to be used to augment the current document, and hyperlink links are links to other documents. The link types section defines whether a particular link
type is an external resource or a hyperlink. One element can create
multiple links (of which some might be external resource links and some
might be hyperlinks); exactly which and how many links are created depends
on the keywords given in the rel attribute. User agents must process the links
on a per-link basis, not a per-element basis.
The exact behavior for links to external resources depends on the exact relationship, as defined for the relevant link type. Some of the attributes control whether or not the external resource is to be applied (as defined below). For external resources that are represented in the DOM (for example, style sheets), the DOM representation must be made available even if the resource is not applied. (However, user agents may opt to only fetch such resources when they are needed, instead of pro-actively downloading all the external resources that are not applied.)
HTTP semantics must be followed when fetching external resources. (For example, redirects must be followed and 404 responses must cause the external resource to not be applied.)
Interactive user agents should provide users with a means to follow the hyperlinks
created using the link element, somewhere
within their user interface. The exact interface is not defined by this
specification, but it should include the following information (obtained
from the element's attributes, again as defined below), in some form or
another (possibly simplified), for each hyperlink created with each
link element in the document:
rel attribute)
title attribute).
href attribute).
hreflang
attribute).
media attribute).
User agents may also include other information, such as the type of the
resource (as given by the type attribute).
The media
attribute says which media the resource applies to. The value must be a
valid media query. [MQ]
If the link is a hyperlink then the media attribute is purely advisory, and
describes for which media the document in question was designed.
However, if the link is an external resource link,
then the media
attribute is prescriptive. The user agent must apply the external resource
to views while their state match the listed
media, and must not apply them otherwise.
The default, if the media attribute is omitted, is all,
meaning that by default links apply to all media.
The hreflang attribute on the
link element has the same semantics as
the hreflang attribute on hyperlink
elements.
The type attribute
gives the MIME type of the linked resource. It is purely advisory. The
value must be a valid MIME type, optionally with parameters. [RFC2046]
For external resource links, user agents may use the type given in this attribute to decide whether or not to consider using the resource at all. If the UA does not support the given MIME type for the given link relationship, then the UA may opt not to download and apply the resource.
User agents must not consider the type attribute authoritative — upon fetching
the resource, user agents must not use metadata included in the link to
the resource to determine its type.
If the attribute is omitted, but the user agent would fetch the resource if the type was known and supported, then the user agent must fetch the resource and determine its type from its Content-Type metadata to determine if it supports (and can apply) that external resource. If no type metadata is specified, but the external resource link type has a default type defined, then the user agent must assume that the resource is of that type.
If a document contains four style sheet links labeled as follows:
<link rel="stylesheet" href="A" type="text/plain"> <link rel="stylesheet" href="B" type="text/css"> <link rel="stylesheet" href="C">
...then a compliant UA that supported only CSS style sheets would fetch
the B and C files, and skip the A file (since text/plain is
not the MIME type for CSS style sheets).
For files B and C, it would then check the actual types returned by the
server. For those that are sent as text/css, it would apply
the styles, but for those labeled as text/plain, or any
other type, it would not.
If one the two files was returned without a Content-Type metadata, or with a syntactically
incorrect type like Content-Type: "null", then
the default type for stylesheet links would kick in. Since that
default type is text/css, the style sheet
would nonetheless be applied.
The title
attribute gives the title of the link. With one exception, it is purely
advisory. The value is text. The exception is for style sheet links, where
the title
attribute defines alternative style sheet sets.
The title attribute on link elements differs from the global title attribute of most other
elements in that a link without a title does not inherit the title of the
parent element: it merely has no title.
The sizes
attribute is used with the icon link type. The attribute must not be
specified on link elements that do not
have a rel attribute
that specifies the icon
keyword.
Some versions of HTTP defined a Link: header, to
be processed like a series of link
elements. When processing links, those must be taken into consideration as
well. For the purposes of ordering, links defined by HTTP headers must be
assumed to come before any links in the document, in the order that they
were given in the HTTP entity header. Relative URIs in these headers must
be resolved according to the rules given in HTTP, not relative to base
URIs set by the document (e.g. using a base element or xml:base attributes). [RFC2616] [RFC2068]
The DOM attributes href, rel, media, hreflang, and type, and sizes each must reflect the respective content attributes of the same
name.
The DOM attribute relList must reflect the rel content attribute.
The DOM attribute disabled only applies to style
sheet links. When the link element
defines a style sheet link, then the disabled attribute behaves as defined for the alternative style
sheets DOM. For all other link
elements it always return false and does nothing on setting.
meta elementcharset attribute is present, or if the
element is in the Encoding declaraton state: as
the first element in a head element.
http-equiv attribute is present, and the
element is not in the Encoding declaraton state: in
a head element.
http-equiv attribute is present, and the
element is not in the Encoding declaraton state: in
a noscript element that is a child
of a head element.
name
attribute is present: where metadata content is
expected.
name
http-equiv
content
charset
(HTML only)
interface HTMLMetaElement : HTMLElement {
attribute DOMString content;
attribute DOMString name;
attribute DOMString httpEquiv;
};
The meta element represents various
kinds of metadata that cannot be expressed using the title, base,
link, style, and script elements.
The meta element can represent
document-level metadata with the name attribute, pragma directives with the http-equiv
attribute, and the file's character encoding
declaration when an HTML document is serialised to string form (e.g.
for transmission over the network or for disk storage) with the charset attribute.
Exactly one of the name, http-equiv, and charset attributes
must be specified.
If either name or
http-equiv is specified, then the content attribute
must also be specified. Otherwise, it must be omitted.
The charset
attribute specifies the character encoding used by the document. This is
called a character encoding declaration.
The charset
attribute may be specified in HTML
documents only, it must not be used in XML documents. If the charset attribute is specified, the element
must be the first element in the head
element of the file.
The content
attribute gives the value of the document metadata or pragma directive
when the element is used for those purposes. The allowed values depend on
the exact context, as described in subsequent sections of this
specification.
If a meta element has a name attribute, it sets document
metadata. Document metadata is expressed in terms of name/value pairs, the
name attribute on
the meta element giving the name, and
the content
attribute on the same element giving the value. The name specifies what
aspect of metadata is being set; valid names and the meaning of their
values are described in the following sections. If a meta element has no content attribute,
then the value part of the metadata name/value pair is the empty string.
If a meta element has the http-equiv
attribute specified, it must be either in a head element or in a noscript element that itself is in a head element. If a meta element does not have the http-equiv
attribute specified, it must be in a head
element.
The DOM attributes name and content must reflect the respective content attributes of the same
name. The DOM attribute httpEquiv must reflect the content attribute http-equiv.
This specification defines a few names for the name attribute of the
meta element.
The value must be a short free-form string that giving the name of the
Web application that the page represents. If the page is not a Web
application, the application-name metadata name must
not be used. User agents may use the application name in UI in
preference to the page's title, since
the title might include status messages and the like relevant to the
status of the page at a particular moment in time instead of just being
the name of the application.
The value must be a free-form string that describes the page. The value must be appropriate for use in a directory of pages, e.g. in a search engine.
The value must be a free-form string that identifies the software used to generate the document. This value must not be used on hand-authored pages.
Extensions to the predefined set of metadata names may be registered in the WHATWG Wiki MetaExtensions page.
Anyone is free to edit the WHATWG Wiki MetaExtensions page at any time to add a type. These new names must be specified with the following information:
The actual name being defined. The name should not be confusingly similar to any other defined name (e.g. differing only in case).
A short description of what the metadata name's meaning is, including the format the value is required to be in.
A list of other names that have exactly the same processing requirements. Authors should not use the names defined to be synonyms, they are only intended to allow user agents to support legacy content.
One of the following:
If a metadata name is added with the "proposal" status and found to be redundant with existing values, it should be removed and listed as a synonym for the existing value.
Conformance checkers must use the information given on the WHATWG Wiki MetaExtensions page to establish if a value not explicitly defined in this specification is allowed or not. When an author uses a new type not defined by either this specification or the Wiki page, conformance checkers should offer to add the value to the Wiki, with the details described above, with the "proposal" status.
This specification does not define how new values will get approved. It is expected that the Wiki will have a community that addresses this.
Metadata names whose values are to be URIs must not be proposed or
accepted. Links must be represented using the link element, not the meta element.
When the http-equiv attribute is
specified on a meta element, the element
is a pragma directive.
The http-equiv attribute is an
enumerated attribute. The following table lists
the keywords defined for this attribute. The states given in the first
cell of the rows with keywords give the states to which those keywords
map.
| State | Keywords |
|---|---|
| Encoding declaration | Content-Type
|
| Default style | default-style
|
| Refresh | refresh
|
When a meta element is inserted into
the document, if its http-equiv attribute is present and
represents one of the above states, then the user agent must run the
algorithm appropriate for that state, as described in the following list:
The Encoding declaration state's
user agent requirements are all handled by the parsing section of the
specification. The state is just an alternative form of setting the
charset attribute: it is a character encoding declaration.
For meta elements in the Encoding
declaraton state, the content attribute must have a value that is
a case-insensitive match of a string that consists
of the literal string "text/html;", optionally
followed by any number of space
characters, followed by the literal string "charset=", followed by the character encoding name of the character encoding declaration.
If the document contains a meta
element in the Encoding declaraton state
then that element must be the first element in the document's head element, and the document must not contain
a meta element with the charset attribute
present.
The Encoding declaraton state may be used in HTML documents only, elements in that state must not be used in XML documents.
If another meta element in the Refresh state
has already been successfully processed (i.e. when it was inserted the
user agent processed it and reached the last step of this list of
steps), then abort these steps.
If the meta element has no content
attribute, or if that attribute's value is the empty string, then
abort these steps.
Let input be the value of the element's content
attribute.
Let position point at the first character of input.
Collect a sequence of characters in the range U+0030 DIGIT ZERO to U+0039 DIGIT NINE, and parse the resulting string using the rules for parsing non-negative integers. If the sequence of characters collected is the empty string, then no number will have been parsed; abort these steps. Otherwise, let time be the parsed number.
Collect
a sequence of characters in the range U+0030 DIGIT ZERO to U+0039
DIGIT NINE and U+002E FULL STOP ("."). Ignore
any collected characters.
Let url be the address of the current page.
If the character in input pointed to by position is a U+003B SEMICOLON (";"), then advance position to the
next character. Otherwise, jump to the last step.
If the character in input pointed to by position is one of U+0055 LATIN CAPITAL LETTER U or U+0075 LATIN SMALL LETTER U, then advance position to the next character. Otherwise, jump to the last step.
If the character in input pointed to by position is one of U+0052 LATIN CAPITAL LETTER R or U+0072 LATIN SMALL LETTER R, then advance position to the next character. Otherwise, jump to the last step.
If the character in input pointed to by position is one of U+004C LATIN CAPITAL LETTER L or U+006C LATIN SMALL LETTER L, then advance position to the next character. Otherwise, jump to the last step.
If the character in input pointed to by position is a U+003D EQUALS SIGN ("="), then advance position to the
next character. Otherwise, jump to the last step.
Let url be equal to the substring of input from the character at position to the end of the string.
Strip any trailing space characters from the end of url.
Strip any U+0009 CHARACTER TABULATION, U+000A LINE FEED (LF), and U+000D CARRIAGE RETURN (CR) characters from url.
Resolve the url value to an absolute URI using
the base URI of the meta element.
Perform one or more of the following steps:
Set a timer so that in time seconds, adjusted to take into account user or user agent preferences, if the user has not canceled the redirect, the user agent navigates the document's browsing context to url, with replacement enabled, and with the document's browsing context as the source browsing context.
Provide the user with an interface that, when selected, navigates a browsing context to url, with the document's browsing context as the source browsing context.
Do nothing.
In addition, the user agent may, as with anything, inform the user of any and all aspects of its operation, including the state of any timers, the destinations of any timed redirects, and so forth.
For meta elements in the Refresh state,
the content
attribute must have a value consisting either of:
;), followed by one or more space characters, followed by
either a U+0055 LATIN CAPITAL LETTER U or a U+0075 LATIN SMALL LETTER
U, a U+0052 LATIN CAPITAL LETTER R or a U+0072 LATIN SMALL LETTER R, a
U+004C LATIN CAPITAL LETTER L or a U+006C LATIN SMALL LETTER L, a
U+003D EQUALS SIGN (=), and then a valid URI (or
IRI).
In the former case, the integer represents a number of seconds before the page is to be reloaded; in the latter case the integer represents a number of seconds before the page is to be replaced by the page at the given URI.
There must not be more than one meta
element with any particular state in the document at a time.
A character encoding declaration is a mechanism by which the character encoding used to store or transmit a document is specified.
The following restrictions apply to character encoding declarations:
If the document does not start with a BOM, and if its encoding is not
explicitly given by Content-Type metadata, then the character encoding
used must be a superset of US-ASCII (specifically, ANSI_X3.4-1968) for
bytes in the range 0x09 - 0x0D, 0x20, 0x21, 0x22, 0x26, 0x27, 0x2C - 0x3F,
0x41 - 0x5A, and 0x61 - 0x7A
,
and, in addition, if that encoding isn't US-ASCII itself, then the
encoding must be specified using a meta
element with a charset attribute or a meta element in the Encoding declaraton state.
Authors should not use JIS_X0212-1990, x-JIS0208, and encodings based on EBCDIC. Authors should not use UTF-32. Authors must not use the CESU-8, UTF-7, BOCU-1 and SCSU encodings. [CESU8] [UTF7] [BOCU1] [SCSU]
Authors are encouraged to use UTF-8. Conformance checkers may advise against authors using legacy encodings.
In XHTML, the XML declaration should be used for inline character encoding information, if necessary.
style elementscoped attribute is present: flow content.
scoped attribute is absent: where metadata content is expected.
scoped attribute is absent: in a noscript element that is a child of a
head element.
scoped attribute is present: where flow content is expected, but before any
sibling elements other than style
elements and before any text nodes other than inter-element whitespace.
type attribute.
media
type
scoped
title attribute has special semantics on this
element.
interface HTMLStyleElement : HTMLElement {
attribute boolean disabled;
attribute DOMString media;
attribute DOMString type;
attribute boolean scoped;
};
The LinkStyle interface must also be implemented by this
element, the styling processing model defines
how. [CSSOM]
The style element allows authors to
embed style information in their documents. The style element is one of several inputs to the styling processing model.
If the type
attribute is given, it must contain a valid MIME type, optionally with
parameters, that designates a styling language. [RFC2046] If the attribute is absent, the type
defaults to text/css. [RFC2138]
When examining types to determine if they support the language, user agents must not ignore unknown MIME parameters — types with unknown parameters must be assumed to be unsupported.
The media
attribute says which media the styles apply to. The value must be a valid
media query. [MQ] User agents must
apply the styles to views while their state match the listed
media, and must not apply them otherwise. [DOM3VIEWS]
The default, if the media attribute is
omitted, is all, meaning that by default styles apply to all
media.
The scoped
attribute is a boolean attribute. If the attribute
is present, then the user agent must apply the specified style information
only to the style element's parent
element (if any), and that element's child nodes. Otherwise, the specified
styles must, if applied, be applied to the entire document.
If the scoped
attribute is not specified, the style
element must be the child of a head
element or of a noscript element that
is a child of a head element.
If the scoped
attribute is specified, then the style element must be the child of a flow content element, before any text nodes
other than inter-element whitespace, and
before any elements other than other style elements.
The title attribute on style elements defines alternative style sheet sets. If the style element has no title attribute, then
it has no title; the title attribute of ancestors does not apply to
the style element.
The title attribute on style elements, like the title attribute on
link elements, differs from the global
title attribute in that
a style block without a title does not
inherit the title of the parent element: it merely has no title.
All descendant elements must be processed, according to their semantics,
before the style element itself is
evaluated. For styling languages that consist of pure text, user agents
must evaluate style elements by passing
the concatenation of the contents of all the text nodes that are direct children of the style element (not any other nodes such as
comments or elements), in tree order, to the
style system. For XML-based styling languages, user agents must pass all
the children nodes of the style element
to the style system.
This specification does not specify a style system, but CSS is expected to be supported by most Web browsers. [CSS21]
The media, type and scoped DOM attributes must reflect the respective content attributes of the same
name.
The DOM disabled attribute behaves as
defined for the
alternative style sheets DOM.
The link and style elements can provide styling information
for the user agent to use when rendering the document. The DOM Styling
specification specifies what styling information is to be used by the user
agent and how it is to be used. [CSSOM]
The style and link elements implement the LinkStyle
interface. [CSSOM]
For style elements, if the user agent
does not support the specified styling language, then the sheet attribute of the element's
LinkStyle interface must return null. Similarly, link elements that do not represent external resource links that
contribute to the styling processing model (i.e. that do not have a
stylesheet
keyword in their rel
attribute), and link elements whose
specified resource has not yet been downloaded, or is not in a supported
styling language, must have their LinkStyle interface's sheet attribute return null.
Otherwise, the LinkStyle interface's sheet attribute must return a
StyleSheet object with the attributes implemented as follows:
[CSSOM]
type DOM
attribute)
The content type must be the same as the style's specified type. For
style elements, this is the same as
the type content
attribute's value, or text/css if that is omitted.
For link elements, this is the Content-Type metadata of the
specified resource.
href DOM
attribute)
For link elements, the location must
be the URI given by the element's href content attribute. For style elements, there is no location.
media DOM attribute)
The media must be the same as the value of the element's media content attribute.
title
DOM attribute)
The title must be the same as the value of the element's title content attribute. If the attribute is absent,
then the style sheet does not have a title. The title is used for
defining alternative style sheet sets.
The disabled DOM attribute on
link and style elements must return false and do nothing
on setting, if the sheet attribute
of their LinkStyle interface is null. Otherwise, it must
return the value of the StyleSheet interface's disabled attribute on getting, and
forward the new value to that same attribute on setting.