Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why do Bootstrap tabs have role="presentation"?

Tags:

I'm working on a design system that's extending from the Bootstrap framework. One of the key goals is accessibility. When implementing Bootstrap tabs I see that they apply role="presentation" to the list items in their nav list.

So I put together a little chunk of test HTML from the Bootstrap template:

<ul class="nav nav-tabs">   <li role="presentation" class="active"><a href="#">Home</a></li>   <li role="presentation"><a href="#">Profile</a></li>   <li role="presentation"><a href="#">Messages</a></li> </ul>  <ul class="nav nav-tabs">   <li class="active"><a href="#">Home</a></li>   <li><a href="#">Profile</a></li>   <li><a href="#">Messages</a></li> </ul> 

The ARIA spec says that presentation is a role for which:

The intended use is when an element is used to change the look of the page but does not have all the functional, interactive, or structural relevance implied by the element type,

It seems to me that the <li> elements have a structural relevance to someone using an accessibility device as they tell you how many tabs are present. If you were to discover, for example, that the third tab held the information you were interested in, navigating to the list and knowing there are three tabs would let you get to what you want more quickly.

Also, when accessing that test HTML with ChromeVox, the lists are announced identically. So it seems that the role doesn't have any practical effect.

I've Googled this question, but haven't found any discussion of it. So, does anyone know why this is part of the Bootstrap framework?

like image 796
theJBRU Avatar asked Jun 24 '15 13:06

theJBRU


People also ask

Why do we use role presentation?

Presentational roles are used when elements need to be in the DOM, but the semantics of them are inaccurate or unnecessary. We're basically telling a screen reader that the semantics of an element are wrong, so ignore them. Which is why the example <table role="presentation"> is often used to present it to the world.

How do Bootstrap tabs work?

Bootstrap tabs separate data in the same wrappers but different panes. Pills are components placed in pages to speed up browsing. Also, the first step of adding links inside navbar is to apply <ul> element together with class="navbar-nav".

What are tabs in Bootstrap?

Bootstrap 5 Tabs component. Tabs are quasi-navigation components which can highly improve website clarity and increase user experience.

What is NAV item in Bootstrap?

Navigation available in Bootstrap share general markup and styles, from the base . nav class to the active and disabled states. Swap modifier classes to switch between each style. The base . nav component is built with flexbox and provide a strong foundation for building all types of navigation components.


1 Answers

See the write up about accessible tabs by Marco at https://www.marcozehe.de/2013/02/02/advanced-aria-tip-1-tabs-in-web-apps/

His implementation has role="presentation" on the li to indicate "that the screen reader should ignore the list items themselves" and then adds the "tab" role on the links "mapping the roles to the intended screen-reader recognizable element type."

One point that was made in an issue in the bootstrap accessibility project (https://github.com/paypal/bootstrap-accessibility-plugin/issues/59) is that (right or wrong) tabs are fairly commonly used as navigation so it would be inappropriate to always include the roles tablist and tab. As Marco's article notes: "There are many circumstances where tabs are not the appropriate semantics."

BTW our job isn't made any easier by the fact that individual combinations of screen readers and browsers fail to support this in the same way. (See this article for a write up on that: http://john.foliot.ca/aria-hidden/)

like image 57
peater Avatar answered Oct 01 '22 08:10

peater