
- CSS - Home
- CSS - Roadmap
- CSS - Introduction
- CSS - Syntax
- CSS - Inclusion
- CSS - Types
- CSS - Measurement Units
- CSS - Selectors
- CSS - Colors
- CSS - Backgrounds
- CSS - Fonts
- CSS - Text
- CSS - Images
- CSS - Links
- CSS - Tables
- CSS - Borders
- CSS - Border Block
- CSS - Border Inline
- CSS - Margins
- CSS - Lists
- CSS - Padding
- CSS - Cursor
- CSS - Outlines
- CSS - Dimension
- CSS - Scrollbars
- CSS - Inline Block
- CSS - Dropdowns
- CSS - Visibility
- CSS - Overflow
- CSS - Clearfix
- CSS - Float
- CSS - Arrows
- CSS - Resize
- CSS - Quotes
- CSS - Order
- CSS - Position
- CSS - Hyphens
- CSS - Hover
- CSS - Display
- CSS - Focus
- CSS - Zoom
- CSS - Translate
- CSS - Height
- CSS - Hyphenate Character
- CSS - Width
- CSS - Opacity
- CSS - Z-Index
- CSS - Bottom
- CSS - Navbar
- CSS - Overlay
- CSS - Forms
- CSS - Align
- CSS - Icons
- CSS - Image Gallery
- CSS - Comments
- CSS - Loaders
- CSS - Attr Selectors
- CSS - Combinators
- CSS - Root
- CSS - Box Model
- CSS - Counters
- CSS - Clip
- CSS - Writing Mode
- CSS - Unicode-bidi
- CSS - min-content
- CSS - All
- CSS - Inset
- CSS - Isolation
- CSS - Overscroll
- CSS - Justify Items
- CSS - Justify Self
- CSS - Tab Size
- CSS - Pointer Events
- CSS - Place Content
- CSS - Place Items
- CSS - Place Self
- CSS - Max Block Size
- CSS - Min Block Size
- CSS - Mix Blend Mode
- CSS - Max Inline Size
- CSS - Min Inline Size
- CSS - Offset
- CSS - Accent Color
- CSS - User Select
- CSS - Cascading
- CSS - Universal Selectors
- CSS - ID Selectors
- CSS - Group Selectors
- CSS - Class Selectors
- CSS - Child Selectors
- CSS - Element Selectors
- CSS - Descendant Selectors
- CSS - General Sibling Selectors
- CSS - Adjacent Sibling Selectors
- CSS Advanced
- CSS - Grid
- CSS - Grid Layout
- CSS - Flexbox
- CSS - Visibility
- CSS - Positioning
- CSS - Layers
- CSS - Pseudo Classes
- CSS - Pseudo Elements
- CSS - @ Rules
- CSS - Text Effects
- CSS - Paged Media
- CSS - Printing
- CSS - Layouts
- CSS - Validations
- CSS - Image Sprites
- CSS - Important
- CSS - Data Types
- CSS3 Advanced Features
- CSS - Rounded Corner
- CSS - Border Images
- CSS - Multi Background
- CSS - Color
- CSS - Gradients
- CSS - Box Shadow
- CSS - Box Decoration Break
- CSS - Caret Color
- CSS - Text Shadow
- CSS - Text
- CSS - 2d transform
- CSS - 3d transform
- CSS - Transition
- CSS - Animation
- CSS - Multi columns
- CSS - Box Sizing
- CSS - Tooltips
- CSS - Buttons
- CSS - Pagination
- CSS - Variables
- CSS - Media Queries
- CSS - Functions
- CSS - Math Functions
- CSS - Masking
- CSS - Shapes
- CSS - Style Images
- CSS - Specificity
- CSS - Custom Properties
- CSS Responsive
- CSS RWD - Introduction
- CSS RWD - Viewport
- CSS RWD - Grid View
- CSS RWD - Media Queries
- CSS RWD - Images
- CSS RWD - Videos
- CSS RWD - Frameworks
- CSS References
- CSS Interview Questions
- CSS Online Quiz
- CSS Online Test
- CSS Mock Test
- CSS - Quick Guide
- CSS - Cheatsheet
- CSS - Properties References
- CSS - Functions References
- CSS - Color References
- CSS - Web Browser References
- CSS - Web Safe Fonts
- CSS - Units
- CSS - Animation
- CSS Resources
- CSS - Useful Resources
- CSS - Discussion
CSS - visibility Property
The visibility Property
CSS visibility property allows you to show or hide an element without changing the layout of a document, while hidden elements take up space.
The visibility property can be used to create a variety of effects, such as hiding elements that are not yet ready to be displayed, or hiding elements that are only relevant to certain users.
Syntax
The syntax for the CSS visibility property is as follows:
visibility: visible | hidden | collapse | initial | inherit;
Possible Values
Value | Description |
---|---|
visible | It is the default value where the elements are visible. |
hidden | It hides the element, but it still takes up space on the page. |
collapse | It removes the table rows, columns, column groups, and row groups from a table. The collapse has the same meaning as hidden if it is used on non-table elements. |
initial | It sets the visibility of an element to its default value. |
inherit | It inherits the visibility property from its parent element. |
Applies to
The visibility property can be applied to all the HTML elements.
CSS visibility - visible Value
You can use the visibility property with visible to make an element visible.
Example
The following example uses the visibility property to make the h2 element visible.
<html> <head> <style> h2 { visibility: visible; } </style> </head> <body> <h2>Tutorials Point CSS visibility</h2> </body> </html>
Hide Elements with CSS visibility Property
To hide any HTML element, you can use the visibility property with the hidden value. It hides the element, but it does not remove it from the document layout. The element will still be accessible to screen readers and will affect the layout of the page, even though it is not visible.
Example
In this example, we have hidden the heading of the web page using 'visibility: hidden;'.
<html> <head> <style> h2 { visibility: hidden; } </style> </head> <body> <h2>Tutorials Point CSS visibility hidden</h2> <p>The hidden heading is still visible to screen readers and takes up space in the page.</p> </body> </html>
Collapse Table Cells with CSS visibility
To remove a table row, column, or any cell without affecting the layout of the table, you can set the visibility property of the row, column, or cell to collapse. This value is only valid for table elements.
Example 1
In this example, we have used the 'visibility: collapse;' property to collapse the table cell. You can use it to hide any row or column.
<html> <head> <style> .collapse { visibility: collapse; } table { border-collapse: collapse; color: #ffffff; width: 100%; background-color: #35DC5A; border: 2px solid black; } th, td { border: 2px solid black; padding: 8px; text-align: left; font-size: 20px; } </style> </head> <body> <table> <tr> <td>visible</td> <td>hidden</td> <td class="collapse">collapse</td> </tr> <tr> <td>initial</td> <td>inherit</td> <td>revert</td> </tr> </table> </body> </html>
Example 2
In this example, we have used the 'visibility: collapse;' property on a non-table element. On a non-table element, it works as hidden value.
<html> <head> <style> .collapse { visibility: collapse; } </style> </head> <body> <h2>Collapse on non-table elements</h2> <p class="collapse">you cant see me</p> <p>the above sentence is hidden</p> </body> </html>
Supported Browsers
Property | ![]() |
![]() |
![]() |
![]() |
![]() |
---|---|---|---|---|---|
visibility | 1.0 | 12.0 | 1.0 | 1.0 | 4.0 |