Is it OK to hide an item using `opacity`, `pointer-events`, `aria-hidden` and `tabindex` ?

Can you hide an item using opacity: 0 + pointer-events: none + aria-hidden="true" + tabindex="-1" instead of using display: none or the hidden attribute ? Specifically in the context of accessible tabs: https://youtu.be/fI9VM5zzpu8
Kevin Powell
YouTube
Create Accessible Tabs with HTML, CSS & JS
Creating tabs takes a bit of work, and making sure they’re accessible can be a little tricky. First, you should ask if you even need tabs in the first place, but assuming you do, this video looks at creating some progressively enhanced tabs. 🔗 Links ✅ The finished code: https://codepen.io/kevinpowell/pen/oNQgRKm ✅ Accessibility guidelines for ...
9 Replies
ἔρως
ἔρως2w ago
no, that's not enough depending on the use, throw it outside the viewport with position absolute and a clip-path to hide it
ne3zy
ne3zyOP2w ago
Why wouldn't that be enough ?
ἔρως
ἔρως2w ago
because it takes space anyways
ne3zy
ne3zyOP2w ago
In my case I want it to take space, I'm stacking every panel over each other using grid grid-row: 1/-1; grid-column: 1/-1; This way the document doesn't shift height even if one panel is taller than another
ἔρως
ἔρως2w ago
then use visibility: hidden instead
ne3zy
ne3zyOP2w ago
Nice I didn't know about this property, should I just use visibility: hidden or do I need to mix it with tabindex="-1", etc ?
ἔρως
ἔρως2w ago
i would mix it too opacity alone doesn't work since the stuff is still there, but had a different color
ne3zy
ne3zyOP2w ago
thanks
ἔρως
ἔρως2w ago
you're welcome

Did you find this page helpful?