DEV Community

Deepak Yadav
Deepak Yadav

Posted on

2 2

Display: none Vs Visibility: hidden

Coding is all about practical knowledge, so let's understand difference between display: none; and visibility: hidden; property practically 😍😍.

👀My GitHub
👀My Insta

step:1 Let's make three circle with different color i.e. Red, Green, and Blue.

Main img

Step:2

Now apply display: none; property to Green color circle

#green{
    display: none;
}
Enter fullscreen mode Exit fullscreen mode

display: none; img

display: none; means that the tag will not appear on the page at all (although you can still interact with it through the Dom). There will be no space allocated for it between the other tags.

Step:3

Now apply visibility: hidden; property to green color circle

#green{
    visibility: hidden;
}
Enter fullscreen mode Exit fullscreen mode

visibility: hidden; img

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.

Hopefully you find this useful.
Share your thoughts in comment section 👇.

Sentry blog image

How I fixed 20 seconds of lag for every user in just 20 minutes.

Our AI agent was running 10-20 seconds slower than it should, impacting both our own developers and our early adopters. See how I used Sentry Profiling to fix it in record time.

Read more

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay