Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 36 additions & 24 deletions selectors-4/Overview.bs
Original file line number Diff line number Diff line change
Expand Up @@ -2256,6 +2256,42 @@ The Focus-Indicated Pseudo-class: '':focus-visible''</h3>
like clicking on the button with a mouse pointer.
</div>

The goal of this selector is to explain how the browser's default focus
indicator behavior works in order to encourage more visible, usable focus
styles, and discourage the practice of disabling the default user agent focus
style.

For example, a `:focus` style will always be applied
to a focused element, regardless of _how_ it was focused. Whereas a
`:focus-visible` style would only be applied to an element if it matches the
same heuristic that the UA uses to draw its default focus indicator.

The user agent should take into account the available signals as to whether
the user might find focus indication useful. The result of these heuristics
must determine whether `:focus-visible` should match on the currently focused
element.

By default, if there are no signals indicating that focus should be
indicated, then focus should not be indicated on the focused element, unless
the user has expressed a preference for always seeing a focus ring.

The following may be considered signals:

* An element which requires the use of a keyboard, such as a text input,
should always have a visible focus indicator.
* If a user is using keyboard-based navigation by using the tab and arrow
keys, the focused element should be indicated.
* If a user is interacting with an element via the keyboard (such as
incrementing or decrementing using the arrow keys, or using the spacebar to
activate a button) the focused element should be indicated.
* Note that keyboard interaction may trigger focus to be moved
programmatically, and this may be considered an extension of the original
keyboard interaction.

Because `:focus-visible` must match the UA's default behavior for when to show
a focus indicator, one way to meet this requirement would be to use
`:focus-visible` in the UA stylesheet itself.

<div class=advisement>
Page authors should follow these guidelines
when deciding whether to use '':focus'' or '':focus-visible''
Expand All @@ -2271,30 +2307,6 @@ The Focus-Indicated Pseudo-class: '':focus-visible''</h3>
use '':focus-visible''.
</div>

When UAs choose to specially indicate focus on an element,
or whether they specially indicate focus at all,
is UA-dependent.
Different UAs,
the same UA on different operating systems,
or the same UA on the same OS,
but with different user settings,
can make different choices as to when an element matches '':focus-visible''.

<div class=example>
The following guidelines are suggested heuristics
for choosing when to apply '':focus-visible''
to elements without “native” focus indicator behavior:

* If the element received focus via a keyboard interaction,
including indirectly,
such as triggering a dialog
by pressing a button using the keyboard,
apply '':focus-visible''.
* If a keyboard event occurs while an element is focused,
even if the element wasn't focused by a keyboard interaction,
apply '':focus-visible''.
</div>

<h3 id="the-focus-within-pseudo">
The Focus Container Pseudo-class: '':focus-within''</h3>

Expand Down