What is the difference between display none and visibility hidden?
Both hide an element, but they treat the space differently.
| Rule | Visible | Space in layout |
|---|---|---|
display: none | No | Removed. Other elements move up |
visibility: hidden | No | Kept as an empty gap |
opacity: 0 | No (but still clickable) | Kept |
.a { display: none; }
.b { visibility: hidden; }
See the display property.
Learn more about the similar topics:
| Tutorials |
|---|
| CSS Layout – The display Property |
| CSS Position Property |
| CSS z-index |
| CSS Float and Clear Property |
| Exercises & Assignments |
|---|
| Write CSS to centre a box horizontally using margin auto |
| Write CSS to create a horizontal navigation menu |