CSS:visibility
From MDC
« CSS « CSS Reference
[edit] Summary
The visibility property is used for two things:
- The
hiddenvalue hides an element but leaves space where it would have been. - The
collapsevalue hides rows or columns of a table.
- Initial value:
visible - Applies to: All elements
- Inherited: Yes
- Percentages: N/A
- Media:
visual - Computed value: As specified
[edit] Syntax
visibility: visible | hidden | collapse | inherit
[edit] Values
-
visible - The element is displayed normally.
-
hidden - The element is hidden, but other elements are positioned as though it were present. This acts like the element is fully transparent. Note that descendants with
visibility: visiblecan be visible again. -
collapse - For table rows, table columns, table column groups, and table row groups, the row(s) or column(s) are hidden and the space they would have occupied is (as if
were applied to the column/row of the table). However, the size of other rows and columns is still calculated as though the cells in the collapsed row(s) or column(s) are present. This was designed for for fast removal of a row/column from a table without having to recalculate widths and heights for every portion of the table. (For other elements,display: nonecollapseis treated the same ashidden.)
[edit] Examples
p { visibility: hidden; } /* paragraphs won't be visible */
p.showme { visibility: visible; } /* except of these with class showme */
tr.col { visibility: collapse; } /* table rows with class col will collapse */
[edit] Notes
The support for visibility: collapse is missing or partially incorrect in some modern browsers. In many cases it may not be correctly treated like visibility: hidden on elements other than table rows and columns.
visibility:collapse may change the layout of a table if the table has nested tables within the cells that are collapsed, unless visibility: visible is specified explicitly on nested tables.