I have a div tag with some content getting loaded inside it. The content inside can have buttons, anchor elements, etc. which are focusable. I do not have control over the content but I can modify the 'div' tag attributes.
My problem is the focus still goes to the content (anchor, buttons, etc.) even if I specify the tabIndex -1 to the div tag.
Is there a way to skip the entire content while tabbing ? It's certainly not working with the above code.
Not sure why nobody has mentioned visibility: hidden
yet. Setting display: none
can in some cases mess up logic when dealing with dimensions of non-visual elements. visibility
will persist the dimensions just like opacity: 0
would do, but also disable any tabbable children.
Example:
<div style="visibility: hidden;">
<a href="#">I'm only tabbable if my parent is visible!</a>
</div>