How can I prevent CSS from hiding keyboard-focusable content?
Quick answer
For each interactive element, check whether it is visually available, whether it can receive keyboard focus, and whether a keyboard user can see and operate it when focused. Clipped content can remain in the tab order without scrolling into view, while content-visibility has different focus behavior for hidden and auto states [S1] [S2]. Test each real state and the resulting focus order; do not assume one hiding technique behaves like another.
The question, the details, the next step.
A practical checklist
List each interactive region and the states in which it is shown, hidden, clipped, or moved.
Record the CSS or layout mechanism used in each state instead of assuming all hiding methods act alike.
Use the keyboard to reach every control in each state; note any focus that is not visibly apparent.
Check whether clipped focus targets are brought into view and can be operated.
Review whether focus order makes sense and whether any focusable item is unavailable to operate.
Retest after changes in the target browser and repeat for every relevant state.
A few more useful answers
Does a focus order have to match the visual layout exactly?
No. W3C guidance says the sequential focus order should preserve meaning and operability; it need not exactly match the visual layout [S3].
Does `content-visibility: auto` make skipped content unreachable?
The cited MDN reference says skipped content under content-visibility: auto remains available and focusable. Test the actual page and state rather than generalizing that behavior to other CSS techniques [S2].
Can clipped content still receive keyboard focus?
Yes, it can: MDN warns that clipped interactive descendants may receive focus without being scrolled into view. The exact behavior can depend on browser and layout, so verify it in your implementation [S1].
Sources
References used for this guide.
- [S1] MDN CSS overflow property: clipping and keyboard focus developer.mozilla.org · Checked
- [S2] MDN CSS content-visibility property and skipped content developer.mozilla.org · Checked
- [S3] Understanding WCAG 2.2 Success Criterion 2.4.3: Focus Order w3.org · Checked
