Living
Standard
—
Last
Updated
29
September
1
October
2025
hidden
attribute
contenteditable
content
attribute
designMode
getter
and
setter
inputmode
attribute
enterkeyhint
attribute
Support in one engine only.
Support in all current engines.
All
may
have
the
hidden
content
attribute
set.
The
attribute
is
an
with
the
following
keywords
and
states:
| Keyword | State | Brief description |
|---|---|---|
hidden
| Hidden | Will not be rendered. |
until-found
| Hidden Until Found | Will not be rendered, but content inside will be accessible to and . |
The attribute's missing value default is the Not Hidden state, and its invalid value default and empty value default are both the state.
When an element has the attribute in the state, it indicates that the element is not yet, or is no longer, directly relevant to the page's current state, or that it is being used to declare content to be reused by other parts of the page as opposed to being directly accessed by the user. User agents should not render elements that are in the state.
The requirement for user agents not to render elements that are in the state can be implemented indirectly through the style layer. For example, a web browser could implement these requirements using the rules suggested in the Rendering section .
When an element has the attribute in the state, it indicates that the element is hidden like the state but the content inside the element will be accessible to and . When these features attempt to scroll to a target which is in the element's subtree, the user agent will remove the attribute in order to reveal the content before scrolling to it by running the on the target node.
Web browsers will use 'content-visibility: hidden' instead of 'display: none' when the attribute is in the state, as specified in the Rendering section .
Because this attribute is typically implemented using CSS, it's also possible to override it using CSS. For instance, a rule that applies 'display: block' to all elements will cancel the effects of the state. Authors therefore have to take care when writing their style sheets to make sure that the attribute is still styled as expected. In addition, legacy user agents which don't support the state will have 'display: none' instead of 'content-visibility: hidden', so authors are encouraged to make sure that their style sheets don't change the 'display' or 'content-visibility' properties of elements.
Since elements with the attribute in the state use 'content-visibility: hidden' instead of 'display: none', there are two caveats of the state that make it different from the state:
The element needs to be affected by in order to be revealed by find-in-page. This means that if the element in the state has a 'display' value of 'none', 'contents', or 'inline', then the element will not be revealed by find-in-page.
The element will still have a when in the state, which means that borders, margin, and padding will still be rendered around the element.
In the following skeletal example, the attribute is used to hide the web game's main screen until the user logs in:
<h1>The Example Game</h1>
<section id="login">
<h2>Login</h2>
<form>
...
<!-- calls login() once the user's credentials have been checked -->
</form>
<script>
function login() {
// switch screens
document.getElementById('login').hidden = true;
document.getElementById('game').hidden = false;
}
</script>
</section>
<section id="game" hidden>
...
</section>
The attribute must not be used to hide content that could legitimately be shown in another presentation. For example, it is incorrect to use to hide panels in a tabbed dialog, because the tabbed interface is merely a kind of overflow presentation — one could equally well just show all the form controls in one big page with a scrollbar. It is similarly incorrect to use this attribute to hide content just from one presentation — if something is marked , it is hidden from all presentations, including, for instance, screen readers.
Elements
that
are
not
themselves
must
not
to
elements
that
are
.
The
for
attributes
of
and
elements
that
are
not
themselves
must
similarly
not
refer
to
elements
that
are
.
In
both
cases,
such
references
would
cause
user
confusion.
Elements and scripts may, however, refer to elements that are in other contexts.
For example, it would be incorrect to use the attribute to link to a section marked with the attribute. If the content is not applicable or relevant, then there is no reason to link to it.
It would be fine, however, to use the ARIA attribute to refer to descriptions that are themselves . While hiding the descriptions implies that they are not useful alone, they could be written in such a way that they are useful in the specific context of being referenced from the elements that they describe.
Similarly, a element with the attribute could be used by a scripted graphics engine as an off-screen buffer, and a form control could refer to a hidden element using its attribute.
Elements in a section hidden by the attribute are still active, e.g. scripts and form controls in such sections still execute and submit respectively. Only their presentation to the user changes.
Support in all current engines.
The
hidden
getter
steps
are:
If the attribute is in the state, then return " ".
If the attribute is set, then return true.
Return false.
The setter steps are:
If the given value is a string that is an match for " ", then set the attribute to " ".
Otherwise, if the given value is false, then remove the attribute.
Otherwise, if the given value is the empty string, then remove the attribute.
Otherwise, if the given value is null, then remove the attribute.
Otherwise, if the given value is 0, then remove the attribute.
Otherwise, if the given value is NaN, then remove the attribute.
Otherwise, set the attribute to the empty string.
An ancestor reveal pair is a consisting of a node and a string .
The ancestor revealing algorithm given a node target is:
Let ancestorsToReveal be « ».
Let ancestor be target .
While ancestor has a parent node within the :
If
ancestor
has
a
attribute
in
the
state,
then
(
ancestor
,
"
until-found
")
to
ancestorsToReveal
.
If
ancestor
is
slotted
into
the
second
slot
of
a
element
which
does
not
have
an
attribute,
then
(
ancestor
's
parent
node,
"
details
")
to
ancestorsToReveal
.
Set ancestor to the parent node of ancestor within the .
For each ( ancestorToReveal , revealType ) of ancestorsToReveal :
If ancestorToReveal is not , then return.
If
revealType
is
"
until-found
":
If ancestorToReveal 's attribute is not in the state, then return.
named at ancestorToReveal with the attribute initialized to true.
If ancestorToReveal is not , then return.
If ancestorToReveal 's attribute is not in the state, then return.
Remove the attribute from ancestorToReveal .
Otherwise:
:
revealType
is
"
details
".
If ancestorToReveal has an attribute, then return.
Set ancestorToReveal 's attribute to the empty string.
A traversable navigable 's system visibility state , including its initial value upon creation, is determined by the user agent. It represents, for example, whether the browser window is minimized, a browser tab is currently in the background, or a system element such as a task switcher obscures the page.
When a user agent determines that the system visibility state for traversable navigable traversable has changed to newState , it must run the following steps:
Let navigables be the inclusive descendant navigables of traversable 's active document .
For each navigable of navigables in what order? :
Let document be navigable 's active document .
Queue a global task on the user interaction task source given document 's relevant global object to update the visibility state of document with newState .
A
Document
has
a
visibility
state
,
which
is
either
"
hidden
"
or
"
visible
",
initially
set
to
"
hidden
".
Support in all current engines.
The
visibilityState
getter
steps
are
to
return
this
's
visibility
state
.
Support in all current engines.
The
hidden
getter
steps
are
to
return
true
if
this
's
visibility
state
is
"
hidden
",
otherwise
false.
To
update
the
visibility
state
of
Document
document
to
visibilityState
:
If document 's visibility state equals visibilityState , then return.
Set document 's visibility state to visibilityState .
Queue
a
new
VisibilityStateEntry
whose
visibility
state
is
visibilityState
and
whose
timestamp
is
the
current
high
resolution
time
given
document
's
relevant
global
object
.
Run the screen orientation change steps with document . [SCREENORIENTATION]
Run the view transition page visibility change steps with document .
Run any page visibility change steps which may be defined in other specifications, with visibility state and document .
It would be better if specification authors sent a pull request to add calls from here into their specifications directly, instead of using the page visibility change steps hook, to ensure well-defined cross-specification call order. As of the time of this writing the following specifications are known to have page visibility change steps , which will be run in an unspecified order: Device Posture API and Web NFC . [DEVICEPOSTURE] [WEBNFC]
Fire
an
event
named
visibilitychange
at
document
,
with
its
bubbles
attribute
initialized
to
true.
VisibilityStateEntry
interface
Support in one engine only.
The
VisibilityStateEntry
interface
exposes
visibility
changes
to
the
document,
from
the
moment
the
document
becomes
active.
function wasHiddenBeforeFirstContentfulPaint() {
const fcpEntry = performance.getEntriesByName("first-contentful-paint")[0];
const visibilityStateEntries = performance.getEntriesByType("visibility-state");
return visibilityStateEntries.some(e =>
e.startTime < fcpEntry.startTime &&
e.name === "hidden");
}
Since hiding a page can cause throttling of rendering and other user-agent operations, it is common to use visibility changes as an indication that such throttling has occurred. However, other things could also cause throttling in different browsers, such as long periods of inactivity.
[Exposed=(Window)]
interface VisibilityStateEntry : PerformanceEntry {
readonly attribute DOMString name; // shadows inherited name
readonly attribute DOMString entryType; // shadows inherited entryType
readonly attribute DOMHighResTimeStamp startTime; // shadows inherited startTime
readonly attribute unsigned long duration; // shadows inherited duration
};
The
VisibilityStateEntry
has
an
associated
DOMHighResTimeStamp
timestamp
.
The
VisibilityStateEntry
has
an
associated
"
visible
"
or
"
hidden
"
visibility
state
.
The
name
getter
steps
are
to
return
this
's
visibility
state
.
The
entryType
getter
steps
are
to
return
"
visibility-state
".
The
duration
getter
steps
are
to
return
zero.
See
also
inert
for
an
explanation
of
the
attribute
of
the
same
name.
A node (in particular elements and text nodes) can be inert . When a node is inert :
Hit-testing must act as if the 'pointer-events' CSS property were set to 'none'.
Text selection functionality must act as if the 'user-select' CSS property were set to 'none'.
If it is editable , the node behaves as if it were non-editable.
The user agent should ignore the node for the purposes of find-in-page .
Inert nodes generally cannot be focused, and user agents do not expose the inert nodes to accessibility APIs or assistive technologies. Inert nodes that are commands will become inoperable to users, in the manner described above.
User agents may allow the user to override the restrictions on find-in-page and text selection, however.
By default, a node is not inert .
A
Document
document
is
blocked
by
a
modal
dialog
subject
if
subject
is
the
topmost
dialog
element
in
document
's
top
layer
.
While
document
is
so
blocked,
every
node
that
is
connected
to
document
,
with
the
exception
of
the
subject
element
and
its
flat
tree
descendants,
must
become
inert
.
subject
can
additionally
become
inert
via
the
inert
attribute,
but
only
if
specified
on
subject
itself
(i.e.,
subject
escapes
inertness
of
ancestors);
subject
's
flat
tree
descendants
can
become
inert
in
a
similar
fashion.
The
dialog
element's
showModal()
method
causes
this
mechanism
to
trigger,
by
adding
the
dialog
element
to
its
node
document
's
top
layer
.
inert
attribute
Support in all current engines.
The
inert
attribute
is
a
boolean
attribute
that
indicates,
by
its
presence,
that
the
element
and
all
its
flat
tree
descendants
which
don't
otherwise
escape
inertness
(such
as
modal
dialogs)
are
to
be
made
inert
by
the
user
agent.
An
inert
subtree
should
not
contain
any
content
or
controls
which
are
critical
to
understanding
or
using
aspects
of
the
page
which
are
not
in
the
inert
state.
Content
in
an
inert
subtree
will
not
be
perceivable
by
all
users,
or
interactive.
Authors
should
not
specify
elements
as
inert
unless
the
content
they
represent
are
also
visually
obscured
in
some
way.
In
most
cases,
authors
should
not
specify
the
inert
attribute
on
individual
form
controls.
In
these
instances,
the
disabled
attribute
is
probably
more
appropriate.
The following example shows how to mark partially loaded content, visually obscured by a "loading" message, as inert.
<section aria-labelledby=s1>
<h3 id=s1>Population by City</h3>
<div class=container>
<div class=loading><p>Loading...</p></div>
<div inert>
<form>
<fieldset>
<legend>Date range</legend>
<div>
<label for=start>Start</label>
<input type=date id=start>
</div>
<div>
<label for=end>End</label>
<input type=date id=end>
</div>
<div>
<button>Apply</button>
</div>
</fieldset>
</form>
<table>
<caption>From 20-- to 20--</caption>
<thead>
<tr>
<th>City</th>
<th>State</th>
<th>20-- Population</th>
<th>20-- Population</th>
<th>Percentage change</th>
</tr>
</thead>
<tbody>
<!-- ... -->
</tbody>
</table>
</div>
</div>
</section>
The
"loading"
overlay
obscures
the
inert
content,
making
it
visually
apparent
that
the
inert
content
is
not
presently
accessible.
Notice
that
the
heading
and
"loading"
text
are
not
descendants
of
the
element
with
the
inert
attribute.
This
will
ensure
this
text
is
accessible
to
all
users,
while
the
inert
content
cannot
be
interacted
with
by
anyone.
By
default,
there
is
no
persistent
visual
indication
of
an
element
or
its
subtree
being
inert.
Appropriate
visual
styles
for
such
content
is
often
context-dependent.
For
instance,
an
inert
off-screen
navigation
panel
would
not
require
a
default
style,
as
its
off-screen
position
visually
obscures
the
content.
Similarly,
a
modal
dialog
element's
backdrop
will
serve
as
the
means
to
visually
obscure
the
inert
content
of
the
web
page,
rather
than
styling
the
inert
content
specifically.
However, for many other situations authors are strongly encouraged to clearly mark what parts of their document are active and which are inert, to avoid user confusion. In particular, it is worth remembering that not all users can see all parts of a page at once; for example, users of screen readers, users on small devices or with magnifiers, and even users using particularly small windows might not be able to see the active part of a page and might get frustrated if inert sections are not obviously inert.
To prevent abuse of certain APIs that could be annoying to users (e.g., opening popups or vibrating phones), user agents allow these APIs only when the user is actively interacting with the web page or has interacted with the page at least once. This "active interaction" state is maintained through the mechanisms defined in this section.
For
the
purpose
of
tracking
user
activation,
each
Window
W
has
two
relevant
values:
A
last
activation
timestamp
,
which
is
either
a
DOMHighResTimeStamp
,
positive
infinity
(indicating
that
W
has
never
been
activated),
or
negative
infinity
(indicating
that
the
activation
has
been
consumed
).
Initially
positive
infinity.
A
last
history-action
activation
timestamp
,
which
is
either
a
DOMHighResTimeStamp
or
positive
infinity,
initially
positive
infinity.
A user agent also defines a transient activation duration , which is a constant number indicating how long a user activation is available for certain user activation-gated APIs (e.g., for opening popups).
The transient activation duration is expected be at most a few seconds, so that the user can possibly perceive the link between an interaction with the page and the page calling the activation-gated API.
We then have the following boolean user activation states for W :
When the current high resolution time given W is greater than or equal to the last activation timestamp in W , W is said to have sticky activation .
This is W 's historical activation state, indicating whether the user has ever interacted in W . It starts false, then changes to true (and never changes back to false) when W gets the very first activation notification .
When the current high resolution time given W is greater than or equal to the last activation timestamp in W , and less than the last activation timestamp in W plus the transient activation duration , then W is said to have transient activation .
This is W 's current activation state, indicating whether the user has interacted in W recently. This starts with a false value, and remains true for a limited time after every activation notification W gets.
The transient activation state is considered expired if it becomes false because the transient activation duration time has elapsed since the last user activation. Note that it can become false even before the expiry time through an activation consumption .
When the last history-action activation timestamp of W is not equal to the last activation timestamp of W , then W is said to have history-action activation .
This is a special variant of user activation, used to allow access to certain session history APIs which, if used too frequently, would make it harder for the user to traverse back using browser UI . It starts with a false value, and becomes true whenever the user interacts with W , but is reset to false through history-action activation consumption . This ensures such APIs cannot be used multiple times in a row without an intervening user activation. But unlike transient activation , there is no time limit within which such APIs must be used.
The
last
activation
timestamp
and
last
history-action
activation
timestamp
are
retained
even
after
the
Document
changes
its
fully
active
status
(e.g.,
after
navigating
away
from
a
Document
,
or
navigating
to
a
cached
Document
).
This
means
sticky
activation
state
spans
multiple
navigations
as
long
as
the
same
Document
gets
reused.
For
the
transient
activation
state,
the
original
expiry
time
remains
unchanged
(i.e.,
the
state
still
expires
within
the
transient
activation
duration
limit
from
the
original
activation
triggering
input
event
).
It
is
important
to
consider
this
when
deciding
whether
to
base
certain
things
off
sticky
activation
or
transient
activation
.
When
a
user
interaction
causes
firing
of
an
activation
triggering
input
event
in
a
Document
document
,
the
user
agent
must
perform
the
following
activation
notification
steps
before
dispatching
the
event:
Assert : document is fully active .
Let windows be « document 's relevant global object ».
Extend windows with the active window of each of document 's ancestor navigables .
Extend windows with the active window of each of document 's descendant navigables , filtered to include only those navigables whose active document 's origin is same origin with document 's origin .
For each window in windows :
Set window 's last activation timestamp to the current high resolution time .
Notify the close watcher manager about user activation given window .
An
activation
triggering
input
event
is
any
event
whose
isTrusted
attribute
is
true
and
whose
type
is
one
of:
"
keydown
",
provided
the
key
is
neither
the
Esc
key
nor
a
shortcut
key
reserved
by
the
user
agent;
"
mousedown
";
"
pointerdown
",
provided
the
event's
pointerType
is
"
mouse
";
"
pointerup
",
provided
the
event's
pointerType
is
not
"
mouse
";
or
"
touchend
".
Activation
consuming
APIs
defined
in
this
and
other
specifications
can
consume
user
activation
by
performing
the
following
steps,
given
a
Window
W
:
If W 's navigable is null, then return.
Let top be W 's navigable 's top-level traversable .
Let navigables be the inclusive descendant navigables of top 's active document .
Let
windows
be
the
list
of
Window
objects
constructed
by
taking
the
active
window
of
each
item
in
navigables
.
For each window in windows , if window 's last activation timestamp is not positive infinity, then set window 's last activation timestamp to negative infinity.
History-action
activation-consuming
APIs
can
consume
history-action
user
activation
by
performing
the
following
steps,
given
a
Window
W
:
If W 's navigable is null, then return.
Let top be W 's navigable 's top-level traversable .
Let navigables be the inclusive descendant navigables of top 's active document .
Let
windows
be
the
list
of
Window
objects
constructed
by
taking
the
active
window
of
each
item
in
navigables
.
For each window in windows , set window 's last history-action activation timestamp to window 's last activation timestamp .
Note
the
asymmetry
in
the
sets
of
browsing
contexts
in
the
page
that
are
affected
by
an
activation
notification
vs
an
activation
consumption
:
an
activation
consumption
changes
(to
false)
the
transient
activation
states
for
all
browsing
contexts
in
the
page,
but
an
activation
notification
changes
(to
true)
the
states
for
a
subset
of
those
browsing
contexts.
The
exhaustive
nature
of
consumption
here
is
deliberate:
it
prevents
malicious
sites
from
making
multiple
calls
to
an
activation
consuming
API
from
a
single
user
activation
(possibly
by
exploiting
a
deep
hierarchy
of
iframe
s).
APIs that are dependent on user activation are classified into different levels:
These APIs require the sticky activation state to be true, so they are blocked until the very first user activation.
These APIs require the transient activation state to be true, but they don't consume it, so multiple calls are allowed per user activation until the transient state expires .
These APIs require the transient activation state to be true, and they consume user activation in each call to prevent multiple calls per user activation.
These APIs require the history-action activation state to be true, and they consume history-action user activation in each call to prevent multiple calls per user activation.
UserActivation
interface
Each
Window
has
an
associated
UserActivation
,
which
is
a
UserActivation
object.
Upon
creation
of
the
Window
object,
its
associated
UserActivation
must
be
set
to
a
new
UserActivation
object
created
in
the
Window
object's
relevant
realm
.
[Exposed=Window]
interface UserActivation {
readonly attribute boolean hasBeenActive;
readonly attribute boolean isActive;
};
partial interface Navigator {
[SameObject] readonly attribute UserActivation userActivation;
};
navigator
.
userActivation
.
hasBeenActive
Returns whether the window has sticky activation .
navigator
.
userActivation
.
isActive
Returns whether the window has transient activation .
The
userActivation
getter
steps
are
to
return
this
's
relevant
global
object
's
associated
UserActivation
.
The
hasBeenActive
getter
steps
are
to
return
true
if
this
's
relevant
global
object
has
sticky
activation
,
and
false
otherwise.
The
isActive
getter
steps
are
to
return
true
if
this
's
relevant
global
object
has
transient
activation
,
and
false
otherwise.
For the purposes of user-agent automation and application testing, this specification defines the following extension command for the Web Driver specification. It is optional for a user agent to support the following extension command . [WEBDRIVER]
| HTTP Method | URI Template |
|---|---|
`
POST
`
|
/session/{
session
id
}/window/consume-user-activation
|
The remote end steps are:
Let window be the current browsing context 's active window .
Let consume be true if window has transient activation ; otherwise false.
If consume is true, then consume user activation of window .
Return success with data consume .
Certain
elements
in
HTML
have
an
activation
behavior
,
which
means
that
the
user
can
activate
them.
This
is
always
caused
by
a
click
event.
The
user
agent
should
allow
the
user
to
manually
trigger
elements
that
have
an
activation
behavior
,
for
instance
using
keyboard
or
voice
input,
or
through
mouse
clicks.
When
the
user
triggers
an
element
with
a
defined
activation
behavior
in
a
manner
other
than
clicking
it,
the
default
action
of
the
interaction
event
must
be
to
fire
a
click
event
at
the
element.
element
.
click
()
Support in all current engines.
Acts as if the element was clicked.
Each element has an associated click in progress flag , which is initially unset.
The
click()
method
must
run
the
following
steps:
If this element is a form control that is disabled , then return.
If this element's click in progress flag is set, then return.
Set this element's click in progress flag .
Fire
a
synthetic
pointer
event
named
click
at
this
element,
with
the
not
trusted
flag
set.
Unset this element's click in progress flag .
ToggleEvent
interface
Support in all current engines.
Support in all current engines.
[Exposed=Window]
interface ToggleEvent : Event {
constructor(DOMString type, optional ToggleEventInit eventInitDict = {});
readonly attribute DOMString oldState;
readonly attribute DOMString newState;
readonly attribute Element? source;
};
dictionary ToggleEventInit : EventInit {
DOMString oldState = "";
DOMString newState = "";
};
event
.
oldState
Set
to
"
closed
"
when
transitioning
from
closed
to
open,
or
set
to
"
open
"
when
transitioning
from
open
to
closed.
event
.
newState
Set
to
"
open
"
when
transitioning
from
closed
to
open,
or
set
to
"
closed
"
when
transitioning
from
open
to
closed.
event
.
source
Set
to
the
element
which
initiated
the
toggle,
which
can
be
set
up
with
the
popovertarget
and
commandfor
attributes.
If
there
is
no
source
element,
then
it
is
set
to
null.
Support in all current engines.
Support in all current engines.
The
oldState
and
newState
attributes
must
return
the
values
they
are
initialized
to.
The
source
getter
steps
are
to
return
the
result
of
retargeting
source
against
this
's
currentTarget
.
DOM standard issue #1328 tracks how to better standardize associated event data in a way which makes sense on Events. Currently an event attribute initialized to a value cannot also have a getter, and so an internal slot (or map of additional fields) is required to properly specify this.
A toggle task tracker is a struct which has:
ToggleEvent
.
oldState
attribute.
CommandEvent
interface
[Exposed=Window]
interface CommandEvent : Event {
constructor(DOMString type, optional CommandEventInit eventInitDict = {});
readonly attribute Element? source;
readonly attribute DOMString command;
};
dictionary CommandEventInit : EventInit {
Element? source = null;
DOMString command = "";
};
event
.
command
Returns what action the element can take.
event
.
source
Returns
the
Element
that
was
interacted
with
in
order
to
cause
this
event.
The
command
attribute
must
return
the
value
it
was
initialized
to.
The
source
getter
steps
are
to
return
the
result
of
retargeting
source
against
this
's
currentTarget
.
DOM standard issue #1328 tracks how to better standardize associated event data in a way which makes sense on Events. Currently an event attribute initialized to a value cannot also have a getter, and so an internal slot (or map of additional fields) is required to properly specify this.
This section is non-normative.
An HTML user interface typically consists of multiple interactive widgets, such as form controls, scrollable regions, links, dialog boxes, browser tabs, and so forth. These widgets form a hierarchy, with some (e.g. browser tabs, dialog boxes) containing others (e.g. links, form controls).
When interacting with an interface using a keyboard, key input is channeled from the system, through the hierarchy of interactive widgets, to an active widget, which is said to be focused .
Consider an HTML application running in a browser tab running in a graphical environment. Suppose this application had a page with some text controls and links, and was currently showing a modal dialog, which itself had a text control and a button.
The hierarchy of focusable widgets, in this scenario, would include the browser window, which would have, amongst its children, the browser tab containing the HTML application. The tab itself would have as its children the various links and text controls, as well as the dialog. The dialog itself would have as its children the text control and the button.
If the widget with focus in this example was the text control in the dialog box, then key input would be channeled from the graphical system to ① the web browser, then to ② the tab, then to ③ the dialog, and finally to ④ the text control.
Keyboard events are always targeted at this focused element.
A top-level traversable has system focus when it can receive keyboard input channeled from the operating system, possibly targeted at one of its active document 's descendant navigables .
A
top-level
traversable
has
user
attention
when
its
system
visibility
state
is
"
visible
",
and
it
either
has
system
focus
or
user
agent
widgets
directly
related
to
it
can
receive
keyboard
input
channeled
from
the
operating
system.
User attention is lost when a browser window loses focus, whereas system focus might also be lost to other system widgets in the browser window such as a location bar.
A
Document
d
is
a
fully
active
descendant
of
a
top-level
traversable
with
user
attention
when
d
is
fully
active
and
d
's
node
navigable
's
top-level
traversable
has
user
attention
.
The term focusable area is used to refer to regions of the interface that can further become the target of such keyboard input. Focusable areas can be elements, parts of elements, or other regions managed by the user agent.
Each
focusable
area
has
a
DOM
anchor
,
which
is
a
Node
object
that
represents
the
position
of
the
focusable
area
in
the
DOM.
(When
the
focusable
area
is
itself
a
Node
,
it
is
its
own
DOM
anchor
.)
The
DOM
anchor
is
used
in
some
APIs
as
a
substitute
for
the
focusable
area
when
there
is
no
other
DOM
object
to
represent
the
focusable
area
.
The following table describes what objects can be focusable areas . The cells in the left column describe objects that can be focusable areas ; the cells in the right column describe the DOM anchors for those elements. (The cells that span both columns are non-normative examples.)
| Focusable area | DOM anchor |
|---|---|
| Examples | |
Elements
that
meet
all
the
following
criteria:
| The element itself. |
|
| |
The
shapes
of
area
elements
in
an
image
map
associated
with
an
img
element
that
is
being
rendered
and
is
not
inert
.
|
The
img
element.
|
|
In
the
following
example,
the
| |
| The user-agent provided subwidgets of elements that are being rendered and are not actually disabled or inert . | The element for which the focusable area is a subwidget. |
|
The
controls
in
the
user
interface
for
a
| |
| The scrollable regions of elements that are being rendered and are not inert . | The element for which the box that the scrollable region scrolls was created. |
|
The CSS 'overflow' property's 'scroll' value typically creates a scrollable region. | |
The
viewport
of
a
Document
that
has
a
non-null
browsing
context
and
is
not
inert
.
|
The
Document
for
which
the
viewport
was
created.
|
|
The
contents
of
an
| |
| Any other element or part of an element determined by the user agent to be a focusable area, especially to aid with accessibility or to better match platform conventions. | The element. |
|
A user agent could make all list item bullets sequentially focusable , so that a user can more easily navigate lists.
Similarly,
a
user
agent
could
make
all
elements
with
| |
A
navigable
container
(e.g.
an
iframe
)
is
a
focusable
area
,
but
key
events
routed
to
a
navigable
container
get
immediately
routed
to
its
content
navigable
's
active
document
.
Similarly,
in
sequential
focus
navigation
a
navigable
container
essentially
acts
merely
as
a
placeholder
for
its
content
navigable
's
active
document
.
One
focusable
area
in
each
Document
is
designated
the
focused
area
of
the
document
.
Which
control
is
so
designated
changes
over
time,
based
on
algorithms
in
this
specification.
Even if a document is not fully active and not shown to the user, it can still have a focused area of the document . If a document's fully active state changes, its focused area of the document will stay the same.
The currently focused area of a top-level traversable traversable is the focusable area -or-null returned by this algorithm:
If traversable does not have system focus , then return null.
Let candidate be traversable 's active document .
While candidate 's focused area is a navigable container with a non-null content navigable : set candidate to the active document of that navigable container 's content navigable .
If candidate 's focused area is non-null, set candidate to candidate 's focused area .
Return candidate .
The current focus chain of a top-level traversable traversable is the focus chain of the currently focused area of traversable , if traversable is non-null, or an empty list otherwise.
An element that is the DOM anchor of a focusable area is said to gain focus when that focusable area becomes the currently focused area of a top-level traversable . When an element is the DOM anchor of a focusable area of the currently focused area of a top-level traversable , it is focused .
The focus chain of a focusable area subject is the ordered list constructed as follows:
Let output be an empty list .
Let currentObject be subject .
While true:
Append currentObject to output .
If
currentObject
is
an
area
element's
shape,
then
append
that
area
element
to
output
.
Otherwise, if currentObject 's DOM anchor is an element that is not currentObject itself, then append currentObject 's DOM anchor to output .
If currentObject is a focusable area , then set currentObject to currentObject 's DOM anchor 's node document .
Otherwise,
if
currentObject
is
a
Document
whose
node
navigable
's
parent
is
non-null,
then
set
currentObject
to
currentObject
's
node
navigable
's
parent
.
Otherwise, break .
Return output .
The
chain
starts
with
subject
and
(if
subject
is
or
can
be
the
currently
focused
area
of
a
top-level
traversable
)
continues
up
the
focus
hierarchy
up
to
the
Document
of
the
top-level
traversable
.
All elements that are focusable areas are said to be focusable .
There are two special types of focusability for focusable areas :
A
focusable
area
is
said
to
be
sequentially
focusable
if
it
is
included
in
its
Document
's
sequential
focus
navigation
order
and
the
user
agent
determines
that
it
is
sequentially
focusable.
A focusable area is said to be click focusable if the user agent determines that it is click focusable. User agents should consider focusable areas with non-null tabindex values to be click focusable.
Elements which are not focusable are not focusable areas , and thus not sequentially focusable and not click focusable .
Being
focusable
is
a
statement
about
whether
an
element
can
be
focused
programmatically,
e.g.
via
the
focus()
method
or
autofocus
attribute.
In
contrast,
sequentially
focusable
and
click
focusable
govern
how
the
user
agent
responds
to
user
interaction:
respectively,
to
sequential
focus
navigation
and
as
activation
behavior
.
The
user
agent
might
determine
that
an
element
is
not
sequentially
focusable
even
if
it
is
focusable
and
is
included
in
its
Document
's
sequential
focus
navigation
order
,
according
to
user
preferences.
For
example,
macOS
users
can
set
the
user
agent
to
skip
non-form
control
elements,
or
can
skip
links
when
doing
sequential
focus
navigation
with
just
the
Tab
key
(as
opposed
to
using
both
the
Option
and
Tab
keys).
Similarly, the user agent might determine that an element is not click focusable even if it is focusable . For example, in some user agents, clicking on a non-editable form control does not focus it, i.e. the user agent has determined that such controls are not click focusable.
Thus, an element can be focusable , but neither sequentially focusable nor click focusable . For example, in some user agents, a non-editable form-control with a negative-integer tabindex value would not be focusable via user interaction, only via programmatic APIs.
When
a
user
activates
a
click
focusable
focusable
area
,
the
user
agent
must
run
the
focusing
steps
on
the
focusable
area
with
focus
trigger
set
to
"
click
".
Note
that
focusing
is
not
an
activation
behavior
,
i.e.
calling
the
click()
method
on
an
element
or
dispatching
a
synthetic
click
event
on
it
won't
cause
the
element
to
get
focused.
A
node
is
a
focus
navigation
scope
owner
if
it
is
a
Document
,
a
shadow
host
,
a
slot
,
or
an
element
which
is
the
popover
trigger
of
an
element
in
the
popover
showing
state
.
Each focus navigation scope owner has a focus navigation scope , which is a list of elements. Its contents are determined as follows:
Every element element has an associated focus navigation owner , which is either null or a focus navigation scope owner . It is determined by the following algorithm:
If element 's parent is null, then return null.
If element 's parent is a shadow host , then return element 's assigned slot .
If element 's parent is a shadow root , then return the parent's host .
If element 's parent is the document element , then return the parent's node document .
If element is in the popover showing state and has a popover trigger set, then return element 's popover trigger .
Return element 's parent's associated focus navigation owner .
Then, the contents of a given focus navigation scope owner owner 's focus navigation scope are all elements whose associated focus navigation owner is owner .
The order of elements within a focus navigation scope does not impact any of the algorithms in this specification. Ordering only becomes important for the tabindex-ordered focus navigation scope and flattened tabindex-ordered focus navigation scope concepts defined below.
A tabindex-ordered focus navigation scope is a list of focusable areas and focus navigation scope owners . Every focus navigation scope owner owner has tabindex-ordered focus navigation scope , whose contents are determined as follows:
It contains all elements in owner 's focus navigation scope that are themselves focus navigation scope owners , except the elements whose tabindex value is a negative integer.
It contains all of the focusable areas whose DOM anchor is an element in owner 's focus navigation scope , except the focusable areas whose tabindex value is a negative integer.
The order within a tabindex-ordered focus navigation scope is determined by each element's tabindex value , as described in the section below.
The rules there do not give a precise ordering, as they are composed mostly of "should" statements and relative orderings.
A flattened tabindex-ordered focus navigation scope is a list of focusable areas . Every focus navigation scope owner owner owns a distinct flattened tabindex-ordered focus navigation scope , whose contents are determined by the following algorithm:
Let result be a clone of owner 's tabindex-ordered focus navigation scope .
For each item of result :
If item is not a focus navigation scope owner , then continue .
If item is not a focusable area , then replace item with all of the items in item 's flattened tabindex-ordered focus navigation scope .
Otherwise, insert the contents of item 's flattened tabindex-ordered focus navigation scope after item .
tabindex
attribute
Support in all current engines.
The
tabindex
content
attribute
allows
authors
to
make
an
element
and
regions
that
have
the
element
as
its
DOM
anchor
be
focusable
areas
,
allow
or
prevent
them
from
being
sequentially
focusable
,
and
determine
their
relative
ordering
for
sequential
focus
navigation
.
The name "tab index" comes from the common use of the Tab key to navigate through the focusable elements. The term "tabbing" refers to moving forward through sequentially focusable focusable areas .
The
tabindex
attribute,
if
specified,
must
have
a
value
that
is
a
valid
integer
.
Positive
numbers
specify
the
relative
position
of
the
element's
focusable
areas
in
the
sequential
focus
navigation
order
,
and
negative
numbers
indicate
that
the
control
is
not
sequentially
focusable
.
Developers
should
use
caution
when
using
values
other
than
0
or
−1
for
their
tabindex
attributes
as
this
is
complicated
to
do
correctly.
The
following
provides
a
non-normative
summary
of
the
behaviors
of
the
possible
tabindex
attribute
values.
The
below
processing
model
gives
the
more
precise
rules.
tabindex
attribute
value
come
later.
Note
that
the
tabindex
attribute
cannot
be
used
to
make
an
element
non-focusable.
The
only
way
a
page
author
can
do
that
is
by
disabling
the
element,
or
making
it
inert
.
The
tabindex
value
of
an
element
is
the
value
of
its
tabindex
attribute,
parsed
using
the
rules
for
parsing
integers
.
If
parsing
fails
or
the
attribute
is
not
specified,
then
the
tabindex
value
is
null.
The tabindex value of a focusable area is the tabindex value of its DOM anchor .
The tabindex value of an element must be interpreted as follows:
The user agent should follow platform conventions to determine if the element should be considered as a focusable area and if so, whether the element and any focusable areas that have the element as their DOM anchor are sequentially focusable , and if so, what their relative position in their tabindex-ordered focus navigation scope is to be. If the element is a focus navigation scope owner , it must be included in its tabindex-ordered focus navigation scope even if it is not a focusable area .
The relative ordering within a tabindex-ordered focus navigation scope for elements and focusable areas that belong to the same focus navigation scope and whose tabindex value is null should be in shadow-including tree order .
Modulo platform conventions, it is suggested that the following elements should be considered as focusable areas and be sequentially focusable :
a
elements
that
have
an
href
attribute
button
elements
input
elements
whose
type
attribute
are
not
in
the
state
select
elements
textarea
elements
summary
elements
that
are
the
first
summary
element
child
of
a
details
element
draggable
attribute
set,
if
that
would
enable
the
user
agent
to
allow
the
user
to
begin
drag
operations
for
those
elements
without
the
use
of
a
pointing
device
The user agent must consider the element as a focusable area , but should omit the element from any tabindex-ordered focus navigation scope .
One
valid
reason
to
ignore
the
requirement
that
sequential
focus
navigation
not
allow
the
author
to
lead
to
the
element
would
be
if
the
user's
only
mechanism
for
moving
the
focus
is
sequential
focus
navigation.
For
instance,
a
keyboard-only
user
would
be
unable
to
click
on
a
text
control
with
a
negative
tabindex
,
so
that
user's
user
agent
would
be
well
justified
in
allowing
the
user
to
tab
to
the
control
regardless.
The user agent must allow the element to be considered as a focusable area and should allow the element and any focusable areas that have the element as their DOM anchor to be sequentially focusable .
The relative ordering within a tabindex-ordered focus navigation scope for elements and focusable areas that belong to the same focus navigation scope and whose tabindex value is zero should be in shadow-including tree order .
The user agent must allow the element to be considered as a focusable area and should allow the element and any focusable areas that have the element as their DOM anchor to be sequentially focusable , and should place the element — referenced as candidate below — and the aforementioned focusable areas in the tabindex-ordered focus navigation scope where the element is a part of so that, relative to other elements and focusable areas that belong to the same focus navigation scope , they are:
tabindex
attribute
has
been
omitted
or
whose
value,
when
parsed,
returns
an
error,
tabindex
attribute
has
a
value
less
than
or
equal
to
zero,
tabindex
attribute
has
a
value
greater
than
zero
but
less
than
the
value
of
the
tabindex
attribute
on
candidate
,
tabindex
attribute
has
a
value
equal
to
the
value
of
the
tabindex
attribute
on
candidate
but
that
is
located
earlier
than
candidate
in
shadow-including
tree
order
,
tabindex
attribute
has
a
value
equal
to
the
value
of
the
tabindex
attribute
on
candidate
but
that
is
located
later
than
candidate
in
shadow-including
tree
order
,
and
tabindex
attribute
has
a
value
greater
than
the
value
of
the
tabindex
attribute
on
candidate
.
Support in all current engines.
The
tabIndex
getter
steps
are:
If attribute is not null:
Let parsedValue be the result of integer parsing attribute 's value .
If
parsedValue
is
not
an
error
and
is
within
the
long
range,
then
return
parsedValue
.
Return
0
if
this
is
an
a
,
area
,
button
,
frame
,
iframe
,
input
,
object
,
select
,
textarea
,
or
SVG
a
element,
or
is
a
summary
element
that
is
a
summary
for
its
parent
details
;
otherwise
1.
The varying default value based on element type is a historical artifact.
To
get
the
focusable
area
for
a
focus
target
that
is
either
an
element
that
is
not
a
focusable
area
,
or
is
a
navigable
,
given
an
optional
string
focus
trigger
(default
"
other
"),
run
the
first
matching
set
of
steps
from
the
following
list:
area
element
with
one
or
more
shapes
that
are
focusable
areas
Return
the
shape
corresponding
to
the
first
img
element
in
tree
order
that
uses
the
image
map
to
which
the
area
element
belongs.
Return the element's first scrollable region, according to a pre-order, depth-first traversal of the flat tree . [CSSSCOPING]
Document
Return the navigable 's active document .
Return the navigable container 's content navigable 's active document .
Let focusedElement be the currently focused area of a top-level traversable 's DOM anchor .
If focus target is a shadow-including inclusive ancestor of focusedElement , then return focusedElement .
Return the focus delegate for focus target given focus trigger .
For sequential focusability , the handling of shadow hosts and delegates focus is done when constructing the sequential focus navigation order . That is, the focusing steps will never be called on such shadow hosts as part of sequential focus navigation.
Return null.
The
focus
delegate
for
a
focusTarget
,
given
an
optional
string
focusTrigger
(default
"
other
"),
is
given
by
the
following
steps:
If focusTarget is a shadow host and its shadow root 's delegates focus is false, then return null.
Let whereToLook be focusTarget .
If whereToLook is a shadow host , then set whereToLook to whereToLook 's shadow root .
Let autofocusDelegate be the autofocus delegate for whereToLook given focusTrigger .
If autofocusDelegate is not null, then return autofocusDelegate .
For each descendant of whereToLook 's descendants , in tree order :
Let focusableArea be null.
If
focusTarget
is
a
dialog
element
and
descendant
is
sequentially
focusable
,
then
set
focusableArea
to
descendant
.
Otherwise,
if
focusTarget
is
not
a
dialog
and
descendant
is
a
focusable
area
,
set
focusableArea
to
descendant
.
Otherwise, set focusableArea to the result of getting the focusable area for descendant given focusTrigger .
This step can end up recursing, i.e., the get the focusable area steps might return the focus delegate of descendant .
If focusableArea is not null, then return focusableArea .
It's important that we are not looking at the shadow-including descendants here, but instead only at the descendants . Shadow hosts are instead handled by the recursive case mentioned above.
Return null.
The above algorithm essentially returns the first suitable focusable area where the path between its DOM anchor and focusTarget delegates focus at any shadow tree boundaries.
The autofocus delegate for a focus target given a focus trigger is given by the following steps:
For each descendant descendant of focus target , in tree order :
If
descendant
does
not
have
an
autofocus
content
attribute,
then
continue
.
Let focusable area be descendant , if descendant is a focusable area ; otherwise let focusable area be the result of getting the focusable area for descendant given focus trigger .
If focusable area is null, then continue .
If
focusable
area
is
not
click
focusable
and
focus
trigger
is
"
click
",
then
continue
.
Return focusable area .
Return null.
The focusing steps for an object new focus target that is either a focusable area , or an element that is not a focusable area , or a navigable , are as follows. They can optionally be run with a fallback target and a string focus trigger .
If new focus target is not a focusable area , then set new focus target to the result of getting the focusable area for new focus target , given focus trigger if it was passed.
If new focus target is null, then:
If no fallback target was specified, then return.
Otherwise, set new focus target to the fallback target .
If new focus target is a navigable container with non-null content navigable , then set new focus target to the content navigable 's active document .
If new focus target is a focusable area and its DOM anchor is inert , then return.
If new focus target is the currently focused area of a top-level traversable , then return.
Let old chain be the current focus chain of the top-level traversable in which new focus target finds itself.
Let new chain be the focus chain of new focus target .
Run the focus update steps with old chain , new chain , and new focus target respectively.
User agents must immediately run the focusing steps for a focusable area or navigable candidate whenever the user attempts to move the focus to candidate .
The unfocusing steps for an object old focus target that is either a focusable area or an element that is not a focusable area are as follows:
If old focus target is a shadow host whose shadow root 's delegates focus is true, and old focus target 's shadow root is a shadow-including inclusive ancestor of the currently focused area of a top-level traversable 's DOM anchor , then set old focus target to that currently focused area of a top-level traversable .
If old focus target is inert , then return.
If
old
focus
target
is
an
area
element
and
one
of
its
shapes
is
the
currently
focused
area
of
a
top-level
traversable
,
or,
if
old
focus
target
is
an
element
with
one
or
more
scrollable
regions,
and
one
of
them
is
the
currently
focused
area
of
a
top-level
traversable
,
then
let
old
focus
target
be
that
currently
focused
area
of
a
top-level
traversable
.
Let old chain be the current focus chain of the top-level traversable in which old focus target finds itself.
If old focus target is not one of the entries in old chain , then return.
If old focus target is not a focusable area , then return.
Let topDocument be old chain 's last entry.
If topDocument 's node navigable has system focus , then run the focusing steps for topDocument 's viewport .
Otherwise, apply any relevant platform-specific conventions for removing system focus from topDocument 's node navigable , and run the focus update steps given old chain , an empty list, and null.
The unfocusing steps do not always result in the focus changing, even when applied to the currently focused area of a top-level traversable . For example, if the currently focused area of a top-level traversable is a viewport , then it will usually keep its focus regardless until another focusable area is explicitly focused with the focusing steps .
The focus update steps , given an old chain , a new chain , and a new focus target respectively, are as follows:
If the last entry in old chain and the last entry in new chain are the same, pop the last entry from old chain and the last entry from new chain and redo this step.
For each entry entry in old chain , in order, run these substeps:
If
entry
is
an
input
element,
and
the
change
event
applies
to
the
element,
and
the
element
does
not
have
a
defined
activation
behavior
,
and
the
user
has
changed
the
element's
value
or
its
list
of
selected
files
while
the
control
was
focused
without
committing
that
change
(such
that
it
is
different
to
what
it
was
when
the
control
was
first
focused),
then:
Set entry 's user validity to true.
Fire
an
event
named
change
at
the
element,
with
the
bubbles
attribute
initialized
to
true.
If entry is an element, let blur event target be entry .
If
entry
is
a
Document
object,
let
blur
event
target
be
that
Document
object's
relevant
global
object
.
Otherwise, let blur event target be null.
If
entry
is
the
last
entry
in
old
chain
,
and
entry
is
an
Element
,
and
the
last
entry
in
new
chain
is
also
an
Element
,
then
let
related
blur
target
be
the
last
entry
in
new
chain
.
Otherwise,
let
related
blur
target
be
null.
If
blur
event
target
is
not
null,
null:
fire
Fire
a
focus
event
named
blur
at
blur
event
target
,
with
related
blur
target
as
the
related
target.
In
some
cases,
e.g.,
if
entry
is
an
area
element's
shape,
a
scrollable
region,
or
a
viewport
,
no
event
is
fired.
Handle interest change for blur event target and false.
Apply any relevant platform-specific conventions for focusing new focus target . (For example, some platforms select the contents of a text control when that control is focused.)
For each entry entry in new chain , in reverse order, run these substeps:
If entry is a focusable area , and the focused area of the document is not entry :
Set document 's relevant global object 's navigation API 's focus changed during ongoing navigation to true.
Designate entry as the focused area of the document .
If entry is an element, let focus event target be entry .
If
entry
is
a
Document
object,
let
focus
event
target
be
that
Document
object's
relevant
global
object
.
Otherwise, let focus event target be null.
If
entry
is
the
last
entry
in
new
chain
,
and
entry
is
an
Element
,
and
the
last
entry
in
old
chain
is
also
an
Element
,
then
let
related
focus
target
be
the
last
entry
in
old
chain
.
Otherwise,
let
related
focus
target
be
null.
If
focus
event
target
is
not
null,
null:
fire
Fire
a
focus
event
named
focus
at
focus
event
target
,
with
related
focus
target
as
the
related
target.
In
some
cases,
e.g.
e.g.,
if
entry
is
an
area
element's
shape,
a
scrollable
region,
or
a
viewport
,
no
event
is
fired.
Handle interest change for focus event target and true.
To
fire
a
focus
event
named
e
at
an
element
t
with
a
given
related
target
r
,
fire
an
event
named
e
at
t
,
using
FocusEvent
,
with
the
relatedTarget
attribute
initialized
to
r
,
the
view
attribute
initialized
to
t
's
node
document
's
relevant
global
object
,
and
the
composed
flag
set.
When a key event is to be routed in a top-level traversable , the user agent must run the following steps:
Let target area be the currently focused area of the top-level traversable .
Assert : target area is not null, since key events are only routed to top-level traversables that have system focus . Therefore, target area is a focusable area .
Let target node be target area 's DOM anchor .
If
target
node
is
a
Document
that
has
a
body
element
,
then
let
target
node
be
the
body
element
of
that
Document
.
Otherwise,
if
target
node
is
a
Document
object
that
has
a
non-null
document
element
,
then
let
target
node
be
that
document
element
.
If target node is not inert , then:
Let canHandle be the result of dispatching the key event at target node .
If
canHandle
is
true,
then
let
target
area
handle
the
key
event.
This
might
include
firing
a
click
event
at
target
node
.
The
has
focus
steps
,
given
a
Document
object
target
,
are
as
follows:
If target 's node navigable 's top-level traversable does not have system focus , then return false.
Let candidate be target 's node navigable 's top-level traversable 's active document .
While true:
If candidate is target , then return true.
If the focused area of candidate is a navigable container with a non-null content navigable , then set candidate to the active document of that navigable container 's content navigable .
Otherwise, return false.
Each
Document
has
a
sequential
focus
navigation
order
,
which
orders
some
or
all
of
the
focusable
areas
in
the
Document
relative
to
each
other.
Its
contents
and
ordering
are
given
by
the
flattened
tabindex-ordered
focus
navigation
scope
of
the
Document
.
Per
the
rules
defining
the
flattened
tabindex-ordered
focus
navigation
scope
,
the
ordering
is
not
necessarily
related
to
the
tree
order
of
the