Name

visibility — NN 4 IE 4 CSS 2

Synopsis

Inherited: Sometimes

For positioned elements, controls whether the element is rendered on the page. An element hidden via the visibility attribute preserves space in the document where the element normally appears. If you prefer surrounding content to cinch up the space left by a hidden element, see the display attribute.

The visibility attribute is inherited when its value is set to inherit. This setting means that if the parent is hidden, the child is also hidden. But, by setting the child’s visibility attribute to visible, you can still keep the parent hidden while showing the child independently.

CSS Syntax

visibility: visibilityType

JavaScript Equivalent

visibility

Value

Navigator 4 features a set of constants that don’t always match those of Internet Explorer 4 and CSS, but Navigator 4 does recognize the CSS standards:

Value

NN 4

IE 4

CSS2

hide

•

-

-

hidden

•

•

•

inherit

•

•

•

show

•

-

-

visible

•

•

•

Use the CSS attribute constants to maintain cross-browser compatibility. There have been reports of Navigator 4 not responding properly to the CSS values when scripting an element’s visibility. For dynamically changing visibility of a positioned element, you might feel safer with some of the cross-browser API strategies detailed in Chapter 4.

Initial Value

inherit

Example

#congrats {visibility: hidden}

Applies To

All elements whose position style attribute is set.

Object ...

Get Dynamic HTML: The Definitive Reference now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.