English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
The visibility attribute specifies whether an element is visible.
The following table provides usage instructions and version history of this attribute, as well as the syntax of its usage in JavaScript scripts.
Default value: | visible |
---|---|
Applies to: | All elements |
Inheritance: | Yes |
Animatable: | Yes.Please refer to Animation properties. |
Version: | CSS 2、3 |
JavaScript syntax: | object.style.visibility="hidden" |
The syntax of this attribute is as follows:
visibility: visible | hidden | collapse | initial | inherit
The following example demonstrates how to use the visibility attribute.
p { visibility: hidden; } div { visibility: hidden; }Test to see‹/›
The following table describes the values of this attribute.
Value | Description |
---|---|
visible | The box and its content are visible. This is the default value. |
hidden | The box and its content are invisible but still affect the page layout. |
collapse | Only applies to some internal table objects: rows, row groups, columns, and column groups. It deletes the object but does not affect the table layout in any other way. The space occupied by the table object will be filled by the subsequent same-level objects. If collapse is specified for other elements, its behavior is the same as hidden. |
initial | Set this attribute to its default value. |
inherit | If specified, the associated elements adopt the visibility attribute value of their parent element. |
The compatibility of visibility attribute in browsers, the numbers in the following table represent the minimum version number of browsers that support this attribute; all mainstream browsers support this attribute.
|
Please refer to the following tutorials:CSS visibility,CSS display.
Related properties:display.