Skip to content

Commit 8562cd2

Browse files
committed
Update focus-visible guidance to match TAG feedback.
1 parent 4ed40b8 commit 8562cd2

File tree

1 file changed

+49
-41
lines changed

1 file changed

+49
-41
lines changed

selectors-4/Overview.bs

Lines changed: 49 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -2256,47 +2256,55 @@ The Focus-Indicated Pseudo-class: '':focus-visible''</h3>
22562256
like clicking on the button with a mouse pointer.
22572257
</div>
22582258

2259-
This pseudo-class is intended to give developers the ability to style focus
2260-
selectively, in order to encourage visible, usable focus styles, and
2261-
discourage the practice of disabling the default user agent focus style.
2262-
2263-
When UAs choose to specially indicate focus on an element,
2264-
or whether they specially indicate focus at all,
2265-
is UA-dependent.
2266-
Different UAs,
2267-
the same UA on different operating systems,
2268-
or the same UA on the same OS,
2269-
but with different user settings,
2270-
can make different choices as to when an element matches '':focus-visible''.
2271-
2272-
Since part of the problem is user agents' default focus indicator behaviour,
2273-
it is recommended that browsers implementing the `:focus-visible`
2274-
selector also use it in their user agent stylesheets to show the default focus
2275-
indicator.
2276-
2277-
<div class=note>
2278-
The user agent should take into account the available signals as to whether
2279-
the user might find focus indication useful. The result of these heuristics
2280-
must determine whether `:focus-visible` should match on the currently
2281-
focused element.
2282-
2283-
By default, if there are no signals indicating that focus should be
2284-
indicated, then focus SHOULD NOT be indicated on the focused element, unless
2285-
the user has expressed a preference for always seeing a focus ring.
2286-
2287-
The following may be considered signals:
2288-
2289-
* An element which requires the use of a keyboard, such as a text input,
2290-
SHOULD always have a visible focus indicator.
2291-
* If a user is using keyboard-based navigation by using the tab and arrow
2292-
keys, the focused element SHOULD be indicated.
2293-
* If a user is interacting with an element via the keyboard (such as
2294-
incrementing or decrementing using the arrow keys, or using the spacebar to
2295-
activate a button) the focused element SHOULD be indicated.
2296-
* Note that keyboard interaction may trigger focus to be moved
2297-
programmatically, and this may be considered an extension of the original
2298-
keyboard interaction.
2299-
2259+
The goal of this selector is to explain how the browser's default focus
2260+
indicator behavior works in order to encourage more visible, usable focus
2261+
styles, and discourage the practice of disabling the default user agent focus
2262+
style.
2263+
2264+
For example, a `:focus` style will always be applied
2265+
to a focused element, regardless of _how_ it was focused. Whereas a
2266+
`:focus-visible` style would only be applied to an element if it matches the
2267+
same heuristic that the UA uses to draw its default focus indicator.
2268+
2269+
The user agent should take into account the available signals as to whether
2270+
the user might find focus indication useful. The result of these heuristics
2271+
must determine whether `:focus-visible` should match on the currently focused
2272+
element.
2273+
2274+
By default, if there are no signals indicating that focus should be
2275+
indicated, then focus should not be indicated on the focused element, unless
2276+
the user has expressed a preference for always seeing a focus ring.
2277+
2278+
The following may be considered signals:
2279+
2280+
* An element which requires the use of a keyboard, such as a text input,
2281+
should always have a visible focus indicator.
2282+
* If a user is using keyboard-based navigation by using the tab and arrow
2283+
keys, the focused element should be indicated.
2284+
* If a user is interacting with an element via the keyboard (such as
2285+
incrementing or decrementing using the arrow keys, or using the spacebar to
2286+
activate a button) the focused element should be indicated.
2287+
* Note that keyboard interaction may trigger focus to be moved
2288+
programmatically, and this may be considered an extension of the original
2289+
keyboard interaction.
2290+
2291+
Because `:focus-visible` must match the UA's default behavior for when to show
2292+
a focus indicator, one way to meet this requirement would be to use
2293+
`:focus-visible` in the UA stylesheet itself.
2294+
2295+
<div class=advisement>
2296+
Page authors should follow these guidelines
2297+
when deciding whether to use '':focus'' or '':focus-visible''
2298+
to style the focused state of an element:
2299+
2300+
* If the element has “native” focus indicator behavior
2301+
(such as text fields or buttons),
2302+
use '':focus-visible''.
2303+
* Otherwise, if the element is emulating a text input,
2304+
or something else that is <em>intended</em> to receive keyboard interaction,
2305+
use '':focus''.
2306+
* Otherwise,
2307+
use '':focus-visible''.
23002308
</div>
23012309

23022310
<h3 id="the-focus-within-pseudo">

0 commit comments

Comments
 (0)