The difference between css:opacity:0,visibility:hidden,display:none

Source: Internet
Author: User

When opacity=0,visibility=hidden,display=none in CSS, what is the difference between the three?

Referring to StackOverflow's blog, we found the difference as follows:

Here are a compilation of verified information from the various answers.

Each of the these CSS properties is in fact unique. In addition to rendering a element not visible, they has the following additional effect (s):

    1. collapses the space that element would normally occupy
    2. Responds to events (e.g., click, KeyPress)
    3. Participates in the taborder
                     Collapse Events taborderopacity:0              no     Yes     yesvisibility:hidden      no     no      novisibility: Collapse    *      no      nodisplay:none          Yes     no      no* yes inside a TABLE element, otherwise No.

---objects with Visibility:hidden still has shape, they just arent visible. Opacity zero elements can still is clicked and react to other events.

The summary is as follows:
1 opacity=0, the element is hidden, but does not change the page layout, and if the element has already bound some events, such as the Click event, then clicking on that area can also trigger the Click event
2 Visibility=hidden, the element is hidden, but does not change the page layout, but does not trigger an event that the element has already bound
3 Display=none, hide the element, and will change the layout of the page, it can be understood to delete the element in the page.


The difference between css:opacity:0,visibility:hidden,display:none

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.