visibility: hidden;. What will you see in the browser?<style>div { width: 100px; height: 100px; background: red; visibility: hidden; }</style><div></div>When visibility is set to hidden, the element is not visible but still occupies space in the layout. This differs from display: none; which removes the element from the layout.
visibility: hidden; hides the element but keeps its space. display: none; removes it from the layout. opacity: 0; makes it transparent but still visible to events. position: absolute; left: -9999px; moves it off-screen but does not reserve space.
<style>p { visibility: collapse; border: 1px solid black; }</style><p>Hello</p>visibility: collapse; behaves on block elements.visibility: collapse; on non-table elements like p behaves the same as visibility: hidden;: the element is invisible but still occupies space in the layout. It only collapses space like display: none; for table rows, row groups, columns, and column groups.
CSS does not support :visible pseudo-class. Using :where(:not([style*='visibility: hidden'])) is a valid way to select elements without inline visibility: hidden. Option D is similar but :where has lower specificity, making it better for overrides.
visibility: hidden; affect screen readers?visibility: hidden;, what is the expected behavior for screen readers?Elements with visibility: hidden; are hidden visually but remain accessible to screen readers, which will read their content aloud. To hide from assistive technologies, use display: none; or aria-hidden="true".