Favorite books
These are a few of my favorite books.
White Teeth
The award winning debut novel by Zadie Smith
The Hitchhiker's Guide to the Galaxy
A trilogy of five books by Douglas Adams.
Interactive user agents typically expose the {{Document}} object's [=Document/URL=] in their user interface. This is the primary mechanism by which a user can tell if a site is attempting to impersonate another.
When a {{Document}} is created by a [=concept/script=] using the {{DOMImplementation/createDocument()}} or {{DOMImplementation/createHTMLDocument()}} APIs, the {{Document}} is both [=ready for post-load tasks=] and [=completely loaded=] immediately. The document's referrer is a string (representing a [=url/URL=]) that can be set when the {{Document}} is created. If it is not explicitly set, then its value is the empty string. Each {{Document}} object has a reload override flag that is originally unset. The flag is set by the {{Document/open()|document.open()}} and {{Document/write()|document.write()}} methods in certain situations. When the flag is set, the {{Document}} also has a reload override buffer which is a Unicode string that is used as the source of the document when it is reloaded. When the user agent is to perform an overridden reload, given a [=source browsing context=], it must act as follows: 1. Let |source| be the value of the [=browsing context=]'s [=active document=]'s [=reload override buffer=]. 2. Let |address| be the [=browsing context=]'s [=active document=]'s [=document url|URL=]. 3. Let |HTTPS state| be the HTTPS state of the [=browsing context=]'s [=active document=]. 4. Let |referrer policy| be the referrer policy of the [=browsing context=]'s [=active document=]. 4. Let |CSP list| be the CSP list of the [=browsing context=]'s [=active document=]. 5. [=Navigate=] the [=browsing context=] to a new [=response=] whose [=response/body=] is |source|, [=response/header list=] isReferrer-Policy/|referrer policy|,
[=response/CSP list=] is |CSP list| and [=response/HTTPS state=] is |HTTPS state|, with the
[=exceptions enabled flag=] set and [=replacement enabled=]. The [=source browsing context=]
is that given to the [=overridden reload=] algorithm. When the [=navigate=] algorithm creates
a {{Document}} object for this purpose, set that {{Document}}'s [=reload override flag=] and
set its [=reload override buffer=] to |source|. Rethrow any exceptions.
When it comes time to set the document's address in the [=navigation algorithm=], use
|address| as the [=override URL=].
enum DocumentReadyState { "loading", "interactive", "complete" };
typedef (HTMLScriptElement or SVGScriptElement) HTMLOrSVGScriptElement;
[OverrideBuiltins]
partial interface Document {
// resource metadata management
[PutForwards=href, Unforgeable] readonly attribute Location? location;
attribute USVString domain;
readonly attribute USVString referrer;
attribute USVString cookie;
readonly attribute DOMString lastModified;
readonly attribute DocumentReadyState readyState;
// DOM tree accessors
getter object (DOMString name);
[CEReactions] attribute DOMString title;
attribute DOMString dir;
attribute HTMLElement? body;
readonly attribute HTMLHeadElement? head;
[SameObject] readonly attribute HTMLCollection images;
[SameObject] readonly attribute HTMLCollection embeds;
[SameObject] readonly attribute HTMLCollection plugins;
[SameObject] readonly attribute HTMLCollection links;
[SameObject] readonly attribute HTMLCollection forms;
[SameObject] readonly attribute HTMLCollection scripts;
NodeList getElementsByName(DOMString elementName);
readonly attribute HTMLOrSVGScriptElement? currentScript; // classic scripts in a document tree only
// dynamic markup insertion
Document open(optional DOMString type = "text/html", optional DOMString replace = "");
WindowProxy open(DOMString url, DOMString name, DOMString features, optional boolean replace = false);
[CEReactions] void close();
[CEReactions] void write(DOMString... text);
[CEReactions] void writeln(DOMString... text);
// user interaction
readonly attribute WindowProxy? defaultView;
readonly attribute Element? activeElement;
boolean hasFocus();
[CEReactions] attribute DOMString designMode;
[CEReactions] boolean execCommand(DOMString commandId, optional boolean showUI = false, optional DOMString value = "");
boolean queryCommandEnabled(DOMString commandId);
boolean queryCommandIndeterm(DOMString commandId);
boolean queryCommandState(DOMString commandId);
boolean queryCommandSupported(DOMString commandId);
DOMString queryCommandValue(DOMString commandId);
// special event handler IDL attributes that only apply to Document objects
[LenientThis] attribute EventHandler onreadystatechange;
};
Document implements GlobalEventHandlers;
Document implements DocumentAndElementEventHandlers;
The {{Document}} has an HTTPS state (an [=HTTPS state value=]),
initially "none", which represents the security properties of the network channel
used to deliver the {{Document}}'s data.
The {{Document}} has a
referrer policy
(a [=referrer policy=]), initially the empty string, which represents the default
[=referrer policy=] used by [=fetches=] initiated by the {{Document}}.
The {{Document}} has a CSP list, which is a CSP list
containing all of the [=Content Security Policy=] objects active for the document. The
list is empty unless otherwise specified.
The {{Document}} has a module map, which is a [=module map=],
initially empty.
referrer attribute must return
[=the document's referrer=].
cookie attribute represents the cookies of
the resource identified by the document's [=Document/URL=].
A {{Document}} object that falls into one of the following conditions is a
cookie-averse {{Document}} object:
* A {{Document}} that has no [=browsing context=].
* A {{Document}} whose [=Document/URL=]'s [=url/scheme=] is not a [=network scheme=].
On getting, if the document is a [=cookie-averse=] {{Document}} object, then the user agent must
return the empty string. Otherwise, if the {{Document}}'s [=concept/origin=] is an
[=opaque origin=], the user agent must throw a "{{SecurityError}}" {{DOMException}}. Otherwise,
the user agent must return the [=cookie-string=] for the document's [=Document/URL=] for a
"non-HTTP" API, decoded using [=UTF-8 decode without BOM=]. [[!COOKIES]]
Since the {{Document/cookie}} attribute is accessible across frames, the path restrictions on cookies are only a tool to help manage which cookies are sent to which parts of the site, and are not in any way a security feature.
The {{Document/cookie}} attribute's getter and setter synchronously access shared state. Since there is no locking mechanism, other browsing contexts in a multiprocess user agent can modify cookies while scripts are running. A site could, for instance, try to read a cookie, increment its value, then write it back out, using the new value of the cookie as a unique identifier for the session; if the site does this twice in two different browser windows at the same time, it might end up using the same "unique" identifier for both sessions, with potentially disastrous effects.
MM/DD/YYYY hh:mm:ss", in the user's local time zone.
If the last modification date is not known, the current time is returned instead.
lastModified attribute, on getting, must
return the date and time of the {{Document}}'s source file's last modification, in the user's
local time zone, in the following format:
1. The month component of the date.
2. A U+002F SOLIDUS character (/).
3. The day component of the date.
4. A U+002F SOLIDUS character (/).
5. The year component of the date.
6. A U+0020 SPACE character.
7. The hours component of the time.
8. A U+003A COLON character (:).
9. The minutes component of the time.
10. A U+003A COLON character (:).
11. The seconds component of the time.
All the numeric components above, other than the year, must be given as two [=ASCII digits=]
representing the number in base ten, zero-padded if necessary. The year must be given as the
shortest possible string of four [=ASCII digits=] representing the number in base
ten, zero-padded if necessary.
The {{Document}}'s source file's last modification date and time must be derived from relevant
features of the networking protocols used, e.g., from the value of the HTTP
Last-Modified header of the document, or from metadata in the
file system for local files. If the last modification date and time are not known, the attribute
must return the current date and time in the above format.
readyState IDL attribute must, on getting,
return the [=current document readiness=].
head attribute, on getting, must return the
<{head}> element of the document (a <{head}> element or null).
title element for SVG.
Can be set, to update the document's title. If there is no appropriate element to update,
the new value is ignored.
title attribute must, on getting, run the
following algorithm:
1. If the [=document element=] is an SVG <{svg}> element, then let |value| be the
[=child text content=] of the first SVG title element
that is a child of the [=document element=]. [[!SVG11]]
2. Otherwise, let |value| be the [=child text content=] of the <{title}> element, or the empty
string if the <{title}> element is null.
3. [=Strip and collapse white space=] in |value|.
4. Return |value|.
On setting, the steps corresponding to the first matching condition in the following list must be
run:
title element that is a child of
the [=document element=], let |element| be the first such element.
2. Otherwise:
1. Let |element| be the result of [=creating an element=] given the
[=document element=]'s [=node document=], SVG
title, and the [=SVG namespace=].
2. Insert |element| as the first child of the [=document element=].
3. Act as if the {{Node/textContent}} IDL attribute of |element| was set to the new value
being assigned.
: If the [=document element=] is in the [=HTML namespace=]
:: 1. If the <{title}> element is null and the <{head}> element is null, then abort these steps.
2. If the <{title}> element is non-null, let |element| be the <{title}> element.
3. Otherwise:
1. Let |element| be the result of [=creating an element=] given the
[=document element=]'s [=node document=], <{title}>, and the [=HTML namespace=].
2. [=Append=] |element| to the <{head}> element.
4. Act as if the {{Node/textContent}} IDL attribute of |element| was set to the new value
being assigned.
: Otherwise
:: Do nothing.
body attribute, on getting, must return the
<{body}> element of the document (either a <{body}> element, a <{frameset}> element, or null). On
setting, the following algorithm must be run:
1. If the new value is not a <{body}> or <{frameset}> element, then throw a
"{{HierarchyRequestError}}" {{DOMException}} and abort these steps.
2. Otherwise, if the new value is the same as the <{body}> element, do nothing. Abort these steps.
3. Otherwise, if the <{body}> element is not null, then [=replace=] the <{body}> element
with the new value within the <{body}> element's parent and abort these steps.
4. Otherwise, if there is no [=document element=], throw a "{{HierarchyRequestError}}"
{{DOMException}} and abort these steps.
5. Otherwise, the <{body}> element is null, but there's a [=document element=]. [=Append=]
the new value to the [=document element=].
images attribute must return an
{{HTMLCollection}} rooted at the {{Document}} node, whose filter matches only <{img}> elements.
The embeds attribute must return an
{{HTMLCollection}} rooted at the {{Document}} node, whose filter matches only <{embed}> elements.
The plugins attribute must return the same object
as that returned by the {{Document/embeds}} attribute.
The links attribute must return an
{{HTMLCollection}} rooted at the {{Document}} node, whose filter matches only <{a}> elements with
<{links/href}> attributes and <{area}> elements with <{links/href}> attributes.
The forms attribute must return an
{{HTMLCollection}} rooted at the {{Document}} node, whose filter matches only <{form}> elements.
The scripts attribute must return an
{{HTMLCollection}} rooted at the {{Document}} node, whose filter matches only <{script}> elements.
name
attribute with the value |name|.
getElementsByName(|name|)
method takes a string |name|, and must return a [=live=] {{NodeList}} containing all the
[=HTML elements=] in that document that have a name attribute whose value is equal to
the |name| argument (in a [=case-sensitive=] manner), in [=tree order=]. When the method is
invoked on a {{Document}} object again with the same argument, the user agent may return the same
as the object returned by the earlier call. In other cases, a new {{NodeList}} object must be
returned.
script
element, that is currently executing, as long as the element represents a
[=classic script=]. In the case of reentrant script execution, returns the one that most
recently started executing amongst those that have not yet finished executing.
Returns null if the {{Document}} is not currently executing a <{script}> element or
SVG script element (e.g., because the running script
is an event handler, or a timeout), or if the currently executing <{script}> or SVG
script element represents a [=module script=].
currentScript attribute, on getting, must
return the value to which it was most recently initialized. When the {{Document}} is created, the
{{Document/currentScript}} must be initialized to null.
This API has fallen out of favor in the implementor and standards community, as it
globally exposes <{script}> or SVG script elements. As such,
it is not available in newer contexts, such as when running [=module scripts=] or when running
scripts in a shadow tree.
name attributes when the same element contributes both:
* the value of the name content attribute for all [=exposed=] <{embed}>,
<{form}>, <{iframe}>, <{img}>, and [=exposed=] <{object}> elements that have a non-empty
name content attribute and are [=in a document tree=] with |document| as their
[=root=];
* the value of the <{global/id}> content attribute for all [=exposed=] <{object}>
elements that have a non-empty <{global/id}> content attribute and are [=in a document tree=]
with |document| as their [=root=];
* the value of the <{global/id}> content attribute for all <{img}> elements that have both a
non-empty <{global/id}> content attribute and a non-empty name content attribute,
and are [=in a document tree=] with |document| as their [=root=].
To determine the value of a named property |name| for a {{Document}}, the
user agent must return the value obtained using the following steps:
1. Let |elements| be the list of [=named elements=] with the name |name| that are
[=in a document tree=] with the {{Document}} as their [=root=].
There will be at least one such element, by definition.
2. If |elements| has only one element, and that element is an <{iframe}> element, and that <{iframe}> element's [=nested browsing context=] is not null, then return the {{WindowProxy}} object of the element's [=nested browsing context=]. 3. Otherwise, if |elements| has only one element, return that element. 4. Otherwise return an {{HTMLCollection}} rooted at the {{Document}} node, whose filter matches only [=named elements=] with the name |name|. Named elements with the name |name|, for the purposes of the above algorithm, are those that are either: * [=exposed=] <{embed}>, <{form}>, <{iframe}>, <{img}>, or [=exposed=] <{object}> elements that have aname content attribute whose value is |name|, or
* [=exposed=] <{object}> elements that have an <{global/id}> content
attribute whose value is |name|, or
* <{img}> elements that have an <{global/id}> content attribute whose value is |name|, and that
have a non-empty name content attribute present also.
An <{embed}> or <{object}> element is said to be exposed if it has no [=exposed=]
<{object}> ancestor, and, for <{object}> elements, is additionally either not showing its
[=fallback content=] or has no <{object}> or <{embed}> descendants.
The {{Document/dir}} attribute on the {{Document}} interface is defined along with the <{global/dir}> content attribute.
These are a few of my favorite books.
The award winning debut novel by Zadie Smith
A trilogy of five books by Douglas Adams.
These are a few of my favorite books.
White TeethThe award winning debut novel by Zadie Smith
The Hitchhiker's Guide to the GalaxyA trilogy of five books by Douglas Adams.
DOM nodes whose [=node document=] does not have a [=browsing context=] are exempt from all document conformance requirements other than [=the HTML syntax=] requirements and [=the XML syntax=] requirements.
For example, an <{ol}> element represents an ordered list.
The basic interface, from which all the [=HTML elements=]' interfaces inherit, and which must be used by elements that have no additional requirements, is the {{HTMLElement}} interface.
[HTMLConstructor]
interface HTMLElement : Element {
// metadata attributes
[CEReactions] attribute DOMString title;
[CEReactions] attribute DOMString lang;
[CEReactions] attribute boolean translate;
[CEReactions] attribute DOMString dir;
// user interaction
[CEReactions] attribute boolean hidden;
void click();
[CEReactions] attribute DOMString accessKey;
[CEReactions] attribute boolean draggable;
[CEReactions] attribute boolean spellcheck;
void forceSpellCheck();
[CEReactions, TreatNullAs=EmptyString] attribute DOMString innerText;
};
HTMLElement implements GlobalEventHandlers;
HTMLElement implements DocumentAndElementEventHandlers;
HTMLElement implements ElementContentEditable;
// Note: intentionally not [HTMLConstructor]
interface HTMLUnknownElement : HTMLElement { };
The {{HTMLElement}} interface holds methods and attributes related to a number of disparate
features, and the members of this interface are therefore described in various different sections
of this specification.
The {{HTMLUnknownElement}} interface must be used for [=HTML elements=] that are not defined by
this specification (or [=other applicable specifications=]).
The [=element interface=] for an element with name |name| in the [=HTML namespace=] is determined
as follows:
1. If |name| is <{applet}>, <{bgsound}>, <{blink}>, <{isindex}>, <{multicol}>, <{nextid}>, or <{spacer}>, then
return {{HTMLUnknownElement}}.
2. If |name| is <{acronym}>, <{basefont}>, <{big}>, <{center}>, <{nobr}>, <{noembed}>,
<{noframes}>, <{plaintext}>, <{rb}>, <{rtc}>, <{strike}>, or <{tt}>, then return
{{HTMLElement}}.
3. If |name| is <{listing}> or <{xmp}>, then return {{HTMLPreElement}}.
4. Otherwise, if this specification defines an interface appropriate for the [=element type=]
corresponding to the local name |name|, then return that interface.
5. If [=other applicable specifications=] define an appropriate interface for |name|, then
return the interface they define.
6. If |name| is a [=valid custom element name=], then return {{HTMLElement}}.
7. Return {{HTMLUnknownElement}}.
The use of {{HTMLElement}} instead of {{HTMLUnknownElement}} in the case of [=valid custom element names=] is done to ensure that any potential future [=upgrades=] only cause a linear transition of the element's prototype chain, from {{HTMLElement}} to a subclass, instead of a lateral one, from {{HTMLUnknownElement}} to an unrelated subclass.
Features shared between HTML and SVG elements are defined in the {{HTMLOrSVGElement}} interface mixin:
interface mixin HTMLOrSVGElement {
[SameObject] readonly attribute DOMStringMap dataset;
attribute DOMString nonce;
[CEReactions] attribute long tabIndex;
void focus(optional FocusOptions options);
void blur();
};
HTMLElement includes HTMLOrSVGElement;
SVGElement includes HTMLOrSVGElement;
Each {{Window}} object is associated with a unique instance of a {{CustomElementRegistry}} object, allocated when the {{Window}} object is created.
Custom element registries are associated with {{Window}} objects, instead of {{Document}} objects, since each custom element constructor inherits from the {{HTMLElement}} interface, and there is exactly one {{HTMLElement}} interface per {{Window}} object.
The {{Window/customElements}} attribute of the {{Window}} interface returns the {{CustomElementRegistry}} object for that {{Window}} object.
interface CustomElementRegistry {
[CEReactions] void define(DOMString name, Function constructor, optional ElementDefinitionOptions options);
any get(DOMString name);
Promise<void> whenDefined(DOMString name);
};
dictionary ElementDefinitionOptions {
DOMString extends;
};
Every {{CustomElementRegistry}} has:
If IsConstructor(constructor) is false, then throw a {{TypeError}} and abort these steps.
If name is not a valid custom element name, then throw a "{{SyntaxError}}" {{DOMException}} and abort these steps.
If this {{CustomElementRegistry}} contains an entry with name name, then throw a "{{NotSupportedError}} {{DOMException}} and abort these steps.
If this {{CustomElementRegistry}} contains an entry with constructor constructor, then throw a "{{NotSupportedError}}" {{DOMException}} and abort these steps.
Let localName be name.
Let extends be the value of the extends member of options, or null if no such member exists.
If extends is not null, then:
If extends is a valid custom element name, then throw a "{{NotSupportedError}}" {{DOMException}}.
If the element interface for extends and the HTML namespace is {{HTMLUnknownElement}} (e.g., if extends does not indicate an element definition in this specification), then throw a "{{NotSupportedError}}" {{DOMException}}.
Set localName to extends.
If this {{CustomElementRegistry}}'s element definition is running flag is set, then throw a "{{NotSupportedError}}" {{DOMException}} and abort these steps.
Set this {{CustomElementRegistry}}'s element definition is running flag.
Run the following substeps while catching any exceptions:
Let prototype be Get(constructor, "prototype"). Rethrow any exceptions.
If Type(prototype) is not Object, then throw a TypeError exception.
Let lifecycleCallbacks be a map with the four keys "connectedCallback",
"disconnectedCallback", "adoptedCallback", and
"attributeChangedCallback", each of which belongs to an entry whose value is null.
For each of the four keys callbackName in lifecycleCallbacks, in the order listed in the previous step:
Let callbackValue be {{get}}(prototype, callbackName). Rethrow any exceptions.
If callbackValue is not undefined, then set the value of the entry in lifecycleCallbacks with key callbackName to the result of converting callbackValue to the Web IDL {{Function}} callback type. Rethrow any exceptions from the conversion.
Let observedAttributes be an empty sequence<DOMString>.
If the value of the entry in lifecycleCallbacks with key "attributeChangedCallback" is not null, then:
Let observedAttributesIterable be Get(constructor, "observedAttributes"). Rethrow any exceptions.
If observedAttributesIterable is not undefined, then set
observedAttributes to the result of converting
observedAttributesIterable to a sequence<DOMString>.
Rethrow any exceptions from the conversion.
Then, perform the following substep, regardless of whether the above steps threw an exception or not:
Unset this {{CustomElementRegistry}}'s element definition is running flag.
Finally, if the first set of substeps threw an exception, then rethrow that exception, and terminate this algorithm. Otherwise, continue onward.
Let definition be a new custom element definition with name name, local name localName, constructor constructor, prototype prototype, observed attributes observedAttributes, and lifecycle callbacks lifecycleCallbacks.
Add definition to this {{CustomElementRegistry}}.
Let document be this {{CustomElementRegistry}}'s relevant global object's associated Document.
Let upgrade candidates be all elements that are shadow-including descendants of document, whose namespace is the HTML namespace and whose local name is localName, in shadow-including tree order. Additionally, if extends is non-null, only include elements whose is value is equal to name.
For each element element in upgrade candidates, enqueue a custom element upgrade reaction given element and definition.
If this {{CustomElementRegistry}}'s when-defined promise map contains an entry with key name:
Let promise be the value of that entry.
Resolve promise with undefined.
Delete the entry with key name from this {{CustomElementRegistry}}'s when-defined promise map.
When invoked, the get(name) method must run these steps:
If this {{CustomElementRegistry}} contains an entry with name name, then return that entry's constructor.
Otherwise, return undefined.
If name is not a valid custom element name, then return a new promise rejected with a "{{SyntaxError}}" {{DOMException}} and abort these steps.
If this {{CustomElementRegistry}} contains an entry with name name, then return a new promise resolved with undefined and abort these steps.
Let map be this {{CustomElementRegistry}}'s when-defined promise map.
If map does not contain an entry with key name, create an entry in map with key name and whose value is a new promise.
Let promise be the value of the entry in map with key name.
Return promise.
The {{whenDefined()}} method can be used to avoid performing an action until all appropriate custom elements are defined. In this example, we combine it with the :defined pseudo-class to hide a dynamically-loaded article's contents until all the autonomous custom elements it uses are defined.
To upgrade an element, given a custom element definition definition and an element element, run the following steps:
If element is custom, abort these steps.
This can occur due to reentrant invocation of this algorithm, as in the following example:
This step will thus bail out the algorithm early when upgrade an element is invoked with "b" a second time.
If element's custom element state is "failed", then abort these steps.
For each attribute in element's attribute list, in order,
enqueue a custom element callback reaction with element,
callback name "attributeChangedCallback", and an argument list containing
attribute's local name, null, attribute's value, and attribute's namespace.
If element is connected, then enqueue a custom element callback reaction
with element, callback name "connectedCallback", and an empty argument list.
Add element to the end of definition's construction stack.
Let C be definition's constructor.
Let constructResult be Construct(C).
If C non-conformantly uses an API decorated with the [{{CEReactions}}] extended attribute, then the reactions enqueued at the beginning of this algorithm will execute during this step, before C finishes and control returns to this algorithm. Otherwise, they will execute after C and the rest of the upgrade process finishes.
Remove the last entry from the end of definition's construction stack.
Assuming C calls super()
and that the call succeeds, this will be the already constructed marker
that replaced the element pushed at the beginning of this algorithm.
(The HTML element constructor carries out this replacement.)
If C does not call super() (i.e. it is not conformant),
or if any step in the HTML element constructor throws, then this entry will still be element.
If constructResult is an abrupt completion, then:
Set element's custom element state to "failed".
Return constructResult (i.e., rethrow the exception), and terminate these steps.
If SameValue(constructResult.[[\value]], element) is false, then throw an "{{InvalidStateError}}" {{DOMException}} and terminate these steps.
This can occur if C constructs another instance of the same custom element before calling super(), or if C uses JavaScript's return-override feature to return an arbitrary object from the constructor.
Set element's custom element state to "custom".
Set element's custom element definition to definition.
To try to upgrade an element, given as input an element element, run the following steps:
Let definition be the result of looking up a custom element definition given element's node document, element's namespace, element's local name, and element's is value.
If definition is not null, then enqueue a custom element upgrade reaction given element and definition.
connectedCallback is run.
disconnectedCallback is run.
adoptedCallback is run.
attributeChangedCallback is run.
Let definition be element's custom element definition.
Let callback be the value of the entry in definition's lifecycle callbacks with key callbackName.
If callback is null, then abort these steps.
If callbackName is "attributeChangedCallback", then:
Let attributeName be the first element of args.
If definition's observed attributes does not contain attributeName, then abort these steps.
Add a new callback reaction to element's custom element reaction queue, with callback function callback and arguments args.
Enqueue an element on the appropriate element queue given element.
To enqueue a custom element upgrade reaction, given an element element and custom element definition definition, run the following steps:
Add a new upgrade reaction to element's custom element reaction queue, with custom element definition definition.
Enqueue an element on the appropriate element queue given element.
To invoke custom element reactions in an element queue queue, run the following steps:
For each custom element element in queue:
Let reactions be element's custom element reaction queue.
Repeat until reactions is empty:
Remove the first element of reactions, and let reaction be that element. Switch on reaction's type:
If this throws any exception, then report the exception.
[CEReactions]
IDL extended attribute is to ensure custom element reactions are triggered appropriately.
It indicates that the relevant algorithm is to be supplemented with additional steps
to appropriately track and invoke custom element reactions.
The [{{CEReactions}}] extended attribute must take no arguments,
and must not appear on anything other than an operation, attribute, setter, or deleter.
Additionally, it must not appear on {{readonly}} attributes,
unless the readonly attribute is also annotated with [PutForwards].
Operations, attributes, setters, or deleters annotated with the [{{CEReactions}}]
extended attribute must run the following steps
surrounding the main algorithm specified for the operation, setter, deleter, or for the attribute's setter:
{{HTMLElement}}'s outerText IDL attribute
{{HTMLInputElement}}'s webkitdirectory and incremental IDL attributes
{{HTMLLinkElement}}'s disabled and scope IDL attributes
{{ShadowRoot}}'s innerHTML IDL attribute
[HTMLConstructor]
IDL extended attribute indicates that the interface object for the given interface
will have a specific behavior, as defined in detail below.
The [{{HTMLConstructor}}] extended attribute must take no arguments, and must not appear on
anything other than an interface. It must appear only once on an interface, and the interface
must not be annotated with the [{{Constructor!!extended-attribute}}] or [{{NoInterfaceObject}}]
extended attributes. (However, the interface may be annotated with [{{NamedConstructor}}];
there is no conflict there.) It must not be used on a callback interface.
Interface objects for interfaces annotated with the [{{HTMLConstructor}}] extended
attribute must run the following steps as the function body behavior for both \[[Call]]
and \[[Construct]] invocations of the corresponding JavaScript function object.
When invoked with \[[Call]], newTarget is undefined, and the algorithm will throw.
When invoked with \[[Construct]], the \[[Construct]] newTarget parameter provides
the NewTarget value.
customElements.define("bad-1", HTMLButtonElement);
new HTMLButtonElement(); // (1)
document.createElement("bad-1"); // (2)
In this case, during the execution of {{HTMLButtonElement}} (either explicitly, as in (1),
or implicitly, as in (2)), both the active function object and NewTarget are
{{HTMLButtonElement}}.
If this check was not present, it would be possible to create an instance of
{{HTMLButtonElement}} whose local name was bad-1.
Since there can be no entry in registry whose constructor is undefined, this step also prevents HTML element constructors from being called as functions (since in that case NewTarget will be undefined).
customElements.define("bad-2", class Bad2 extends HTMLParagraphElement {});
In this case, during the (implicit) super() call that occurs
when constructing an instance of Bad2, the active function object
is {{HTMLParagraphElement}}, not {{HTMLElement}}.
customElements.define("bad-3", class Bad3 extends HTMLQuoteElement {}, { extends: "p" });
In this case, during the (implicit) super() call that occurs when
constructing an instance of Bad3, valid local names
is the list containing <{q}> and <{blockquote}>, but definition's
local name is <{p}>, which is not in that list.
Let prototype be definition's prototype.
If definition's construction stack is empty, then:
Let element be a new element that implements the interface to which the
active function object corresponds, with no attributes, namespace set to the
HTML namespace, local name set to definition's local name, and
node document set to the current global object's associated Document.
Perform element.[[\SetPrototypeOf]](prototype). Rethrow any exceptions.
Set element's custom element state to "custom".
Set element's custom element definition to definition.
Return element.
This occurs when author script constructs a new custom element directly,
e.g. via new MyCustomElement().
super():
let doSillyThing = false;
class DontDoThis extends HTMLElement {
constructor() {
if (doSillyThing) {
doSillyThing = false;
new DontDoThis();
// Now the construction stack will contain an already constructed marker.
}
// This will then fail with an "InvalidStateError" DOMException:
super();
}
}
super() twice, since per the JavaScript specification,
this actually executes the superclass constructor (i.e. this algorithm) twice,
before throwing an error:
This step is normally reached when upgrading a custom element;
the existing element is returned, so that the super() call inside the
custom element constructor assigns that existing element to this.
prototype property).
extends
clause when defining a custom element constructor:
For simplicity, only the most specific expectations are listed. For example,
an element that is both [=flow content=] and [=phrasing content=] can be used anywhere
that either [=flow content=] or [=phrasing content=] is expected, but since anywhere that
[=flow content=] is expected, [=phrasing content=] is also expected (since all
[=phrasing content=] is [=flow content=]), only "where [=phrasing content=] is expected"
will be listed.
: Content model
:: A normative description of what content must be included as children and descendants of the
element.
: Tag omission in text/html
:: A non-normative description of whether, in the [[#text-html|text/html]]
syntax, the [=start tag|start=] and [=end tag|end=] tags can be omitted. This information is
redundant with the normative requirements given in the [=omitted|optional tags=] section, and
is provided in the element definitions only as a convenience.
: Content attributes
:: A normative list of attributes that may be specified on the element (except where otherwise
disallowed), along with non-normative descriptions of those attributes. (The content to the
left of the dash is normative, the content to the right of the dash is not.)
: Allowed ARIA role attribute values
:: A non normative list of [[#aria-role-attribute|ARIA role attribute]] values that may be
specified on the element (except where otherwise disallowed). Each value is linked to a non
normative description.
: Allowed ARIA state and property attributes
:: Links to the [=Global aria-* attributes=] list and the
[[#allowed-aria-roles-states-and-properties|allowed roles, states and properties]] table as
described in the [[#state-and-property-attributes|state and property attributes]] section.
: DOM interface
:: A normative definition of a DOM interface that such elements must implement.
This is then followed by a description of what the element [=represents=], along with any
additional normative conformance criteria that may apply to authors
and implementations. Examples are sometimes also included.
When a <{template}> element is being parsed, its children are assigned to the [=template contents=] (a separate {{DocumentFragment}} assigned to the element when the element is created), rather than its children.
The [=space characters=] are always allowed between elements. User agents represent these characters between elements in the source markup as {{Text}} nodes in the DOM. Empty {{Text}} nodes and {{Text}} nodes consisting of just sequences of those characters are considered inter-element white space. [=Inter-element white space=], comment nodes, and processing instruction nodes must be ignored when establishing whether an element's contents match the element's content model or not, and must be ignored when following algorithms that define document and element semantics.Thus, an element |A| is said to be preceded or followed by a second element |B| if |A| and |B| have the same parent node and there are no other element nodes or {{Text}} nodes (other than [=inter-element white space=]) between them. Similarly, a node is the only child of an element if that element contains no other nodes other than [=inter-element white space=], comment nodes, and processing instruction nodes.
Authors must not use [=HTML elements=] anywhere except where they are explicitly allowed, as defined for each element, or as explicitly required by other specifications. For XML compound documents, these contexts could be inside elements from other namespaces, if those elements are defined as providing the relevant contexts.content
element. When its <{atom/type}> attribute has the value xhtml, the Atom
specification requires that it contain a single HTML <{div}> element. Thus, a <{div}> element
is allowed in that context, even though this is not explicitly normatively stated by this
specification. [[RFC4287]]
var data = {
name: "Banana",
cell: document.createElement('td'),
};
Most HTML elements whose content model is "nothing" are also, for convenience, [=void elements=] (elements that have no [=end tag=] in the [[#syntax|HTML syntax]]). However, these are entirely separate concepts.
Some elements also fall into other categories, which are defined in other parts of this specification.
These categories are related as follows: Sectioning content, heading content, phrasing content, embedded content, and interactive content are all types of flow content. Metadata is sometimes flow content. Metadata and interactive content are sometimes phrasing content. Embedded content is also a type of phrasing content, and sometimes is interactive content. Other categories are also used for specific purposes. For instance, form controls are specified using a number of categories to define common requirements. Some elements have unique requirements and do not fit into any particular category.I like playing with string, I guess. Sister says squirrels are fun too so sometimes I follow her to play with them.
There are also certain elements that are [=sectioning roots=]. These are distinct from [=sectioning content=], but they can also have an [=outline=].
Most elements that are categorized as phrasing content can only contain elements that are themselves categorized as phrasing content, not any flow content.
Text, in the context of content models, means either nothing, or {{Text}} nodes. [=Text=] is sometimes used as a content model on its own, but is also [=phrasing content=], and can be [=inter-element white space=] (if the {{Text}} nodes are empty or contain just [=space characters=]). {{Text}} nodes and attribute values must consist of [=Unicode characters=], must not contain U+0000 characters, must not contain permanently undefined Unicode characters (noncharacters), and must not contain [=control characters=] other than [=space characters=]. This specification includes extra constraints on the exact value of {{Text}} nodes and attribute values depending on their precise context. For elements in HTML, the constraints of the [=Text=] [=content model=] also depends on the [=kind of element=]. For instance, an "<" inside a <{textarea}> element does not
need to be escaped in HTML because <{textarea}> is an [=escapable raw text=] element. (This does
not apply to XHTML. In XHTML, the [=kind of element=] doesn't affect the constraints of the
[=Text=] [=content model=].)
[=Palpable content=] makes an element non-empty by providing either some descendant non-empty [=text=], or else something users can hear (<{audio}> elements) or view (<{video}> or <{img}> or <{canvas}> elements) or otherwise interact with (for example, interactive form controls).
This requirement is not a hard requirement, however, as there are many cases where an element can be empty legitimately, for example when it is used as a placeholder which will later be filled in by a script, or when the element is part of a template and would on most pages be filled in but on some pages is not relevant. Conformance checkers are encouraged to provide a mechanism for authors to find elements that fail to fulfill this requirement, as an authoring aid. The following elements are palpable content:In some cases, where transparent elements are nested in each other, the process has to be applied iteratively.
The term [=paragraph=] as defined in this section is used for more than just the definition of the <{p}> element. The [=paragraph=] concept defined here is used to describe how to interpret documents. The <{p}> element is merely one of several ways of marking up a [=paragraph=].
A paragraph is typically a run of [=phrasing content=] that forms a block of text with one or more sentences that discuss a particular topic, as in typography, but can also be used for more general thematic grouping. For instance, an address is also a paragraph, as is a byline, or a stanza in a poem.This is the second.
Generally, having elements straddle paragraph boundaries is best avoided. Maintaining such markup can be difficult.
This is the second.
The <{p}> element can be used to wrap individual paragraphs when there would otherwise not be any content other than phrasing content to separate the paragraphs from each other.
Welcome! This is home of...
The Lockheed Martin multirole jet fighter aircraft! This page discusses the F-16 Fighting Falcon's innermost secrets.
You can play with my cat simulator.
I'm quite proud of it.
bogus" element does not have a
<{global/dir}> attribute as defined in this specification, despite having an attribute with the
literal name "<{global/dir}>". Thus, [=the directionality=] of the inner-most <{span}> element
is 'rtl', inherited from the <{div}> element
indirectly through the "bogus" element.
class
attribute's value must be a [=set of space-separated tokens=]
representing the various classes that the element belongs to.
The DOM specification defines additional user agent requirements for this attribute. [[DOM]]
id
attribute value must be unique amongst all the [=IDs=] in the element's [=tree=]
and must contain at least one character. The value must not contain any [=space characters=].
The DOM specification defines additional user agent requirements for this attribute. [[DOM]]
is
attribute identifies the element as a customized built-in element. Its value must be a
valid custom element name.
Changing the value of the <{global/is}> attribute after the
[=create an element|element is created=] does not change an element's behaviour.
There are no conformance requirements for the
slot attribute specific to [=HTML elements=].
The DOM specification defines requirements for this attribute. [[DOM]]
The <{global/slot}> attribute is used for elements in shadow trees, to assign a slot for the element. The slot will be assigned to the <{slot}> element whose <{slot/name}> attribute matches the value of the <{global/slot}> attribute.
The attributes marked with an asterisk have a different meaning when specified on <{body}> elements as those elements expose [=event handlers=] of the {{Window}} object with the same names.
While these attributes apply to all elements, they are not useful on all elements. For example, only [=media elements=] will ever receive a {{media/volumechange}} event fired by the user agent.
data-foldername or data-msgid) can be
specified on any [=HTML element=], to store custom data specific to the page.
http://www.w3.org/1999/xhtml".
This does not apply to [=XML documents=].
In HTML, the <{xmlns/xmlns}> attribute has absolutely no effect. It is basically a talisman.
It is allowed merely to make migration to and from XML mildly easier. When parsed by an
[=HTML parser=], the attribute ends up in no namespace, not the
"http://www.w3.org/2000/xmlns/" namespace like namespace declaration attributes
in XML do.
In XML, an <{xmlns/xmlns}> attribute is part of the namespace declaration mechanism, and an element cannot actually have an <{xmlns/xmlns}> attribute in no namespace specified.
There is no way to serialize the <{xml/space|xml:space}> attribute on
[=HTML elements=] in the [[#text-html|text/html]] syntax.
title
attribute [=represents=] advisory information for the element, such as would be appropriate for a
tooltip. On a link, this could be the title or a description of the target resource; on an image,
it could be the image credit or a description of the image; on a paragraph, it could be a
footnote or commentary on the text; on a citation, it could be further information about the
source; on [=interactive content=], it could be a label for, or instructions for, use of the
element; and so forth. The value is text.
My logs show that there was some interest in HTTP today.
title IDL attribute must [=reflect=] the
<{global/title}> content attribute.
lang attribute (in no namespace) specifies
the primary language for the element's contents and for any of the element's attributes that
contain text. Its value must be a valid BCP 47 language tag, or the empty string. Setting the
attribute to the empty string indicates that the primary language is unknown. [[!BCP47]]
The lang attribute in the [=XML namespace=] is
defined in XML. [[!XML]]
If these attributes are omitted from an element, then the language of this element is the same as
the language of its parent element, if any.
The <{global/lang}> attribute in no namespace may be used on any [=HTML element=].
The <{global/lang}> attribute in the [=XML namespace=] may be used on [=HTML elements=] in
[=XML documents=], as well as elements in other namespaces if the relevant specifications allow it
(in particular, MathML and SVG allow <{global/lang}> attributes in the [=XML namespace=] to be
specified on their elements). If both the <{global/lang}> attribute in no namespace and the
<{global/lang}> attribute in the [=XML namespace=] are specified on the same element, they must
have exactly the same value when compared in an [=ASCII case-insensitive=] manner.
Authors must not use the <{global/lang}> attribute in the [=XML namespace=] on [=HTML elements=]
in [=HTML documents=]. To ease migration to and from XHTML, authors may specify an attribute in
no namespace with no prefix and with the literal localname "<{xml/lang|xml:lang}>" on
[=HTML elements=] in [=HTML documents=], but such attributes must only be specified if a
<{global/lang}> attribute in no namespace is also specified, and both attributes must have the
same value when compared in an [=ASCII case-insensitive=] manner.
The attribute in no namespace with no prefix and with the literal localname "<{xml/lang|xml:lang}>" has no effect on language processing.
For example, if a document is delivered over HTTP and the
Content-Language HTTP header is specified with a value
"en", then for any element in the document that does not itself have a
<{global/lang}> attribute nor any ancestor of that element, the fallback language for
the element will be English. If the value of the
Content-Language header was "de, fr, it" then the
language of the node is unknown.
This article provides
some additional guidance on the use of HTTP headers, and <{meta}> elements for providing
language information.
Thus, for instance, an element with lang="xyzzy" would be matched by the selector
:lang(xyzzy) (e.g., in CSS), but it would not be matched by
:lang(abcde), even though both are equally invalid. Similarly, if a Web browser
and screen reader working in unison communicated about the language of the element, the
browser would tell the screen reader that the language was "xyzzy", even if it knew it was
invalid, just in case the screen reader actually supported a language with that tag after all.
Even if the screen reader supported both BCP 47 and another syntax for encoding language
names, and in that other syntax the string "xyzzy" was a way to denote the Belarusian
language, it would be *incorrect* for the screen reader to then start treating text as
Belarusian, because "xyzzy" is not how Belarusian is described in BCP 47 codes
(BCP 47 uses the code "be" for Belarusian).
lang IDL attribute must [=reflect=] the
<{global/lang}> content attribute in no namespace.
translate attribute is an
[=enumerated attribute=] that is used to specify whether an element's attribute values and the
values of its {{Text}} node children are to be translated when the page is localized, or whether
to leave them unchanged.
The attribute's keywords are the empty string, yes, and no. The empty
string and the yes keyword map to the yes state. The no keyword
maps to the no state. In addition, there is a third state, the inherit state, which
is the [=missing value default=] (and the [=invalid value default=]).
Each element (even non-HTML elements) has a translation mode, which is in either the
[=translate-enabled=] state or the [=no-translate=] state. If an [=HTML element=]'s
<{global/translate}> attribute is in the yes state, then the element's
[=translation mode=] is in the [=translate-enabled=] state; otherwise, if the element's
<{global/translate}> attribute is in the no state, then the element's
[=translation mode=] is in the [=no-translate=] state. Otherwise, either the element's
<{global/translate}> attribute is in the inherit state, or the element is not an
[=HTML element=] and thus does not have a <{global/translate}> attribute; in either case,
the element's [=translation mode=] is in the same state as its parent element's, if any,
or in the [=translate-enabled=] state, if the element is a [=document element=].
When an element is in the translate-enabled state, the element's
[=translatable attributes=] and the values of its {{Text}} node children are to be translated
when the page is localized.
When an element is in the no-translate state, the element's attribute values and the
values of its {{Text}} node children are to be left as-is when the page is localized, e.g.,
because the element contains a person's name or a name of a computer program.
The following attributes are translatable attributes:
alt on <{area/alt|area}>, <{img/alt|img}>, and <{input/alt|input}> elements
* <{meta/content}> on <{meta}> elements, if the <{meta/name}> attribute specifies a metadata
name whose value is known to be translatable
* <{links/download}> on <{a}> and <{area}> elements
* label on <{optgroup/label|optgroup}>, <{option/label|option}>, and <{track/label|track}> elements
* <{global/lang}> on [=HTML elements=]; must be "translated" to match the language used in the
translation
* placeholder on <{input/placeholder|input}> and <{textarea/placeholder|textarea}>
elements
* <{iframe/srcdoc}> on <{iframe}> elements; must be parsed and recursively processed
* <{global/style}> on [=HTML elements=]; must be parsed and recursively processed
(e.g., for the values of 'content' properties)
* <{global/title}> on all [=HTML elements=]
* <{input/value}> on <{input}> elements with a <{input/type}> attribute in the <{input/Button}>
state or the <{input/Reset|Reset Button}> state
translate IDL attribute must, on getting,
return true if the element's [=translation mode=] is [=translate-enabled=], and false otherwise.
On setting, it must set the content attribute's value to "yes" if the new value is
true, and set the content attribute's value to "no" otherwise.
The Bee Game is a text adventure game in English.
When the game launches, the first thing you should do is type eat honey. The game will respond with:
Yum yum! That was some good honey!
xml:base attribute is defined in XML
Base. [[!XMLBASE]]
The <{xml/base|xml:base}> attribute may be used on [=HTML elements=] of [=XML documents=].
Authors must not use the <{xml/base|xml:base}> attribute on [=HTML elements=] in
[=HTML documents=].
dir attribute specifies the element's text
directionality. The attribute is an [=enumerated attribute=] with the following keywords and
states:
: The ltr keyword, which maps to the
ltr state
:: Indicates that the contents of the element are explicitly directionally isolated left-to-right
text.
: The rtl keyword, which maps to the
rtl state
:: Indicates that the contents of the element are explicitly directionally isolated right-to-left
text.
: The auto keyword, which maps to the
auto state
:: Indicates that the contents of the element are explicitly directionally isolated text, but
that the direction is to be determined programmatically using the contents of the element
(as described below).
The heuristic used by this state is very crude (it just looks at the first character with a strong directionality, in a manner analogous to the Paragraph Level determination in the bidirectional algorithm). Authors are urged to only use this value as a last resort when the direction of the text is truly unknown and no better server-side heuristic can be applied. [[!BIDI]]
For <{textarea}> and <{pre}> elements, the heuristic is applied on a per-paragraph level.
The attribute has no [=invalid value default=] and no [=missing value default=].ltr' or
'rtl', and is determined as per the first
appropriate set of steps from the following list:
rtl state
:: [=The directionality=] of the element is 'rtl'.
: If the element is an <{input}> element whose <{input/type}> attribute is in the
<{input/Text}>, <{input/Search}>, <{input/Telephone}>, <{input/URL}>, or <{input/E-mail}>
state, and the <{global/dir}> attribute is in the auto state
: If the element is a <{textarea}> element and the <{global/dir}> attribute is in the
auto state
:: If the element's [=attribute value|value=] contains a character of bidirectional character
type AL or R, and there is no character of bidirectional character type L anywhere before
it in the element's [=attribute value|value=], then [=the directionality=] of the element
is 'rtl'. [[!BIDI]]
Otherwise, if the element's [=attribute value|value=] is not the empty string, or if the
element is a [=document element=], [=the directionality=] of the element is
'ltr'.
Otherwise, [=the directionality=] of the element is the same as the element's parent
element's [=directionality=].
: If the element's <{global/dir}> attribute is in the auto state
: If the element is a <{bdi}> element and the <{global/dir}> attribute is not in a defined
state (i.e., it is not present or has an invalid value)
:: Find the first character in [=tree order=] that matches the following criteria:
* The character is from a {{Text}} node that is a descendant of the element whose
[=directionality=] is being determined.
* The character is of bidirectional character type L, AL, or R. [[!BIDI]]
* The character is not in a {{Text}} node that has an ancestor element that is a descendant
of the element whose [=directionality=] is being determined and that is either:
Since the <{global/dir}> attribute is only defined for [=HTML elements=], it cannot be present
on elements from other namespaces. Thus, elements from other namespaces always just inherit
their [=directionality=] from their parent element, or, if they don't have one, default to
'ltr'.
This attribute has rendering requirements involving the bidirectional algorithm.
rtl'.
Otherwise, the [=directionality of the attribute=] is
'ltr'.
: Otherwise
:: The [=directionality of the attribute=] is the same as [=the element's directionality=].
alt on <{area/alt|area}>, <{img/alt|img}>, and <{input/alt|input}> elements
* <{meta/content}> on <{meta}> elements, if the <{meta/name}> attribute specifies a metadata
name whose value is primarily intended to be human-readable rather than machine-readable
* label on <{optgroup/label|optgroup}>, <{option/label|option}>, and
<{track/label|track}> elements
* placeholder on <{input/placeholder|input}> and <{textarea/placeholder|textarea}>
elements
* <{global/title}> on all [=HTML elements=]
ltr',
'rtl', or
'auto' to replace the <{html}> element's
<{global/dir}> attribute's value.
If there is no <{html}> element, returns the empty string and ignores new values.
dir IDL attribute on an element
must [=reflect=] the <{global/dir}> content attribute of that element,
[=limited to only known values=].
The dir IDL attribute on {{Document}} objects
must [=reflect=] the <{global/dir}> content attribute of the <{html}> element, if any,
[=limited to only known values=]. If there is no such element, then the attribute must return the
empty string and do nothing on setting.
Authors are strongly encouraged to use the <{global/dir}> attribute to indicate text direction rather than using CSS, since that way their documents will continue to render correctly even in the absence of CSS (e.g., as interpreted by search engines).
Student: How do you write "What's your name?" in Arabic?
Teacher: ما اسمك؟
Student: Thanks.
Teacher: That's written "شكرًا".
Teacher: Do you know how to write "Please"?
Student: "من فضلك", right?
As noted earlier, the 'auto' value is not a
panacea. The final paragraph in this example is misinterpreted as being right-to-left text,
since it begins with an Arabic character, which causes the "right?" to be to the left of the
Arabic text.
style attributeBlocked" when executed upon the attribute's {{Element|element}}
and "style attribute", and the attribute's value, then the style rules defined in
the attribute's value must not be applied to the {{Element|element}}. [[!CSP3]]
Documents that use <{global/style}> attributes on any of their elements must still be
comprehensible and usable if those attributes were removed.
In particular, using the <{global/style}> attribute to hide and show content, or to convey meaning that is otherwise not included in the document, is non-conforming. (To hide and show content, use the <{global/hidden}> attribute.)
My suit is green. My eyes are blue.
data-", has at least
one character after the hyphen, is [=XML-compatible=], and contains no
[=uppercase ASCII letters=].
All attribute names on [=HTML elements=] in [=HTML documents=] get ASCII-lowercased automatically, so the restriction on ASCII uppercase letters doesn't affect such documents.
[=Custom data attributes=] are intended to store custom data private to the page or application, for which there are no more appropriate attributes or elements. These attributes are not intended for use by software that is not known to the administrators of the site that uses the attributes. For generic extensions that are to be used by multiple independent tools, either this specification should be extended to provide the feature explicitly, or a technology like microdata should be used (with a standardized vocabulary).
<p>
The third <span data-mytrans-de="Anspruch">claim</span> covers the case of <span translate="no">HTML</span> markup.
</p>
In this example, the "data-mytrans-de" attribute gives specific text for the
MyTrans product to use when translating the phrase "claim" to German. However, the standard
<{global/translate}> attribute is used to indicate that "HTML" is to remain unchanged in all
languages. When a standard attribute is available, there is no need for a
[=custom data attribute=] to be used.
data-doquery-range, and a library called "jJo" could use attributes names like
data-jjo-range. The jJo library could also provide an API to set which prefix to
use (e.g. J.setDataPrefix("j2"), making the attributes have names like
data-j2-range).
data-foo-bar="" becomes
element.dataset.fooBar.
dataset IDL attribute provides convenient
accessors for all the <{global/data-*}> attributes on an element. On getting, the
{{HTMLElement/dataset}} IDL attribute must return a {{DOMStringMap}} whose associated element is
this element.
The {{DOMStringMap}} interface is used for the {{HTMLElement/dataset}} attribute. Each
{{DOMStringMap}} has an associated element.
[OverrideBuiltins]
interface DOMStringMap {
getter DOMString (DOMString name);
[CEReactions] setter void (DOMString name, DOMString value);
[CEReactions] deleter void (DOMString name);
};
To
get a {{DOMStringMap}}'s name-value pairs,
run the following algorithm:
1. Let |list| be an empty list of name-value pairs.
2. For each content attribute on the {{DOMStringMap}}'s [=associated element=] whose first five
characters are the string "data-" and whose remaining characters (if any) do not
include any [=uppercase ASCII letters=], in the order that those attributes are listed in the
element's [=element attribute|attribute list=], add a name-value pair to |list| whose name is
the attribute's name with the first five characters removed and whose value is the
attribute's value.
3. For each name in |list|, for each U+002D HYPHEN-MINUS character (-) in the name that is
followed by a [=lowercase ASCII letter=], remove the U+002D HYPHEN-MINUS character (-) and
replace the character that followed it by the same character in [=ASCII uppercase=].
4. Return |list|.
The [=supported property names=] on a {{DOMStringMap}} object at any instant are the names
of each pair returned from
[=DOMStringMap/__getter__()|getting the DOMStringMap's name-value pairs=] at
that instant, in the order returned.
To [=determine the value of a named property=] |name| for a {{DOMStringMap}}, return the value
component of the name-value pair whose name component is |name| in the list returned from
[=DOMStringMap/__getter__()|getting the DOMStringMap's name-value pairs=].
To
[=set the value of a new named property=] or [=set the value of an existing named property=] for a {{DOMStringMap}},
given a property name |name| and a new value |value|, run the following steps:
1. If |name| contains a U+002D HYPHEN-MINUS character (-) followed by a
[=lowercase ASCII letter=], then throw a "{{SyntaxError}}" {{DOMException}} and abort these
steps.
2. For each [=uppercase ASCII letter=] in |name|, insert a U+002D HYPHEN-MINUS character (-)
before the character and replace the character with the same character in
[=ASCII lowercase=].
3. Insert the string data- at the front of |name|.
4. If |name| does not match the XML [=xml/Name=] production, throw an
"{{InvalidCharacterError}}" {{DOMException}} and abort these steps.
5. [=Set an attribute value=] for the {{DOMStringMap}}'s [=associated element=] using |name| and
|value|.
To
[=delete an existing named property=] |name| for a {{DOMStringMap}},
run the following steps:
1. For each [=uppercase ASCII letter=] in |name|, insert a U+002D HYPHEN-MINUS character (-)
before the character and replace the character with the same character in [=ASCII lowercase=].
2. Insert the string data- at the front of |name|.
3. [=Remove an attribute by name=] given |name|, and the {{DOMStringMap}}'s
[=associated element=].
This algorithm will only get invoked by the Web IDL specification for names that are given by the earlier algorithm for [=DOMStringMap/__getter__()|getting the DOMStringMap's name-value pairs=]. [[!WEBIDL]]
splashDamage() that takes some arguments,
the first of which is the element to process:
function splashDamage(node, x, y, damage) {
if (node.classList.contains('tower') && // checking the 'class' attribute
node.dataset.x == x && // reading the 'data-x' attribute
node.dataset.y == y) { // reading the 'data-y' attribute
var hp = parseInt(node.dataset.hp); // reading the 'data-hp' attribute
hp = hp - damage;
if (hp < 0) {
hp = 0;
node.dataset.ai = 'dead'; // setting the 'data-ai' attribute
delete node.dataset.ability; // removing the 'data-ability' attribute
}
node.dataset.hp = hp; // setting the 'data-hp' attribute
}
}
innerText attribute must
follow these steps:
1. If this element is not [=being rendered=], or if the user agent is a non-CSS user agent, then
return the same value as the {{Node/textContent}} IDL attribute on this element.
2. Compute a list of items each of which is a string or a positive integer (a
|required line break count|), by applying the following recursive procedure to each child
node |node| of this element in [=tree order=], and then concatenating the results to a
single list of items.
Intuitively, a |required line break count| item means that a certain number of line breaks appear at that point, but they can be collapsed with the line breaks induced by adjacent |required line break count| items, reminiscent to CSS margin-collapsing.
1. Let |items| be the result of recursively applying this procedure to each child of |node| in [=tree order=], and then concatenating the results to a single list of items. 2. If |node|'s [=computed value=] of 'visibility' is not "visible", then let the result of these substeps be |items| and abort these substeps. 3. If |node| has no associated CSS box, then let the result of these substeps be |items| and abort these substeps. For the purpose of this step, the following elements must act as described if the [=computed value=] of the 'display' property is not "none":Items can be non-empty due to "display: contents".
4. If |node| is a {{Text}} node, then for each CSS text box produced by |node|, in content order, compute the text of the box after application of the CSS 'white-space' processing rules and 'text-transform' rules, let the result of these substeps be a list of the resulting strings, and abort these substeps. The CSS 'white-space' processing rules are slightly modified: collapsible spaces at the end of lines are always collapsed, but they are only removed if the line is the last line of the block, or it ends with a <{br}> element. Soft hyphens should be preserved. [[CSS-TEXT-3]] 5. If |node| is a <{br}> element, then append a string containing a single U+000A LINE FEED (LF) character to |items|. 6. If |node|'s [=computed value=] of 'display' is ''display/table-cell'', and |node|'s CSS box is not the last ''table-cell'' box of its enclosing ''table-row'' box, then append a string containing a single U+0009 CHARACTER TABULATION (tab) character to |items|. 7. If |node|'s [=computed value=] of 'display' is ''display/table-cell'', and |node|'s CSS box is not the last ''table-cell'' box of the nearest ancestor ''display/table'' box, then append a string containing a single U+000A LINE FEED (LF) character to |items|. 8. If |node| is a <{p}> element, then add 2 (a |required line break count|) at the beginning and end of |items|. 9. If |node|'s [=used value=] of 'display' is block-level or ''display/table-caption'', then add 1 (a |required line break count|) at the beginning and end of |items|. [[CSS-DISPLAY-3]]Floats and absolutely-positioned elements fall into this category.
10. Let the result of these substeps be |items|. 3. Delete any string items whose strings are empty. 4. Delete any runs of consecutive |required line break count| items at the start or end of the list. 5. Replace each remaining run of consecutive |required line break count| items with a string consisting of as many U+000A LINE FEED (LF) characters as the maximum of the values in the |required line break count| items. 6. Return the concatenation of the string |items|.Note that descendant nodes of most replaced elements (e.g., <{textarea}>, <{input}>, and <{video}> — but not <{button}>) are not rendered by CSS, strictly speaking, and therefore have no CSS boxes for the purposes of this algorithm.
On setting, the {{HTMLElement/innerText}} attribute must follow these steps: 1. Let |document| be this element's [=node document=]. 2. Let |fragment| be a new {{DocumentFragment}} object whose [=node document=] is |document|. 3. Let |input| be the given value. 4. Let |pointer| be a pointer into |input|, initially pointing at the start of the string. 5. Let |text| be the empty string. 6. While |pointer| is not past the end of |input|: 1. [=Collect a sequence of characters=] that are not U+000A LINE FEED (LF) or U+000D CARRIAGE RETURN (CR) characters. Set |text| to the collected characters. 2. If |text| is not the empty string, then [=append=] a new {{Text}} node whose {{CharacterData/data}} is |text| and [=node document=] is |document| to |fragment|. 3. While |pointer| is not past the end of |input|, and the character at |position| is either a U+000A LINE FEED (LF) or U+000D CARRIAGE RETURN (CR) character: 1. If the character at |position| is a U+000D CARRIAGE RETURN (CR) character and the next character is a U+000A LINE FEED (LF) character, then advance |position| to the next character in |input|. 2. Advance |position| to the next character in |input|. 3. [=Append=] the result of [=creating an element=] given |document|, <{br}>, and the [=HTML namespace=] to |fragment|. 7. [=Replace all=] with |fragment| within this element.Authors are encouraged to use the <{global/dir}> attribute, the <{bdo}> element, and the <{bdi}> element, rather than maintaining the bidirectional-algorithm formatting characters manually. The bidirectional-algorithm formatting characters interact poorly with CSS.
The following elements and attributes have requirements defined by the [[#rendering|rendering]] section that, due to the requirements in this section, are requirements on all user agents (not just those that [=support the suggested default rendering=]):
In the majority of cases setting an ARIA <{aria/role}> and/or <{aria/aria-*}> attribute that matches the default implicit ARIA semantics is unnecessary and not recommended as these properties are already set by the browser.
The following table provides an informative reference to the ARIA roles, states and properties permitted for use in HTML. Links to ARIA roles, states and properties in the table reference the normative definitions in the [[!wai-aria-1.1]] specification.
| Role | Description | Required Properties | Supported Properties |
|---|---|---|---|
| any | [=global aria-* attributes=] can be used on any HTML element. | none |
|
alert |
A message with important, and usually time-sensitive, information. See related
alertdialog and
status.
|
none |
|
alertdialog |
A type of dialog that contains an alert message, where initial focus goes to an element
within the dialog. See related alert and
dialog.
|
none |
|
application |
A structure containing one or more focusable elements requiring user input, such as keyboard or gesture events, that do not follow a standard interaction pattern supported by a widget role. | none |
|
article |
A section of a page that consists of a composition that forms an independent part of a document, page, or site. | none |
|
banner |
A region that contains mostly site-oriented content, rather than page-specific content. | none |
|
button |
An input that allows for user-triggered actions when clicked or pressed. See related
link.
|
none |
|
checkbox |
A checkable input that has three possible values: true, false, or mixed. |
|
none |
cell |
A cell in a tabular container. | none |
|
columnheader |
A cell containing header information for a column. | none |
|
combobox |
A presentation of a select; usually similar to a textbox where users can type ahead to
select an option, or type to enter arbitrary text as a new item in the list. See related
listbox.
|
|
|
complementary |
A supporting section of the document, designed to be complementary to the main content at a similar level in the DOM hierarchy, but remains meaningful when separated from the main content. | none |
|
contentinfo |
A large perceivable region that contains information about the parent document. | none |
|
definition |
A definition of a term or concept. | none |
|
dialog |
A dialog is an application window that is designed to interrupt the current processing of
an application in order to prompt the user to enter information or require a response.
See related alertdialog.
|
none |
|
directory |
A list of references to members of a group, such as a static table of contents. | none |
|
document |
A region containing related information that is declared as document content, as opposed to a web application. | none |
|
feed |
A scrollable list of articles where scrolling may cause articles to be added to or removed from either end of the list. | none |
|
figure |
A perceivable section of content that typically contains a graphical document, images, code snippets, or example text. | none |
|
form |
A landmark region that contains a collection of items and objects that, as a whole,
combine to create a form. See related
search.
|
none |
|
grid |
A grid is an interactive control which contains cells of tabular data arranged in rows and columns, like a table. | none |
|
gridcell |
A cell in a grid or treegrid. | none |
|
group |
A set of user interface objects which are not intended to be included in a page summary or table of contents by assistive technologies. | none |
|
heading |
A heading for a section of the page. | none |
|
img |
A container for a collection of elements that form an image. | none |
|
link |
An interactive reference to an internal or external resource that, when activated, causes
the user agent to navigate to that resource. See related
button.
|
none |
|
list |
A group of non-interactive list items. See related
listbox. |
none |
|
listbox |
A widget that allows the user to select one or more items from a list of choices.
See related combobox and
list.
|
none |
|
listitem |
A single item in a list or
directory.
|
none |
|
log |
A type of live region where new information is added in meaningful order and old
information may disappear. See related
marquee.
|
none |
|
main |
The main content of a document. | none |
|
marquee |
A type of live region where non-essential information changes frequently.
See related log.
|
none |
|
MathML math |
Content that represents a mathematical expression. | none |
|
menu |
A type of widget that offers a list of choices to the user. | none |
|
menubar |
A presentation of menu that usually remains visible and is usually presented horizontally. | none |
|
menuitem |
An option in a group of choices contained by a
menu
or menubar.
|
none |
|
menuitemcheckbox |
A checkable menuitem that has three
possible values: true, false, or mixed.
|
|
|
menuitemradio |
A checkable menuitem in a group of
menuitemradio roles, only one of which
can be checked at a time.
|
|
|
navigation |
A collection of navigational elements (usually links) for navigating the document or related documents. | none |
|
none |
An element whose implicit native role semantics will not be mapped to the accessibility
API. See synonym presentation.
|
none | none |
note |
A section whose content is parenthetic or ancillary to the main content of the resource. | none |
|
option |
A selectable item in a select list. | none |
|
presentation |
An element whose implicit native role semantics will not be mapped to the accessibility API. | none | none |
progressbar |
An element that displays the progress status for tasks that take a long time. | none |
|
radio |
A checkable input in a group of radio roles, only one of which can be checked at a time. |
|
|
radiogroup |
A group of radio buttons. | none |
|
region |
A large perceivable section of a web page or document, that the author feels is important enough to be included in a page summary or table of contents, for example, an area of the page containing live sporting event statistics. | none |
|
row |
A row of cells in a grid. | none |
|
rowgroup |
A group containing one or more row elements in a grid. | none |
|
rowheader |
A cell containing header information for a row in a grid. | none |
|
scrollbar |
A graphical object that controls the scrolling of content within a viewing area, regardless of whether the content is fully displayed within the viewing area. |
|
|
search |
A landmark region that contains a collection of items and objects that, as a whole,
combine to create a search facility. See related
form.
|
none |
|
searchbox |
A type of textbox intended for specifying search criteria. | none |
|
separator |
A divider that separates and distinguishes sections of content. |
|
|
slider |
A user input where the user selects a value from within a given range. |
|
|
spinbutton |
A form of range that expects the user to select from among discrete choices. |
|
|
status |
A container whose content is advisory information for the user but is not important
enough to justify an alert, often but not necessarily presented as a status bar.
See related alert.
|
none |
|
switch |
A type of checkbox that represents on/off values, as opposed to checked/unchecked values. |
|
none |
tab |
A grouping label providing a mechanism for selecting the tab content that is to be rendered to the user. | none |
|
table |
A section containing data arranged in rows and columns. The table role is intended for tabular containers which are not interactive. | none |
|
tablist |
A list of tab elements, which are references to tabpanel elements. | none |
|
tabpanel |
A container for the resources associated with a
tab, where each
tab is contained in a
tablist.
|
none |
|
term |
A word or phrase with a corresponding definition. See related
definition.
|
none | none |
textbox |
Input that allows free-form text as its value. | none |
|
timer |
A type of live region containing a numerical counter which indicates an amount of elapsed time from a start point, or the time remaining until an end point. | none |
|
toolbar |
A collection of commonly used function buttons represented in compact visual form. | none |
|
tooltip |
A contextual popup that displays a description for an element. | none |
|
tree |
A type of list that may contain sub-level nested groups that can be collapsed and expanded. | none |
|
treegrid |
A grid whose rows can be expanded and collapsed in the same manner as for a tree. | none |
|
treeitem |
An option item of a tree. This is an element within a tree that may be expanded or collapsed if it contains a sub-level group of treeitems. | none |
|