If the visibility property of the style of an HTML element is set to hidden, is it still clickable?
Only if its children override the visibility.
CSS visibility
does not forcefully apply to all children. Suppose you have a dialog box (my use case) that uses visibility:hidden
. If anything inside that dialog box uses visibility:visible
it will "break through" the parent and allow events.
The foolproof way is to create a new stacking context and shrink it to 0. Using transform
is a simple way without having to cause a layout reflow (eg: max-height
).
visibility: hidden;
transform: scale(0);
<div style="visibility:hidden">
<input style="visibility:visible" value="Visible child">
</div>
<div style="visibility:hidden;transform:scale(0)">
<input style="visibility:visible" value="Visible Child">
</div>
<div style="visibility:hidden">
<input style="visibility:visible;opacity:0" value="Transparent Child">
</div>
<div>
<input value="Normal">
</div>
It'll still take up the same space it normally would, but click events won't trigger, nor will the cursor change. That says nothing about keyboard Tab
though...