What is the difference between “display: none” and “visibility: hidden”, when used as attributes to the HTML element

What is the difference between “display: none” and “visibility: hidden”, when used as attributes to the HTML element.

1 Like

Answer:- When we use the attribute “visibility: hidden” for an HTML element then that element will be hidden from the webpage but still takes up space. Whereas, if we use the “display: none” attribute for an HTML element then the element will be hidden, and also it won’t take up any space on the webpage

1 Like

display:none means that the tag in question will not appear on the page at all. There will be no space allocated for it between the other tags.

visibility:hidden means that unlike display:none, the tag is not visible, but space is allocated for it on the page. The tag is rendered, it just isn’t seen on the page.

1 Like