Which one is best optimized code display:none or visibility:hidden as per the performance?
.className{
display: none;
}
.className{
visibility: hidden;
}
Which one is best optimized code display:none or visibility:hidden as per the performance?
.className{
display: none;
}
.className{
visibility: hidden;
}
visibility:hidden would be the more efficient as it does not change the flow of the DOM, reducing the amount of redraws.
Switching an element's display property would cause greater redrawing as space isn't allocated for the element. This would occur most with stacked elements.
It depends on the requirement..if you want to show the element when user interact with the page then visibility:hidden can be useful otherwise display:none is useful.
visibility:hidden takes the space provided to it though it is not visible but display:none remove the space and allow other element to take the space.
I think display:none is that property which makes tag not to appear on the page but space is not allocated.
And visibility:hidden is that property which makes the tag not visible but space is allocated.