Want to share your CSS expertise with others? Apply to the MDN Fellowship by April 1! http://mzl.la/MDNFellowship

mozilla

Revision 24583 of visibility

  • Revision slug: CSS/visibility
  • Revision title: visibility
  • Revision id: 24583
  • Created:
  • Creator: Jürgen Jeka
  • Is current revision? No
  • Comment no wording changes

Revision Content

{{ CSSRef() }}

Summary

The visibility CSS property is used for two things:

  1. The hidden value hides an element but leaves space where it would have been.
  2. The collapse value hides rows or columns of a table. It also collapses XUL elements.
  • {{ Xref_cssinitial() }}: {{ Cssxref("visible") }}
  • Applies to: All elements
  • {{ Xref_cssinherited() }}: Yes
  • Media: {{ Xref_cssvisual() }}
  • {{ Xref_csscomputed() }}: As specified

Syntax

visibility:  visible | hidden | collapse | {{ Cssxref("inherit") }}

Values

visible
Default value, the box is visible.
hidden
The box is invisible (fully transparent, nothing is drawn), but still affects layout.  Descendants of the element will be visible if they have visibility:visible (this doesn't work in IE up to version 7).
collapse
For table rows, columns, column groups, and row groups the row(s) or column(s) are hidden and the space they would have occupied is (as if {{ Cssxref("display") }}: none 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 XUL elements, the computed size of the element is always zero, regardless of other styles that would normally affect the size, although margins still take effect. For other elements, collapse is treated the same as hidden.

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 */

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.

Browser compatibility

Browser Lowest version
Internet Explorer 4.0
Firefox (Gecko) 1.0 (1.0)
Opera 4.0
Safari (WebKit) 1.0 (85)

Specifications

See also

{{ Cssxref("display") }}

{{ languages( { "fr": "fr/CSS/visibility", "pl": "pl/Dokumentacja_CSS/W\u0142asno\u015bci_szablonu", "zh-cn": "cn/CSS/visibility" } ) }}

Revision Source

<p>{{ CSSRef() }}</p>
<h3>Summary</h3>
<p>The<code> visibility </code>CSS property is used for two things:</p>
<ol> <li>The<code> hidden </code>value hides an element but leaves space where it would have been.</li> <li>The<code> collapse </code>value hides rows or columns of a table. It also collapses XUL elements.</li>
</ol>
<ul> <li>{{ Xref_cssinitial() }}: {{ Cssxref("visible") }}</li> <li>Applies to: All elements</li> <li>{{ Xref_cssinherited() }}: Yes</li> <li>Media: {{ Xref_cssvisual() }}</li> <li>{{ Xref_csscomputed() }}: As specified</li>
</ul>
<h3>Syntax</h3>
<pre class="eval">visibility:  visible | hidden | collapse | {{ Cssxref("inherit") }}
</pre>
<h3>Values</h3>
<dl> <dt>visible</dt> <dd>Default value, the box is visible.</dd> <dt>hidden</dt> <dd>The box is invisible (fully transparent, nothing is drawn), but still affects layout.  Descendants of the element will be visible if they have<code> visibility:visible </code>(this doesn't work in IE up to version 7).</dd> <dt>collapse</dt> <dd>For table rows, columns, column groups, and row groups the row(s) or column(s) are hidden and the space they would have occupied is (as if <code>{{ Cssxref("display") }}: none</code> 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 XUL elements, the computed size of the element is always zero, regardless of other styles that would normally affect the size, although margins still take effect. For other elements, <code>collapse</code> is treated the same as <code>hidden</code>.</dd>
</dl>
<h3>Examples</h3>
<pre>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 */
</pre>
<h3>Notes</h3>
<p>The support for<code> visibility:collapse </code>is missing or partially incorrect in some modern browsers. In many cases it may not be correctly treated like<code> visibility:hidden </code>on elements other than table rows and columns.</p>
<p><code>visibility:collapse </code>may change the layout of a table if the table has nested tables within the cells that are collapsed, unless<code> visibility:visible </code>is specified explicitly on nested tables.</p>
<h3>Browser compatibility</h3>
<table class="standard-table"> <tbody> <tr> <th>Browser</th> <th>Lowest version</th> </tr> <tr> <td>Internet Explorer</td> <td>4.0</td> </tr> <tr> <td>Firefox (Gecko)</td> <td>1.0 (1.0)</td> </tr> <tr> <td>Opera</td> <td>4.0</td> </tr> <tr> <td>Safari (WebKit)</td> <td>1.0 (85)</td> </tr> </tbody>
</table>
<h3>Specifications</h3>
<ul> <li><a class="external" href="http://www.w3.org/TR/CSS21/visufx.html#visibility">CSS 2.1 Visual effects #visibility</a></li>
</ul>
<h3>See also</h3>
<p>{{ Cssxref("display") }}</p>
<p>{{ languages( { "fr": "fr/CSS/visibility", "pl": "pl/Dokumentacja_CSS/W\u0142asno\u015bci_szablonu", "zh-cn": "cn/CSS/visibility" } ) }}</p>
Revert to this revision