Revision 236888 of visibility

  • Revision slug: CSS/visibility
  • Revision title: visibility
  • Revision id: 236888
  • Created:
  • Creator: teoli
  • Is current revision? No
  • Comment

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.
<style type="text/css"></style>
  • {{ 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 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

{{ CompatibilityTable() }}

Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari
Basic support 1.0 {{ CompatGeckoDesktop("1") }} 4.0 4.0 1.0
Feature Android Chrome for Android Firefox Mobile (Gecko) IE Mobile Opera Mobile Safari Mobile
Basic support 1.0 1.0 {{ CompatGeckoMobile("1") }} 6.0 6.0 1.0

Specifications

See also

  • {{ CSS_Reference:Position() }}

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

</nobr>

Revision Source

<p>{{ CSSRef() }}</p>
<h2 id="Summary">Summary</h2>
<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>
<nobr>
<style type="text/css"><![CDATA[.cssprop {
  display:table;
  padding: 0.4em;
  border-left:0.15em solid;
  background-color:#eeeeff
}
.cssprop li {
 display:table-row;
 padding: 3px;
 margin:0;
}
.cssprop li dfn {
  display:table-cell;
  padding: 0 5px;
  border-bottom: none;
  cursor:inherit;
}

]]></style>
<ul class="cssprop"> <li><dfn>{{ Xref_cssinitial() }}:</dfn> {{ Cssxref("visible") }}</li> <li><dfn>Applies to:</dfn> All elements</li> <li><dfn>{{ Xref_cssinherited() }}:</dfn> Yes</li> <li><dfn>Media:</dfn> {{ Xref_cssvisual() }}</li> <li><dfn>{{ Xref_csscomputed() }}:</dfn> As specified</li>
</ul>
<h2 id="Syntax">Syntax</h2>
<pre class="eval">visibility:  visible | hidden | collapse | {{ Cssxref("inherit") }}
</pre>
<h3 id="Values">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 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 id="Examples">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>
<h2 id="Notes">Notes</h2>
<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>
<h2 id="Browser_compatibility">Browser compatibility</h2>
<p>{{ CompatibilityTable() }}</p>
<div id="compat-desktop"> <table class="compat-table"> <tbody> <tr> <th>Feature</th> <th>Chrome</th> <th>Firefox (Gecko)</th> <th>Internet Explorer</th> <th>Opera</th> <th>Safari</th> </tr> <tr> <td>Basic support</td> <td>1.0</td> <td>{{ CompatGeckoDesktop("1") }}</td> <td>4.0</td> <td>4.0</td> <td>1.0</td> </tr> </tbody> </table>
</div>
<div id="compat-mobile"> <table class="compat-table"> <tbody> <tr> <th>Feature</th> <th>Android</th> <th>Chrome for Android</th> <th>Firefox Mobile (Gecko)</th> <th>IE Mobile</th> <th>Opera Mobile</th> <th>Safari Mobile</th> </tr> <tr> <td>Basic support</td> <td>1.0</td> <td>1.0</td> <td>{{ CompatGeckoMobile("1") }}</td> <td>6.0</td> <td>6.0</td> <td>1.0</td> </tr> </tbody> </table>
</div>
<h2 id="Specifications">Specifications</h2>
<ul> <li><a class="external" href="http://www.w3.org/TR/CSS21/visufx.html#visibility">CSS 2.1 Visual effects #visibility</a></li>
</ul>
<h2 id="See_also">See also</h2>
<ul>
  <li>{{ CSS_Reference:Position() }}</li>
</ul>
<p>{{ languages( { "de": "de/CSS/visibility", "fr": "fr/CSS/visibility", "pl": "pl/Dokumentacja_CSS/W\u0142asno\u015bci_szablonu", "zh-cn": "cn/CSS/visibility" } ) }}</p>
<p>&lt;/nobr&gt;</p></nobr>
Revert to this revision