The difference between Display:none and Visibility:hidden in CSS

Source: Internet
Author: User


Difference Analysis

First of all, we all know that Display:none and Visibility:hidden can play the role of hiding elements.

The difference between the two is that the document flow is occupied

Display:none hidden elements while removing the space occupied by the elements in the document flow

Visibility:hidden hide elements without removing the space occupied by the elements in the document flow

Examples of differences

HTML Code

<span class= "One" > First area </span>
<span> Second Area </span>
<br/><br/>
<span class= "Three" > Third area </span>
<span> Fourth Area </span>

CSS Code

span {
Background-color:black;
padding:5px;
Color: #fff;
}
. One {
Display:none;
}
. Three {
Visibility:hidden;
}

From the image above, you can see

Using the first area of Display:none, the document stream has not been occupied in the current HTML

Use the third area of Visibility:hidden and still occupy the document stream
Results diagram

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: info-contact@alibabacloud.com 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.