Recently, I saw some tricks on hiding things. What I'm curious about is what's the difference between clip: rect(0, 0, 0, 0); and visibility: hidden;, while both can hide things and remain the space in the same time.
Also, is there any difference between using clip: rect(0, 0, 0, 0); and clip: rect(1px, 1px, 1px, 1px);?
Visually, a
clipped element is collapsed, just like an element withdisplay: noneis.visibility: hiddenon the other hand reserves the space the element would normally use.In other words, comparing
clipandvisibilityis very much apples to oranges, you should be comparingclipanddisplay.I guess one reason to use one or the other is accessibility:
visibility: hiddenhides content from screenreaders.display: nonehides content from screenreaders.clip: rect(0,0,0,0); position: absolutekeeps content visible to screenreaders.Compatibility: MDN marks
clipas deprecated, withclip-pathbeing the newer replacement.