details
elementsummary
element followed by flow content.open
interface HTMLDetailsElement : HTMLElement { attribute boolean open; };
The details
element represents a
disclosure widget from which the user can obtain additional
information or controls.
The details
element is not appropriate
for footnotes. Please see the section on
footnotes for details on how to mark up footnotes.
The first summary
element
child of the element, if any, represents the summary or
legend of the details. If there is no child
summary
element, the user agent should provide its own
legend (e.g. "Details").
The rest of the element's contents represents the additional information or controls.
The open
content attribute is a boolean attribute. If present,
it indicates that both the summary and the additional information is
to be shown to the user. If the attribute is absent, only the
summary is to be shown.
When the element is created, if the attribute is absent, the additional information should be hidden; if the attribute is present, that information should be shown. Subsequently, if the attribute is removed, then the information should be hidden; if the attribute is added, the information should be shown.
The user agent should allow the user to request that the
additional information be shown or hidden. To honor a request for
the details to be shown, the user agent must set the open
attribute on the element to
the value open
. To honor a request for the
information to be hidden, the user agent must remove the open
attribute from the
element.
The open
IDL
attribute must reflect the open
content attribute.
The following example shows the details
element
being used to hide technical details in a progress report.
<section class="progress window"> <h1>Copying "Really Achieving Your Childhood Dreams"</h1> <details> <summary>Copying... <progress max="375505392" value="97543282"></progress> 25%</summary> <dl> <dt>Transfer rate:</dt> <dd>452KB/s</dd> <dt>Local filename:</dt> <dd>/home/rpausch/raycd.m4v</dd> <dt>Remote filename:</dt> <dd>/var/www/lectures/raycd.m4v</dd> <dt>Duration:</dt> <dd>01:16:27</dd> <dt>Color profile:</dt> <dd>SD (6-1-6)</dd> <dt>Dimensions:</dt> <dd>320×240</dd> </dl> </details> </section>
The following shows how a details
element can be
used to hide some controls by default:
<details> <summary><label for=fn>Name & Extension:</label></summary> <p><input type=text id=fn name=fn value="Pillar Magazine.pdf"> <p><label><input type=checkbox name=ext checked> Hide extension</label> </details>
One could use this in conjunction with other details
in a list to allow the user to collapse a set of fields down to a
small set of headings, with the ability to open each one.
In these examples, the summary really just summarises what the controls can change, and not the actual values, which is less than ideal.
Because the open
attribute is added and removed automatically as the user interacts
with the control, it can be used in CSS to style the element
differently based on its state. Here, a stylesheet is used to
animate the color of the summary when the element is opened or
closed:
<style> details > summary { transition: color 1s; color: black; } details[open] > summary { color: red; } </style> <details> <summary>Automated Status: Operational</summary> <p>Velocity: 12m/s</p> <p>Direction: North</p> </details>
summary
elementdetails
element.HTMLElement
.The summary
element represents a
summary, caption, or legend for the rest of the contents of the
summary
element's parent details
element, if any.
command
elementtype
label
icon
disabled
checked
radiogroup
command
title
attribute has special semantics on this element.interface HTMLCommandElement : HTMLElement { attribute DOMString type; attribute DOMString label; attribute DOMString icon; attribute boolean disabled; attribute boolean checked; attribute DOMString radiogroup; readonly attribute HTMLElement? command; };
The command
element represents a command that the user
can invoke.
A command can be explicitly part of a context menu or toolbar,
using the menu
element. It can also be put anywhere
else on a page, either just to define a keyboard shortcut, or to
define a command that is then referenced from other
command
elements.
A command
element that uses the
type
,
label
,
icon
,
disabled
,
checked
,
radiogroup
,
and
title
attributes defines a new
command. A command
element that uses the command
attribute
defines a command by reference to another one. This allows authors
to define a command once, and set its state (e.g. whether it is
active or disabled) in one place, and have all references to that
command in the user interface change at the same time.
The type
attribute indicates the kind of command: either a normal command
with an associated action, or a state or option that can be toggled,
or a selection of one item from a list of items.
The attribute is an enumerated attribute with three
keywords and states. The "command
"
keyword maps to the Command state, the
"checkbox
"
keyword maps to the Checkbox state, and
the "radio
"
keyword maps to the Radio state. The
missing value default is the Command state.
The element represents a normal command with an associated action.
The element represents a state or option that can be toggled.
The element represents a selection of one item from a list of items.
The label
attribute gives the name of the command, as shown to the user. The
label
attribute must be
specified and must have a value that is not the empty string.
The title
attribute gives a hint describing the command, which might be shown
to the user to help him.
The icon
attribute gives a picture that represents the command. If the
attribute is specified, the attribute's value must contain a
valid non-empty URL potentially surrounded by
spaces. To obtain the absolute
URL of the icon when the attribute's value is not the empty
string, the attribute's value must be resolved relative to the element. When the attribute is
absent, or its value is the empty string, or resolving its value fails, there is no icon.
The disabled
attribute
is a boolean attribute that, if present, indicates that
the command is not available in the current state.
The distinction between disabled
and hidden
is subtle. A command would be
disabled if, in the same context, it could be enabled if only
certain aspects of the situation were changed. A command would be
marked as hidden if, in that situation, the command will never be
enabled. For example, in the context menu for a water faucet, the
command "open" might be disabled if the faucet is already open, but
the command "eat" would be marked hidden since the faucet could
never be eaten.
The checked
attribute is a boolean attribute that, if present,
indicates that the command is selected. The attribute must be
omitted unless the type
attribute is in either the Checkbox state or
the Radio
state.
The radiogroup
attribute gives the name of the group of commands that will be
toggled when the command itself is toggled, for commands whose type
attribute has the value "radio
". The scope of the name is the child list of
the parent element. The attribute must be omitted unless the type
attribute is in the Radio state.
If a command
element slave has a
command
attribute, and slave is in a
Document
, and there is an element in that
Document
whose ID has a
value equal to the value of slave's command
attribute, and the first
such element in tree order, hereafter master, itself defines
a command and either is not a command
element or
does not itself have a command
attribute, then the
master command of slave is master.
An element with a
command
attribute must have a master command and must not have any
type
,
label
,
icon
,
disabled
,
checked
, or
radiogroup
attributes.
The type
IDL
attribute must reflect the content attribute of the
same name, limited to only known values.
The label
, icon
, disabled
, checked
, and radiogroup
IDL attributes must reflect the respective content
attributes of the same name.
The command
IDL attribute must return the master command, if any,
or null otherwise.
If the element's Disabled State is false
(enabled) then the element's activation behavior
depends on the element's type
and command
attributes, as
follows:
command
attributeThe user agent must run synthetic click activation steps on the element's master command.
type
attribute is
in the Checkbox stateIf the element has a checked
attribute, the UA must
remove that attribute. Otherwise, the UA must add a checked
attribute, with the
literal value checked
.
type
attribute is
in the Radio stateIf the element has a parent, then the UA must walk the list
of child nodes of that parent element, and for each node that is a
command
element, if that element has a radiogroup
attribute whose
value exactly matches the current element's (treating missing radiogroup
attributes as if
they were the empty string), and has a checked
attribute, must remove
that attribute.
Then, the element's checked
attribute attribute
must be set to the literal value checked
.
The element's activation behavior is to do nothing.
Firing a synthetic click
event at the element does not cause
any of the actions described above to happen.
If the element's Disabled State is true (disabled) then the element has no activation behavior.
command
elements are not rendered
unless they form part of a menu.
Here is an example of a toolbar with three buttons that let the user toggle between left, center, and right alignment. One could imagine such a toolbar as part of a text editor. The toolbar also has a separator followed by another button labeled "Publish", though that button is disabled.
<menu type="toolbar"> <command type="radio" radiogroup="alignment" checked="checked" label="Left" icon="icons/alL.png" onclick="setAlign('left')"> <command type="radio" radiogroup="alignment" label="Center" icon="icons/alC.png" onclick="setAlign('center')"> <command type="radio" radiogroup="alignment" label="Right" icon="icons/alR.png" onclick="setAlign('right')"> <hr> <command type="command" disabled label="Publish" icon="icons/pub.png" onclick="publish()"> </menu>
menu
elementtype
attribute is in the toolbar state: Interactive content.type
attribute is in the toolbar state or the list state: Palpable content.li
elements.type
label
interface HTMLMenuElement : HTMLElement { attribute DOMString type; attribute DOMString label; };
The menu
element represents a list of commands.
The type
attribute
is an enumerated attribute indicating the kind of menu
being declared. The attribute has three states. The context
keyword maps to the
context menu state, in which
the element is declaring a context menu. The toolbar
keyword maps to the
toolbar state, in which the
element is declaring a toolbar. The attribute may also be
omitted. The missing value default is the list state, which indicates that the element is merely
a list of commands that is neither declaring a context menu nor
defining a toolbar.
If a menu
element's type
attribute is in the context menu state, then the
element represents the commands of a context menu, and
the user can only interact with the commands if that context menu is
activated.
If a menu
element's type
attribute is in the toolbar state, then the element
represents a list of active commands that the user can
immediately interact with.
If a menu
element's type
attribute is in the list state, then the element either
represents an unordered list of items (each represented
by an li
element), each of which represents a command
that the user can perform or activate, or, if the element has no
li
element children, flow content
describing available commands.
The label
attribute gives the label of the menu. It is used by user agents to
display nested menus in the UI. For example, a context menu
containing another menu would use the nested menu's label
attribute for the submenu's
menu label.
The type
and label
IDL attributes must
reflect the respective content attributes of the same
name.
This section is non-normative.
The menu
element is used to define context menus and
toolbars.
For example, the following represents a toolbar with three menu buttons on it, each of which has a dropdown menu with a series of options:
<menu type="toolbar"> <li> <menu label="File"> <button type="button" onclick="fnew()">New...</button> <button type="button" onclick="fopen()">Open...</button> <button type="button" onclick="fsave()">Save</button> <button type="button" onclick="fsaveas()">Save as...</button> </menu> </li> <li> <menu label="Edit"> <button type="button" onclick="ecopy()">Copy</button> <button type="button" onclick="ecut()">Cut</button> <button type="button" onclick="epaste()">Paste</button> </menu> </li> <li> <menu label="Help"> <li><a href="help.html">Help</a></li> <li><a href="about.html">About</a></li> </menu> </li> </menu>
In a supporting user agent, this might look like this:
In a legacy user agent, the above would look like a bulleted list with three items, the first of which has four buttons, the second of which has three, and the third of which has two nested bullet points with two items consisting of links.
The following implements a similar toolbar, with a single button whose values, when selected, redirect the user to Web sites.
<form action="redirect.cgi"> <menu type="toolbar"> <label for="goto">Go to...</label> <menu label="Go"> <select id="goto"> <option value="" selected="selected"> Select site: </option> <option value="http://www.apple.com/"> Apple </option> <option value="http://www.mozilla.org/"> Mozilla </option> <option value="http://www.opera.com/"> Opera </option> </select> <span><input type="submit" value="Go"></span> </menu> </menu> </form>
The behavior in supporting user agents is similar to the example
above, but here the legacy behavior consists of a single
select
element with a submit button. The submit button
doesn't appear in the toolbar, because it is not a child of the
menu
element or of its li
children.
A menu (or toolbar) consists of a list of zero or more of the following components:
The list corresponding to a particular menu
element
is built by iterating over its child nodes. For each child node in
tree order, the required behavior depends on what the
node is, as follows:
hr
elementoption
element that has a value
attribute set to the empty
string, and has a disabled
attribute, and whose
textContent
consists of a string of one or more
hyphens (U+002D HYPHEN-MINUS)li
elementlabel
elementmenu
element with no label
attributeselect
elementmenu
or select
element, then
append another separator.menu
element with a label
attributeoptgroup
element with a label
attributelabel
attribute as the label of the menu. The
submenu must be constructed by taking the element and creating a
new menu for it using the complete process described in this
section.Once all the nodes have been processed as described above, the user agent must the post-process the menu as follows:
The contextmenu
attribute gives the element's context
menu. The value must be the ID of a menu
element in the
DOM. If the node that would be obtained by
invoking the getElementById()
method
using the attribute's value as the only argument is null or not a
menu
element, then the element has no assigned context
menu. Otherwise, the element's assigned context menu is the element
so identified.
When an element's context menu is requested (e.g. by the user right-clicking the element, or pressing a context menu key), the user agent must apply the appropriate rules from the following list:
The user agent must fire a trusted event with the name contextmenu
, that bubbles and is cancelable, and that uses the
MouseEvent
interface, at the element for which the menu was requested. The context
information of the event must be initialized to the same values as the last
MouseEvent
user interaction event that was fired as part of the gesture that that
was interpreted as a request for the context menu.
The user agent must fire a synthetic mouse event named contextmenu
that bubbles
and is cancelable at the element for which the menu was
requested.
Typically, therefore, the firing of the contextmenu
event will be the
default action of a mouseup
or keyup
event. The exact sequence of events
is UA-dependent, as it will vary based on platform conventions.
The default action of the contextmenu
event depends on
whether the element or one of its ancestors has a context menu
assigned (using the contextmenu
attribute) or not. If
there is no context menu assigned, the default action must be for
the user agent to show its default context menu, if it has one.
If the element or one of its ancestors does have a
context menu assigned, then the user agent must fire a simple
event named show
at the
menu
element of the context menu of the nearest
ancestor (including the element itself) with one assigned.
The default action of this event is that the user agent
must show a context menu built from the menu
element.
The user agent may also provide access to its default context menu, if any, with the context menu shown. For example, it could merge the menu items from the two menus together, or provide the page's context menu as a submenu of the default menu.
If the user dismisses the menu without making a selection, nothing in particular happens.
If the user selects a menu item that represents a command, then the UA must invoke that command's Action.
Context menus must not, while being shown, reflect changes in the
DOM; they are constructed as the default action of the show
event and must remain as constructed
until dismissed.
User agents may provide means for bypassing the context menu
processing model, ensuring that the user can always access the UA's
default context menus. For example, the user agent could handle
right-clicks that have the Shift key depressed in such a way that it
does not fire the contextmenu
event and instead always shows the default context menu.
The contextMenu
IDL attribute must reflect the contextmenu
content attribute.
Here is an example of a context menu for an input control:
<form name="npc"> <label>Character name: <input name=char type=text contextmenu=namemenu required></label> <menu type=context id=namemenu> <command label="Pick random name" onclick="document.forms.npc.elements.char.value = getRandomName()"> <command label="Prefill other fields based on name" onclick="prefillFields(document.forms.npc.elements.char.value)"> </menu> </form>
This adds two items to the control's context menu, one called "Pick random name", and one called "Prefill other fields based on name". They invoke scripts that are not shown in the example above.
When a menu
element has a type
attribute in the toolbar state, then the user agent
must build the
menu for that menu
element, and use the result in the
rendering.
The user agent must reflect changes made to the
menu
's DOM, by immediately rebuilding the menu.
A command is the abstraction behind menu items, buttons, and links. Once a command is defined, other parts of the interface can refer to the same command, allowing many access points to a single feature to share facets such as the Disabled State.
Commands are defined to have the following facets:
These facets are exposed on elements using the command API:
commandType
Exposes the Type facet of the command.
id
Exposes the ID facet of the command.
commandLabel
Exposes the Label facet of the command.
title
Exposes the Hint facet of the command.
commandIcon
Exposes the Icon facet of the command.
accessKeyLabel
Exposes the Access Key facet of the command.
commandHidden
Exposes the Hidden State facet of the command.
commandDisabled
Exposes the Disabled State facet of the command.
commandChecked
Exposes the Checked State facet of the command.
click
()Triggers the Action of the command.
The commandType
attribute must return a string whose value is either "command
", "radio
", or "checkbox
", depending on whether the Type of the command defined by the
element is "command", "radio", or "checkbox" respectively. If the
element does not define a command, it must return null.
The commandLabel
attribute must return the command's Label, or null if the element
does not define a command or does not specify a Label.
The commandIcon
attribute must return the absolute URL of the command's
Icon. If the element does
not specify an icon, or if the element does not define a command,
then the attribute must return null.
The commandHidden
attribute must return true if the command's Hidden State is that the
command is hidden, and false if the command is not hidden. If the
element does not define a command, the attribute must return
null.
The commandDisabled
attribute must return true if the command's Disabled State is that
the command is disabled, and false if the command is not disabled.
This attribute is not affected by the command's Hidden State. If the
element does not define a command, the attribute must return
null.
The commandChecked
attribute must return true if the command's Checked State is that the
command is checked, and false if it is that the command is not
checked. If the element does not define a command, the attribute
must return null.
The ID facet
is exposed by the id
IDL attribute, the
Hint facet is exposed by the
title
IDL attribute, and the AccessKey facet is exposed by
the accessKeyLabel
IDL
attribute.
commands
Returns an HTMLCollection
of the elements in the
Document
that define commands and have IDs.
The commands
attribute
of the document's Document
interface must return an
HTMLCollection
rooted at the Document
node, whose filter matches only elements that define commands and have IDs.
User agents may expose the commands whose Hidden State facet is false
(visible) and whose elements are in a
Document
. For example, such commands could be
listed in the user agent's menu bar. User agents are encouraged to
do this especially for commands that have Access Keys, as a way to
advertise those keys to the user.
a
element to define a commandAn a
element with an href
attribute defines a command.
The Type of the command is "command".
The ID of the command is
the value of the id
attribute of the
element, if the attribute is present and not empty. Otherwise the
command is an anonymous command.
The Label of the command
is the string given by the element's textContent
IDL
attribute.
The Hint of the command
is the value of the title
attribute
of the element. If the attribute is not present, the Hint is the empty string.
The Icon of the command
is the absolute URL obtained from resolving the value of the src
attribute of the first
img
element descendant of the element in tree
order, relative to that element, if there is such an element
and resolving its attribute is successful. Otherwise, there is no
Icon for the command.
The AccessKey of the command is the element's assigned access key, if any.
The Hidden State
of the command is true (hidden) if the element has a hidden
attribute, and false
otherwise.
The Disabled State facet of the command is true if the element or one of its ancestors is inert, and false otherwise.
The Checked State of the command is always false. (The command is never checked.)
The Action of the
command, if the element has a defined activation
behavior, is to run synthetic click activation
steps on the element. Otherwise, it is just to fire a
click
event at the
element.
button
element to define a commandA button
element always defines a command.
The Type, ID, Label, Hint, Icon, Access Key, Hidden State, Checked State, and Action facets of the command are
determined as for a
elements (see the previous section).
The Disabled State of the command is true if the element or one of its ancestors is inert, or if the element's disabled state is set, and false otherwise.
input
element to define a commandAn input
element whose type
attribute is in one of the Submit Button, Reset Button, Image Button, Button, Radio Button, or Checkbox states defines a command.
The Type of the command
is "radio" if the type
attribute is in the Radio
Button
state, "checkbox" if the type
attribute is in the Checkbox
state, and
"command" otherwise.
The ID of the command is
the value of the id
attribute of the
element, if the attribute is present and not empty. Otherwise the
command is an anonymous command.
The Label of the command depends on the Type of the command:
If the Type is "command",
then it is the string given by the value
attribute, if any, and a
UA-dependent, locale-dependent value that the UA uses to label the
button itself if the attribute is absent.
Otherwise, the Type is
"radio" or "checkbox". If the element is a labeled
control, the textContent
of the first
label
element in tree order whose
labeled control is the element in question is the Label (in DOM terms, this is the
string given by element.labels[0].textContent
). Otherwise,
the value of the value
attribute, if present, is the Label. Otherwise, the Label is the empty string.
The Hint of the command
is the value of the title
attribute
of the input
element. If the attribute is not present, the
Hint is the empty
string.
If the element's type
attribute is in the Image
Button state, and the element has a src
attribute, and that attribute's
value can be successfully resolved relative to the element, then the Icon of the command is the
absolute URL obtained from resolving that attribute
that way. Otherwise, there is no Icon for the command.
The AccessKey of the command is the element's assigned access key, if any.
The Hidden State
of the command is true (hidden) if the element has a hidden
attribute, and false
otherwise.
The Disabled State of the command is true if the element or one of its ancestors is inert, or if the element's disabled state is set, and false otherwise.
The Checked State of the command is true if the command is of Type "radio" or "checkbox" and the element is checked attribute, and false otherwise.
The Action of the
command, if the element has a defined activation
behavior, is to run synthetic click activation
steps on the element. Otherwise, it is just to fire a
click
event at the
element.
option
element to define a commandAn option
element with an ancestor
select
element and either no value
attribute or a value
attribute that is not the
empty string defines a
command.
The Type of the command
is "radio" if the option
's nearest ancestor
select
element has no multiple
attribute, and
"checkbox" if it does.
The ID of the command is
the value of the id
attribute of the
element, if the attribute is present and not empty. Otherwise the
command is an anonymous command.
The Label of the command
is the value of the option
element's label
attribute, if there is one,
or else the value of option
element's
textContent
IDL attribute, with leading and trailing whitespace
stripped, and with any sequences of two or more space characters replaced by a single
U+0020 SPACE character.
The Hint of the command
is the string given by the element's title
attribute, if any, and the empty
string if the attribute is absent.
There is no Icon for the command.
The AccessKey of the command is the element's assigned access key, if any.
The Hidden State
of the command is true (hidden) if the element has a hidden
attribute, and false
otherwise.
The Disabled
State of the command is true if the element is disabled, or if its nearest
ancestor select
element is disabled, or if it or one of its
ancestors is inert, and false otherwise.
The Checked State of the command is true (checked) if the element's selectedness is true, and false otherwise.
The Action of the
command depends on its Type. If the command is of Type "radio" then it must pick the option
element. Otherwise, it must toggle the option
element.
command
element to define
a commandA command
element that does not have a command
attribute defines a command.
The Type of the command
is "radio" if the command
's type
attribute is
"radio
", "checkbox" if the attribute's value is
"checkbox
", and "command" otherwise.
The ID of the command is
the value of the id
attribute of the
element, if the attribute is present and not empty. Otherwise the
command is an anonymous command.
The Label of the command
is the value of the element's label
attribute, if there is one,
or the empty string if it doesn't.
The Hint of the command
is the string given by the element's title
attribute, if any, and the
empty string if the attribute is absent.
The Icon for the command
is the absolute URL obtained from resolving the value of the element's icon
attribute, relative to the
element, if it has such an attribute and resolving it is
successful. Otherwise, there is no Icon for the command.
The AccessKey of the command is the element's assigned access key, if any.
The Hidden State
of the command is true (hidden) if the element has a hidden
attribute, and false
otherwise.
The Disabled
State of the command is true if the element or one of its
ancestors is inert, or if the element has a disabled
attribute, and false
otherwise.
The Checked State
of the command is true (checked) if the element has a checked
attribute, and false
otherwise.
The Action of the
command, if the element has a defined activation
behavior, is to run synthetic click activation
steps on the element. Otherwise, it is just to fire a
click
event at the
element.
command
attribute on command
elements to define a command indirectlyA command
element with a master command
defines a command.
The Type of the command is the Type of the master command.
The ID of the command is
the value of the id
attribute of the
element, if the attribute is present and not empty. Otherwise the
command is an anonymous command.
The Label of the command is the Label of the master command.
If the element has a title
attribute, then the Hint of
the command is the value of that title
attribute. Otherwise, the Hint of the command is the Hint of the master
command.
The Icon of the command is the Icon of the master command.
The AccessKey of the command is the element's assigned access key, if any.
The Hidden State of the command is the Hidden State of the master command.
The Disabled State of the command is the Disabled State of the master command.
The Checked State of the command is the Checked State of the master command.
The Action of the command is to invoke the Action of the master command.
accesskey
attribute on a label
element to define a commandA label
element that has an assigned access
key and a labeled control and whose
labeled control defines a
command, itself defines a
command.
The Type of the command is "command".
The ID of the command is
the value of the id
attribute of the
element, if the attribute is present and not empty. Otherwise the
command is an anonymous command.
The Label of the command
is the string given by the element's textContent
IDL
attribute.
The Hint of the command
is the value of the title
attribute
of the element.
There is no Icon for the command.
The AccessKey of the command is the element's assigned access key.
The Hidden State, Disabled State, and Action facets of the command are the same as the respective facets of the element's labeled control.
The Checked State of the command is always false. (The command is never checked.)
accesskey
attribute on a legend
element to define a commandA legend
element that has an assigned access
key and is a child of a fieldset
element that
has a descendant that is not a descendant of the legend
element and is neither a label
element nor a
legend
element but that defines a command, itself defines a command.
The Type of the command is "command".
The ID of the command is
the value of the id
attribute of the
element, if the attribute is present and not empty. Otherwise the
command is an anonymous command.
The Label of the command
is the string given by the element's textContent
IDL
attribute.
The Hint of the command
is the value of the title
attribute
of the element.
There is no Icon for the command.
The AccessKey of the command is the element's assigned access key.
The Hidden State,
Disabled State, and
Action facets of the
command are the same as the respective facets of the first element
in tree order that is a descendant of the parent of the
legend
element that defines a command but is not a
descendant of the legend
element and is neither a
label
nor a legend
element.
The Checked State of the command is always false. (The command is never checked.)
accesskey
attribute to define a command on other elementsAn element that has an assigned access key defines a command.
If one of the earlier sections that define elements that define commands define that this element defines a command, then that section applies to this element, and this section does not. Otherwise, this section applies to that element.
The Type of the command is "command".
The ID of the command is
the value of the id
attribute of the
element, if the attribute is present and not empty. Otherwise the
command is an anonymous command.
The Label of the command
depends on the element. If the element is a labeled
control, the textContent
of the first
label
element in tree order whose
labeled control is the element in question is the Label (in DOM terms, this is the
string given by element.labels[0].textContent
). Otherwise, the
Label is the
textContent
of the element itself.
The Hint of the command
is the value of the title
attribute
of the element. If the attribute is not present, the Hint is the empty string.
There is no Icon for the command.
The AccessKey of the command is the element's assigned access key.
The Hidden State
of the command is true (hidden) if the element has a hidden
attribute, and false
otherwise.
The Disabled State of the command is true if the element or one of its ancestors is inert, and false otherwise.
The Checked State of the command is always false. (The command is never checked.)
The Action of the command is to run the following steps:
click
event at the element.dialog
elementdt
element.th
element.open
interface HTMLDialogElement : HTMLElement { attribute boolean open; attribute DOMString returnValue; void show(optional (MouseEvent or Element) anchor); void showModal(optional (MouseEvent or Element) anchor); void close(optional DOMString returnValue); };
The dialog
element represents a part of an
application that a user interacts with to perform a task, for
example a dialog box, inspector, or window.
The open
attribute is a boolean attribute. When specified, it
indicates that the dialog
element is active and that
the user can interact with it.
A dialog
element without an open
attribute specified should not
be shown to the user. This requirement may be implemented indirectly
through the style layer. For example, user agents that support the suggested default rendering
implement this requirement using the CSS rules described in the rendering section.
show
( [ anchor ] )Displays the dialog
element.
The argument, if provided, provides an anchor point to which the element will be fixed.
showModal
( [ anchor ] )Displays the dialog
element and makes it the top-most modal dialog.
The argument, if provided, provides an anchor point to which the element will be fixed.
This method honors the autofocus
attribute.
close
( [ result ] )Closes the dialog
element.
The argument, if provided, provides a return value.
returnValue
[ = result ]Returns the dialog
's return value.
Can be set, to update the return value.
When the show()
method is invoked, the user agent must run the following steps:
If the element already has an open
attribute, then abort these
steps.
Add an open
attribute
to the dialog
element, whose value is the empty
string.
If the show()
method
was invoked with an argument, set up the position of
the dialog
element, using that argument as the anchor.
Otherwise, set up the default static position of the
dialog element.
Each Document
has a stack of dialog
elements known as the pending dialog stack. When a
Document
is created, this stack must be initialized to
be empty.
When an element is added to the pending dialog stack, it must also be added to the top layer layer. When an element is removed from the pending dialog stack, it must be removed from the top layer. [FULLSCREEN]
When the showModal()
method
is invoked, the user agent must run the following steps:
Let dialog be the dialog
element on which the method was invoked.
If dialog already has an open
attribute, then throw an
InvalidStateError exception and abort these
steps.
If dialog is not in a
Document
, then throw an
InvalidStateError exception and abort these
steps.
Add an open
attribute
to dialog, whose value is the empty
string.
If the showModal()
method was invoked with an argument, set up the
position of dialog, using that argument
as the anchor. Otherwise, set up the default static
position of the dialog element.
Let dialog's Document
be
blocked by the modal
dialog dialog.
Push dialog onto dialog's Document
's pending
dialog stack.
Let control be the first element in tree
order whose nearest ancestor dialog
element is dialog and that has an autofocus
attribute
specified, if any.
If there is no control, then abort these steps.
Run the focusing steps for control.
If at any time a dialog
element is removed from a
Document
, then if that dialog
is in
that Document
's pending dialog stack, the
following steps must be run:
Let dialog be that dialog
element and document be the
Document
from which it is being removed.
Remove dialog from document's pending dialog stack.
If document's pending dialog stack is not empty, then let document be blocked by the modal dialog that is at the top of document's pending dialog stack. Otherwise, let document be no longer blocked by a modal dialog at all.
When the close()
method is invoked, the user agent must close the dialog
that the method was invoked on. If the method was invoked with an
argument, that argument must be used as the return value; otherwise,
there is no return value.
When a dialog
element dialog is
to be closed, optionally with a
return value result, the user agent must run the
following steps:
If dialog does not have an open
attribute, then throw an
InvalidStateError exception and abort these
steps.
Remove dialog's open
attribute.
If the argument was passed a result,
then set the returnValue
attribute to the
value of result.
If dialog is in its Document
's
pending dialog stack, then run these substeps:
Remove dialog from that pending dialog stack.
If that pending dialog stack is not empty,
then let dialog's Document
be
blocked by the modal
dialog that is at the top of the pending dialog
stack. Otherwise, let document be no
longer blocked by a modal dialog at all.
Queue a task to fire a simple
event named close
at dialog.
The returnValue
IDL
attribute, on getting, must return the last value to which it was
set. On setting, it must be set to the new value. When the element
is created, it must be set to the empty string.
Canceling dialogs: When a
Document
's pending dialog stack is not
empty, user agents may provide a user interface that, upon
activation, queues a task to
fire a simple event named cancel
that is cancelable at
the top dialog
element on the Document
's
pending dialog stack. The default action of this event
must be to close the dialog with no return value.
An example of such a UI mechanism would be the user pressing the "Escape" key.
When a user agent is to set up the default static position of an element dialog without an anchor, it must set up the element such that its top static position, for the purposes of calculating the used value of the 'top' property, is the value that would place the element's top margin edge as far from the top of the viewport as the element's bottom margin edge from the bottom of the viewport, if the element's height is less than the height of the viewport, and otherwise is the value that would place the element's top margin edge at the top of the viewport.
This top static position must remain the element's top static position until it is next changed by the above algorithm or the next one. (The element's static position is only used in calculating the used value of the 'top' property in certain situations; it's not used, for instance, to position the element if its 'position' property is set to 'static'.)
When a user agent is to set up the position of an element dialog using an anchor anchor, it must run the following steps:
If anchor is a MouseEvent
object, then run these substeps:
If anchor's target element does not have a rendered box, or is in a different document than dialog, then abort the set up the position steps.
Let anchor element be an anonymous element rendered as a box with zero height and width (so its margin and border boxes both just form a point), positioned so that its top and left are at the coordinate identified by the event, and whose properties all compute to their initial values.
Otherwise, let anchor element be anchor.
Let dialog be magically aligned to anchor element.
While an element A is magically aligned to an element B, A and B both have rendered boxes, and B is not a descendant of A, the following requirements apply:
A's 'position' property must compute to the keyword 'absolute-anchored'.
Let A and B's anchor points be defined as per the appropriate entry in the following list:
The anchor points of A and B are the center points of their respective first boxes' border boxes.
The anchor point of B is the point given by its 'anchor-point' property.
If the anchor point of B is the center point of B's first box's border box, then A's anchor point is the center point of its first box's margin box.
Otherwise, A's anchor point is on one of its margin edges. Consider four hypothetical half-infinite lines L1, L2, L3, and L4 that each start in the center of B's first box's border box, and that extend respectively through the top left corner, top right corner, bottom right corner, and bottom left corner of B's first box's border box. A's anchor point is determined by the location of B's anchor point relative to these four hypothetical lines, as follows:
If the anchor point of B lies on L1 or L2, or inside the area bounded by L1 and L2 that also contains the points above B's first box's border box, then let A's anchor point be the horizontal center of A's bottom margin edge.
Otherwise, if the anchor point of B lies on L3 or L4, or inside the area bounded by L4 and L4 that also contains the points below B's first box's border box, then let A's anchor point be the horizontal center of A's top margin edge.
Otherwise, if the anchor point of B lies inside the area bounded by L4 and L1 that also contains the points to the left of B's first box's border box, then let A's anchor point be the vertical center of A's right margin edge.
Otherwise, the anchor point of B lies inside the area bounded by L2 and L3 that also contains the points to the right of B's first box's border box; let A's anchor point be the vertical center of A's left margin edge.
The anchor point of A is the point given by its 'anchor-point' property.
If the anchor point of A is the center point of A's first box's margin box, then B's anchor point is the center point of its first box's border box.
Otherwise, B's anchor point is on one of its border edges. Consider four hypothetical half-infinite lines L1, L2, L3, and L4 that each start in the center of A's first box's margin box, and that extend respectively through the top left corner, top right corner, bottom right corner, and bottom left corner of A's first box's margin box. B's anchor point is determined by the location of A's anchor point relative to these four hypothetical lines, as follows:
If the anchor point of A lies on L1 or L2, or inside the area bounded by L1 and L2 that also contains the points above A's first box's margin box, then let B's anchor point be the horizontal center of B's bottom border edge.
Otherwise, if the anchor point of A lies on L3 or L4, or inside the area bounded by L4 and L4 that also contains the points below A's first box's margin box, then let B's anchor point be the horizontal center of B's top border edge.
Otherwise, if the anchor point of A lies inside the area bounded by L4 and L1 that also contains the points to the left of A's first box's margin box, then let B's anchor point be the vertical center of B's right border edge.
Otherwise, the anchor point of A lies inside the area bounded by L2 and L3 that also contains the points to the right of A's first box's margin box; let B's anchor point be the vertical center of B's left border edge.
The anchor points of A and B are the points given by their respective 'anchor-point' properties.
The rules above generally use A's margin box, but B's border box. This is because while A always has a margin box, and using the margin box allows for the dialog to be positioned offset from the box it is annotating, B sometimes does not have a margin box (e.g. if it is a table-cell), or has a margin box whose position may be not entirely clear (e.g. in the face of margin collapsing and 'clear' handling of in-flow blocks).
In cases where B does not have a border box but its border box is used by the algorithm above, user agents must use its first box's content area instead. (This is in particular an issue with boxes in tables that have 'border-collapse' set to 'collapse'.)
The trivial example of an element that does not have a rendered box is one whose 'display' property computes to 'none'. However, there are many other cases; e.g. table columns do not have boxes (their properties merely affect other boxes).
When an element's 'position' property must compute to 'absolute-anchored', the 'float', property does not apply and must compute to 'none', the 'display' property must compute to a value as described by the table in the section of CSS 2.1 describing the relationships between 'display', 'position', and 'float', and the element's box must be positioned using the rules for absolute positioning but with its static position set such that if the box is positioned in its static position, its anchor point is exactly aligned over the anchor point of the element to which it is magically aligned.
The 'absolute-anchored' keyword is not a keyword
that can be specified in CSS; the 'position' property can only
compute to this value if the dialog
element is
positioned via the APIs described above.
The open
IDL
attribute must reflect the open
content attribute.
This section will eventually be moved to a CSS specification; it is specified here only on an interim basis until an editor can be found to own this.
Value: | none | <position> |
---|---|
Initial: | none |
Applies to: | all elements |
Inherited: | no |
Percentages: | refer to width or height of box; see prose |
Media: | visual |
Computed value: | The specified value, but with any lengths replaced by their corresponding absolute length |
Animatable: | no |
Canonical order: | per grammar |
The 'anchor-point' property specifies a point to which dialog boxes are to be aligned.
If the value is a <position>, the alignment point is the point given by the value, which must be interpreted relative to the element's first rendered box's margin box. Percentages must be calculated relative to the element's first rendered box's margin box (specifically, its width for the horizontal position and its height for the vertical position). [CSSVALUES] [CSS]
If the value is the keyword 'none', then no explicit alignment
point is defined. The user agent will pick an alignment point
automatically if necessary (as described in the definition of the
open()
method above).