Skip to content

Instantly share code, notes, and snippets.

@rikschennink
Last active December 6, 2016 14:59
Show Gist options
  • Save rikschennink/2ba2f232689ac1c65f049a92e6e148de to your computer and use it in GitHub Desktop.
Save rikschennink/2ba2f232689ac1c65f049a92e6e148de to your computer and use it in GitHub Desktop.
Pagination #a11y

Assumption: Next button is most clicked button in a pagination control.

The trap is to layout the HTML to match the design of the control. With the next button last and the previous button first.

By reformatting the HTML we can make things easier for everyone:

  • Visual users still see the classic paging (CSS takes care of that);
  • Tab focus for keyboard users is immidiately brought to next button, no need to tab over all pages;
  • Screenreader users have the same benefit and also hear which page is currently active;

Any suggestions on what more we could improve?

<nav role="navigation" aria-label="Pagination, currently on page 3">
<h1 class="implicit">Pagination</h1>
<a href="/">Next</a>
<a href="/">Previous</a>
<ul>
<li><a href="/">Page 1</a></li>
<li><a href="/">Page 2</a></li>
<li><a href="/">Page 3</a></li>
<li><a href="/">Page 4</a></li>
<li><a href="/">Page 5</a></li>
</ul>
</nav>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment