Computer >> Computer tutorials >  >> Programming >> CSS

Usage of CSS visibility property


A property called visibility allows you to hide an element from view. You can use this property along with JavaScript to create very complex menu and very complex webpage layouts.

The visibility property can take the values listed in the table that follows

Value
Description
visible
The box and its contents are shown to the user.
hidden
The box and its content are made invisible, although they still affect the layout of the page.
collapse
This is for use only with dynamic table columns and row effects.

Example

You can try to run the following code to learn how to work with visible and hidden values

<html>
   <head>
      <style>
         p {
            visibility: hidden;
         }
      </style>
   </head>
   <body>
      <p style = "visibility:visible;">
         This paragraph is visible.
      </p>
      <p>
         This paragraph won't be visible.
      </p>
   </body>
</html>