I'm trying to make our webpages more accessible and am confused about the tab order for push/pull sections.
Here is an example:
<section class="section">
<div class="container-fluid">
<div class="row">
<div class="col-md-6">
<a href="#" aria-label="Lorem ipsum" target="_blank"><img src="https://via.placeholder.com/770x560" alt="Image" /></a>
</div>
<div class="col-md-6">
<h3>Lorem ipsum</h3>
<p>Sed ut perspiciatis unde omnis iste natus</p>
<div class="btn">
<a href="#" role="button" tabindex="0" target="_blank">Lorem ipsum</a>
</div>
</div>
</div>
<div class="row">
<div class="col-md-6 col-md-push-6">
<a href="#" aria-label="Lorem ipsum" target="_blank"><img src="https://via.placeholder.com/770x560" alt="Image" /></a>
</div>
<div class="col-md-6 col-md-pull-6">
<h3>Lorem ipsum</h3>
<p>Sed ut perspiciatis unde omnis iste natus</p>
<div class="btn">
<a href="#" role="button" tabindex="0" target="_blank">Lorem ipsum</a>
</div>
</div>
</div>
</div>
</section>
When I tab through the row with push/pull, the image is focused first, and the button focused second even though it's displayed on desktop as button first and image second. I understand why it does this, but is this best practice for accessibility? Seems like it'd be confusing for the user. And if this is not best practice, how would I reverse the tab order? Would I need to go through the entire webpage and set tabindex="0", "1", "2"
, etc. for every focusable element?