Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

HTML DOM Style visibility property

Style visibility property

Style Object Reference The Style object


Definition and Usage

The visibility property sets whether an element should be visible.

The visibility property allows the author to show or hide an element. It is similar to the display property. However, the difference is that if you set display:none, the entire element will be hidden, whereas if you set visibility:hidden, the element's content will be invisible but the element still retains its original position and size.

Syntax

Set the visibility property:

Object.style.visibility="visible|hidden|collapse|inherit"

Return the visibility property:

Object.style.visibility

Value Description
visible Default. The element is visible.
hidden The element is invisible but still affects the layout.
collapse When used in a table row or cell, the element is invisible (same as "hidden").
inherit The value of the visibility property is inherited from the parent element.

Browser support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support the visibility property.

**Note:** IE7 and earlier versions do not support the "inherit" value. IE8 supports "inherit" only if a !DOCTYPE is specified. IE9 supports "inherit".


Example

Example

Hide the content of an element:

Runoob Tutorial(runoob.com)

This is some text.

This is some text.

Try it »


Style Object Reference The Style object