Visual hiding and reading order
Definition and purpose
Visual hiding and semantic hiding are different. A visually hidden label can name a control while occupying almost no visible area; a genuinely unavailable control should not remain keyboard reachable.
Icon button label
<!doctype html><html lang="en"> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <title>CSS practice</title> <style> body { margin: 0; font: 16px sans-serif; color: #172033; background: white; } #b { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; } </style> </head> <body> <button id="a" type="button"> <span id="b">Remove item</span> <span aria-hidden="true">×</span> </button> </body></html>Only the decorative symbol is visible; the text remains in the DOM.
Syntax and mental model
For a noninteractive label, use absolute positioning, a 1px box, overflow hidden, clip-path: inset(50%), and white-space nowrap. Do not use display:none on the only name text expecting it to behave like visually hidden text. Hidden referenced labels can be a special accessible-name case. DOM reading and focus order should remain meaningful; flex order and grid placement change visual arrangement but do not normally reorder keyboard navigation.
Remove a box
<!doctype html><html lang="en"> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <title>CSS practice</title> <style> body { margin: 0; font: 16px sans-serif; color: #172033; background: white; } </style> </head> <body> <p id="a" hidden>Unavailable</p> </body></html>The hidden paragraph has no rendered box.
Common mistakes
Do not put focusable controls inside a permanently visually hidden box. A skip link needs a visible focused state. opacity:0 is not a way to remove focus.
Practice and next steps
After trying the examples, complete the linked coding exercise and review questions. Predict the result before running your code. Prerequisite: Reflow, zoom and text spacing. Next lesson: Preferences and forced colors.
Check Your Understanding
Solidify your learning with the interactive assessment directly below this lesson.
Concept Quiz & Questions
Visual hiding and reading order — knowledge check
Five questions on visual hiding and reading order.
Which approach preserves the label text while clipping its box?
What does opacity:0 alone leave possible?
What should a focused skip link do?
Does flex order normally change Tab order?
How should an icon-only button be named?