How to hide an element in CSS?
You can hide an element in three main ways.
.a { display: none; } /* hidden, no space */
.b { visibility: hidden; } /* hidden, space stays */
.c { opacity: 0; } /* invisible, space stays, still clickable */
Use display: none to remove it completely. Note that screen readers also ignore an element with display: none. See display none vs visibility hidden.
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 |