I want to ensure that only the children of the main div
are able to receive focus, not the grandchildren.
Here is an example:
<div class="parent" >
<div class="child1" > <!-- should be focused-->
<div class="grandchild" ></div> <!-- shouldn't be focused-->
</div>
<div class="child2" > <!-- should be focused-->
<div class="grandchild" ></div> <!-- shouldn't be focused-->
</div>
<div class="child3" > <!-- should be focused-->
<div class="grandchild" ></div> <!-- shouldn't be focused-->
</div>
<div class="child4" > <!-- should be focused-->
<div class="grandchild" ></div> <!-- shouldn't be focused-->
</div>
<div class="child5" > <!-- should be focused-->
<div class="grandchild" ></div> <!-- shouldn't be focused-->
<!-- more divs-->
</div>
</div>
Can this be achieved using only HTML and CSS?
If I use tabindex=0
on the parent div, will it make all the children focusable? Or do I have to individually assign a tabindex
to each child?
Navigating with the tab key on a keyboard