CSS Visibility
Anonymous contributor
Published Jul 13, 2021Updated Feb 5, 2024
Contribute to Docs
The visibility property shows or hides an element. If the element is hidden, it will still take up space within the page.
Syntax
visibility: <value>;
The visibility property has three values.
visible: Shows the element.hidden: Hides the element.collapse: Hides both the element and the space it would have occupied.
Note: collapse should only be used with <table> rows, row groups, columns, and column groups. If collapse is used on other elements, it will be treated the same as hidden. Implementing collapse within a <table> can be especially useful because it allows for hiding rows or columns without affecting the table layout.
Example 1
Hiding an element with a class of hide.
.hide {visibility: hidden;}
Example 2
Hiding a <tr> element within a table.
tr {visibility: collapse;}
Contribute to Docs
- Learn more about how to get involved.
- Edit this page on GitHub to fix an error or make an improvement.
- Submit feedback to let us know how we can improve Docs.
Learn CSS on Codecademy
- Front-end engineers work closely with designers to make websites beautiful, functional, and fast.
- Includes 34 Courses
- With Professional Certification
- Beginner Friendly.115 hours
- A full-stack engineer can get a project done from start to finish, back-end to front-end.
- Includes 51 Courses
- With Professional Certification
- Beginner Friendly.150 hours