Set an Element's Visibility
By Stephen Bucaro
Use the visibility property to set whether an element is visible. To make
an element invisible, set visibility: hidden;. To make an element visible
(the default), set visibility: visible;.
<span style="visibility:hidden">This text would not be visible</span>
• The hidden element still takes up space on the webpage.
For example the code shown above is used to place a span
This text would not be visible
between these two lines, it takes up space, but it's not visible.
• You might use Java Script to dynmically change an element's visibility.
For example, use the onclick event of one element to show and hide another element.
Optionally, you can use the display property to set whether an element is
visible. To make an element invisible, set display: none;. To make an element
visible, set display: inline; or display: block;.
<span style="display:none">This text would not be visible</span>
• You might use Java Script to dynmically change an element's display property.
For example, use the onclick event of one element to change another element's display
property from block and none.
• An element with display:none; takes up no space on the webpage.
For example the code shown above is used to place a span
This text would not be visible
between these two lines, it's not visible and takes up no space.
• The display property is usually used to define the type of
box an element creates, for example display: inline creates an element that "flows"
into position along with the other elements on the webpage, display: block creates an
element that is positioned relative or absolute to its parent container element.
More CSS Quick Reference: • position:relative • Set a Background Image • Pseudo-class Selectors • Set the Text Alignment • Set a Background Image's Position • Use an Embedded Style Sheet • Context selectors • Set the Text Decoration • Set the box-sizing Property • How to Define and Apply a Style Class
|