The visibility property shows or hides an element. With hidden, the box is not drawn but still occupies layout space. Neighbors do not slide into the gap.
To hide an element and remove its space, use display: none instead. The property is inherited. The initial value is visible.
Baseline · Widely available.
Not deprecated. hidden also removes the element from the accessibility tree and from keyboard focus.
Experimental:
force-hidden appears in newer CSS Display drafts (hide ancestors so children cannot re-show). Skip it for production until browsers ship it as a CSS value.
Target the row.visibility: collapse on tr hides Row 2.
Space drops. Unlike hidden, the row’s height is removed from the table.
Sizing can stay. Other columns may still size as if those cells existed.
Not for every box. On a normal div, collapse usually acts like hidden.
Edge Cases & Pitfalls
If hide/show behaves oddly, one of these is usually why.
display
Do not confuse with display: none
hidden keeps space. display: none removes the box from flow.
a11y
Hidden leaves the accessibility tree
Screen readers skip visibility: hidden content, and the element cannot receive focus.
opacity
Different from opacity: 0
opacity: 0 can still receive pointer events unless you also disable them. hidden is not interactive.
collapse
collapse quirks outside tables
On most non-table elements it matches hidden. Flex/ruby collapse behavior is incomplete in some engines.
child
Children can reappear
A visible descendant shows again inside a hidden ancestor. That does not work with display: none.
Compatibility
Browser Support
visibility is a browser CSS property for showing and hiding boxes. Node.js, Deno, and Bun do not apply it.
✓ Baseline · Widely available
visibility
Supported in all major browsers for many years (Chrome 1+, Firefox 1+, Safari 1+, Edge 12+, IE 4+).
97%Global support
Google Chrome1+
Full support
Mozilla Firefox1+
Full support
Apple Safari1+
Full support
Microsoft Edge12+
Full support
Opera4+
Full support
Samsung Internet1+
Full support
Internet Explorer4+
Full support
visibilityWidely supported
Bottom line: Safe everywhere for visible/hidden. Prefer collapse mainly for table rows and columns. This is not a JavaScript runtime API.
Remember
Key Takeaways
Role: show or hide without removing layout space when using hidden.
vs display:none removes the box; hidden leaves a gap.
Inherited. A child can set visible inside a hidden parent.
collapse: best understood on table rows and columns.
One line:visibility: hidden makes a box invisible but still present in the layout.
Frequently Asked Questions
It shows or hides an element without removing it from document flow when you use hidden. The box is not painted, but it still takes up layout space.
hidden keeps the element’s space so neighbors do not move. display: none removes the box from layout, so content reflows into that space.
The initial value is visible.
Yes. A child can override a hidden ancestor by setting visibility: visible, which makes that child show again.
On table rows, columns, and groups it hides them and removes their space while still using their sizes for table layout. On most other elements it behaves like hidden.
It is Baseline Widely available and supported in all major browsers, including Internet Explorer. It is a browser CSS property, not a Node.js feature.