Home HTML/CSS CSS: The Difference Between Display and Visibility Property?
Author:

When you want to hide an element on a website, you have the option to use the property display or visibility in CSS.

But do you know what are the different between them and which one to use? Display will make an element disappear while visibility hide an element and it still take up the space on the webpage.

Here is an example of the difference:

display

visibility

display:none

display:none hides an element, and it will not take up any space. The element will be hidden, and the page will be displayed as the element is not there.

visibility:hidden

visibility:hidden hides an element, but it will still take up the same space of the page. The element will be hidden, but still affect the layout.

Did you like this tip?



Comments (0)
Write comment
Your Contact Details:
Comment:
Security
Please input the anti-spam code that you can read in the image.

"