Skip to content

KBD-002 Keep the focused element at least partly in view

Level
Rule
Verdict
Requirement
Status
decided, version 1.0.2

Rule

When an element has keyboard focus, at least part of it stays in view: no sticky header or footer, toast, cookie banner, chat button or panel that the page put on screen may cover it completely.

Examples

Live examples built with Justified's components. Try them with the mouse, the keyboard or a screen reader.

Do: Scroll room reserved for the sticky header

The box is a small page with a header that stays at the top. It starts at the highest point Shift+Tab can leave Choir summer tour: just below the header, because the box keeps that room free. Tab into it and on through the projects to School fun run, then press Shift+Tab to go back up. Whenever the box scrolls, it stops the link clear of the header, and the line under the box says it is fully in view. The room the box keeps free follows the header's real height.

Don't: Sticky header with no reserved room

The same page without the reserved room. It starts where Shift+Tab leaves it when focus comes back up to Choir summer tour: behind the header. Tab down to School fun run, then press Shift+Tab to go back up. On the way, links such as Choir summer tour stop at the very top of the box, behind the header, and the line under the box says they are partly or completely hidden. You cannot see which link Enter would open.

Why

A keyboard user follows the focus to know where they are. If it moves under a bar or a banner, they press Tab and see nothing happen. They cannot tell which control will react to Enter, and they may give up or act on the wrong thing. The same goes for people who use switches or voice control, and for people who zoom in and see only a small part of the page at a time. WCAG 2.2, 2.4.11 Focus Not Obscured (Minimum) requires that content the page itself places on top never hides the focused element completely. Partly hidden still meets the criterion. Our aim goes further and keeps the whole element in view, as 2.4.12 Focus Not Obscured (Enhanced) asks at Level AAA, but that is not required here. Whether the focus indicator exists and can be seen is KBD-001. What sticky bars do at 320 pixels is LAY-001.

Do

  • Reserve scroll room for sticky bars. Set scroll-padding-top on the scrolling element to the height of a sticky header, and scroll-padding-bottom to the height of a sticky footer, so the browser stops a newly focused element clear of them. scroll-margin on the elements themselves works too.
  • Let that reserved room follow the bar's real height. A header with My account and Sign out that grows to two lines with larger text needs more room, so read the height from a CSS variable that changes with the breakpoint, not a fixed number.
  • Leave enough space at the end of the page that the last links, such as Accessibility statement and Contact, can scroll up above a sticky footer with a Go to checkout button.
  • Tab down a long page and back up again under the sticky header, and check every focused element stays at least partly in view both ways.
  • Keep a cookie banner in the normal flow at the very start of the page, so it pushes content down instead of lying over it. When the person picks Accept all or Necessary only, it goes away.
  • Place toasts and chat buttons in empty space where no control sits under them, and check that space at every breakpoint. Make them smaller or move them where it is tight.
  • Place a toast with Undo after Archive so it never covers the row of buttons that has focus. If the person tabs on to Edit in the row below, that button must still show.
  • Where there is room, let a side panel such as Filter push the main area narrower so it reflows, rather than lie over the result list. Where the panel must lie over the list, as at narrow widths in LAY-001, the person opens it, and it either closes with Escape or keeps focus inside until closed.
  • Treat a modal dialog as already meeting the rule when focus moves into it as it opens and the page behind cannot be used until it closes, as DLG-006 and DLG-007 say.
  • Close an autocomplete list for City as soon as focus leaves the field, so it never stays over the next field.
  • Test with the page zoomed to 400 percent as well as at full size, since layers take a larger share of the screen when zoomed.

Don't

  • Fix a header to the top with no reserved scroll room, so tabbing back up puts Search or a link in the article right under it.
  • Fix a cookie banner to the bottom of the viewport while the page behind it can still be used, so it hides Read more and Next as focus moves down.
  • Show a lasting toast, such as "Your change is saved" with Undo, in the top right where it covers the user menu Anna S when that gets focus.
  • Leave a chat button in the bottom right over a small link such as Terms, so the link vanishes completely when it has focus.
  • Let a promotional pop-up appear by itself over the form and stay there while the person tabs through the fields behind it.
  • Treat a toast as fine because the person can tab to its close button. The focused element was hidden before they could.
  • Rely on a semi-transparent or blurred layer to keep focus visible without checking that the indicator seen through it still has enough contrast, as 1.4.11 Non-text Contrast asks.

Exceptions

  • A layer the person opened. If the person opened a layer themselves, such as a chat window from Chat with us, it may cover the focused element as long as they can uncover it without moving focus, for example by pressing Escape to close it or by scrolling the page. A toast that appears after the person's own action, such as saving or archiving, does not count as opened by them. The page placed it, so the rule applies in full.
  • A panel the person can drag. If people can move a toolbar or panel, judge it where it first appears. A design that also keeps focus clear after a move is better.

Verdict

Requirement. Only the judges decide; the expert witnesses are shown but do not vote. How verdicts work

Stances on KBD-002
SourceRoleStancePage
WCAG 2.2LawRequires2.4.11 Focus Not Obscured (Minimum)
WCAG 2.2LawSupports2.4.7 Focus Visible
WCAG 2.2LawSupports1.4.11 Non-text Contrast
WCAG 2.2LawSupports1.4.10 Reflow
Material DesignJudge SupportsSnackbar: guidelines
Apple Human Interface GuidelinesJudge No position
Carbon Design SystemJudge No position
GOV.UK Design SystemExpert witness SupportsCookie banner
Nielsen Norman GroupExpert witness No position

Each stance links to the page it rests on, read on the date in the source register. This page never repeats what a source says; read the source itself.

History

  • Version 1.0.2, : The modal dialog bullet refers to DLG-006 and DLG-007.
  • Version 1.0.1, : Examples in English.
  • Version 1.0.0, : First version.

Last checked against the other rules for conflicts on .

More in Keyboard: 5 rules and 0 guidelines · All rules