Copy link to clipboard
Copied
Hi,
I get a lot of these errors on W3 validation:
The aria-controls attribute must point to an element in the same document.
It relates to my tabbed panels - some missing connection between the tabs and the panels, but i am not sure what needs to be corrected? It is the same error on all pages/ tabbed panels.
<li class="nav-item"> <a class="nav-link" href="#pane6" role="tab" id="hatstab6" data-toggle="tab" aria-controls="hats">Intro to Philosophy</a></li>
The corresponding panel content is
<div role="tabpanel" class="tab-pane fade" id="pane6" aria-labelledby="hatstab6">
<br> <p class="panelcontent"><h6 class="panelh6">Intro to Philosophy</h6></p><br/>
Whatever you name the 'tab-pane' id should be what you name the 'aria-controls' and the href should also be named the same - Bootstrap js/jQuery uses this to find and open the correct tab-pane with the matching id.
Check out the default Bootstrap 4 code/documentation listed at the website:
<ul class="nav nav-tabs" id="myTab" role="tablist">
<li class="nav-item">
<a class="nav-link active" id="home-tab" data-toggle="tab" href="#home" role="tab" aria-controls="home" aria-selected="true">Home</a>
</li
Am I missing the point? The subject of this topic is
Aria controls error
how can you continue to ignore this issue?
The following is cited in the linked document that I quoted:
Note that navigation bars, even if visually styled as tabs with the .nav-tabs
class, should not be given role="tablist"
, role="tab"
or role="tabpanel"
attributes.
For a nore elaborate explanation: https://www.w3.org/TR/wai-aria-practices/examples/tabs/tabs-2/tabs.html
Copy link to clipboard
Copied
aria-controls="hats"
Should be:
aria-controls="pane6"
Same as your panel ID
Although 'hats' is probably more descriptive than 'pane6' so you could change your naming so its the other way around, then change <a href="#pane6'> to <a href="#hats">
Copy link to clipboard
Copied
Hi Ben,
Thank you for this - just to clarify - for both the tabs and the dropdown tabs - then do I change as follows (the code below is the original code, for reference):
For the second tab:
href changes to #hats, id changes to pane2
For the panel content correponding to the second tab:
id changed to pane2 and aria-labelled changes to pane2
<li class="nav-item"> <a class="nav-link" href="#paneTwo1" role="tab" id="hatstab1" data-toggle="tab" aria-controls="hats">Tab 2</a> </li>
<div role="tabpanel" class="tab-pane fade" id="paneTwo1" aria-labelledby="hatstab1">
<p>Content 2</p>
And for the drop down - let's say it's the THIRD dropdown tab pane, already having two previous dropdown panes before it:
in the li class, href remains as it is
in the div class, and the first <a class>, href changes to pane3dropdown1, id changes to dropdownshoestab3
in the second <a class>, href changes to pane3dropdown2, id changes to dropdownboots3
(if there was a 3rd class, href would change to pane3dropdown3, and id change to dropdownboots4?)
in the 1st corresponding tabcontent pane,
id changes to pane3dropdown1, aria-labelled by dropdownshoestab3
and for the 2nd corresponding dropdown pane,
id changes to pane3dropdown2, aria-labelled by dropdownbootstab3
(and a third dropdown pane
id changes to pane3dropdown3, aria-labelled by dropdownbootstab4 )?
<li class="nav-item dropdown"> <a class="nav-link dropdown-toggle" data-toggle="dropdown" href="#" role="button" aria-haspopup="true" aria-expanded="false"> Tab 3 Dropdown </a>
<div class="dropdown-menu"> <a class="dropdown-item" href="#tabDropDownOne1" role="tab" id="dropdownshoestab1" data-toggle="tab" aria-controls="dropdownShoes">Dropdown Link 1</a> <a class="dropdown-item" href="#tabDropDownTwo1" role="tab" id="dropdownbootstab1" data-toggle="tab" aria-controls="dropdownBoots">Dropdown Link 2</a> </div>
<div role="tabpanel" class="tab-pane fade" id="tabDropDownOne1" aria-labelledby="dropdownshoestab1">
<p>Dropdown content#1</p>
</div>
<div role="tabpanel" class="tab-pane fade" id="tabDropDownTwo1" aria-labelledby="dropdownbootstab1">
<p>Dropdown content#2</p>
Copy link to clipboard
Copied
correction, for the dropdown, in the second <a class>, href changes to pane3dropdown2, id changes to dropdownbootstab3
Copy link to clipboard
Copied
Whatever you name the 'tab-pane' id should be what you name the 'aria-controls' and the href should also be named the same - Bootstrap js/jQuery uses this to find and open the correct tab-pane with the matching id.
Check out the default Bootstrap 4 code/documentation listed at the website:
<ul class="nav nav-tabs" id="myTab" role="tablist">
<li class="nav-item">
<a class="nav-link active" id="home-tab" data-toggle="tab" href="#home" role="tab" aria-controls="home" aria-selected="true">Home</a>
</li>
<li class="nav-item">
<a class="nav-link" id="profile-tab" data-toggle="tab" href="#profile" role="tab" aria-controls="profile" aria-selected="false">Profile</a>
</li>
<li class="nav-item">
<a class="nav-link" id="contact-tab" data-toggle="tab" href="#contact" role="tab" aria-controls="contact" aria-selected="false">Contact</a>
</li>
</ul>
<div class="tab-content" id="myTabContent">
<div class="tab-pane fade show active" id="home" role="tabpanel" aria-labelledby="home-tab">Home</div>
<div class="tab-pane fade" id="profile" role="tabpanel" aria-labelledby="profile-tab">Profile</div>
<div class="tab-pane fade" id="contact" role="tabpanel" aria-labelledby="contact-tab">Contact</div>
</div>
Copy link to clipboard
Copied
Am I missing the point? The subject of this topic is
Aria controls error
how can you continue to ignore this issue?
The following is cited in the linked document that I quoted:
Note that navigation bars, even if visually styled as tabs with the .nav-tabs
class, should not be given role="tablist"
, role="tab"
or role="tabpanel"
attributes.
For a nore elaborate explanation: https://www.w3.org/TR/wai-aria-practices/examples/tabs/tabs-2/tabs.html
Copy link to clipboard
Copied
Just trying to avoid making any more errors... ps the hats/shoes /boots synonyms are about as clear to a newbie as a wellie on the wrong foot...
Copy link to clipboard
Copied
Really? Makes me wonder what else Bootstrap has wrong, because quite clearly in their example tab template code for their tab widget they include all of the mentioned aria attributes.
Copy link to clipboard
Copied
Could you point me in the direction of the help sheet for this? I couldn't find one and it was by no means clear to me what to change when adding more tabs/ dropdown menu tabs and matching them to panels. The nomenclature doesn't make it any easier - just saying!
Copy link to clipboard
Copied
Well if I point you in the direction of the Bootstrap 4 help sheet according to the W3.org on aria its wrong:
Bootstrap 4 (uses anchor tags, which are a form of naviagtion)
<ul class="nav nav-tabs" id="myTab" role="tablist">
<li class="nav-item">
<a class="nav-link active" id="home-tab" data-toggle="tab" href="#home" role="tab" aria-controls="home" aria-selected="true">Home</a>
</li>
<li class="nav-item">
<a class="nav-link" id="profile-tab" data-toggle="tab" href="#profile" role="tab" aria-controls="profile" aria-selected="false">Profile</a>
</li>
<li class="nav-item">
<a class="nav-link" id="contact-tab" data-toggle="tab" href="#contact" role="tab" aria-controls="contact" aria-selected="false">Contact</a>
</li>
</ul>
<div class="tab-content" id="myTabContent">
<div class="tab-pane fade show active" id="home" role="tabpanel" aria-labelledby="home-tab">...</div>
<div class="tab-pane fade" id="profile" role="tabpanel" aria-labelledby="profile-tab">...</div>
<div class="tab-pane fade" id="contact" role="tabpanel" aria-labelledby="contact-tab">...</div>
</div>
Bootstrap 5: (uses buttons which I guess arent a form of navigation)
<ul class="nav nav-tabs" id="myTab" role="tablist">
<li class="nav-item" role="presentation">
<button class="nav-link active" id="home-tab" data-bs-toggle="tab" data-bs-target="#home" type="button" role="tab" aria-controls="home" aria-selected="true">Home</button>
</li>
<li class="nav-item" role="presentation">
<button class="nav-link" id="profile-tab" data-bs-toggle="tab" data-bs-target="#profile" type="button" role="tab" aria-controls="profile" aria-selected="false">Profile</button>
</li>
<li class="nav-item" role="presentation">
<button class="nav-link" id="contact-tab" data-bs-toggle="tab" data-bs-target="#contact" type="button" role="tab" aria-controls="contact" aria-selected="false">Contact</button>
</li>
</ul>
<div class="tab-content" id="myTabContent">
<div class="tab-pane fade show active" id="home" role="tabpanel" aria-labelledby="home-tab">...</div>
<div class="tab-pane fade" id="profile" role="tabpanel" aria-labelledby="profile-tab">...</div>
<div class="tab-pane fade" id="contact" role="tabpanel" aria-labelledby="contact-tab">...</div>
</div>
According to the official W3.org source for aria this is the correct method to follow:
<div class="tabs">
<div role="tablist" aria-label="Entertainment">
<button role="tab"
aria-selected="true"
aria-controls="nils-tab"
id="nils">
Nils Frahm
</button>
<button role="tab"
aria-selected="false"
aria-controls="agnes-tab"
id="agnes"
tabindex="-1">
Agnes Obel
</button>
<button role="tab"
aria-selected="false"
aria-controls="complexcomplex"
id="complex"
tabindex="-1"
data-deletable="">
Joke
</button>
</div>
<div tabindex="0"
role="tabpanel"
id="nils-tab"
aria-labelledby="nils">
<p>
Nils Frahm is a German musician, composer and record producer based in Berlin. He is known for combining classical and electronic music and for an unconventional approach to the piano in which he mixes a grand piano, upright piano, Roland Juno-60, Rhodes piano, drum machine, and Moog Taurus.
</p>
</div>
<div tabindex="0"
role="tabpanel"
id="agnes-tab"
aria-labelledby="agnes"
hidden="">
<p>
Agnes Caroline Thaarup Obel is a Danish singer/songwriter. Her first album, Philharmonics, was released by PIAS Recordings on 4 October 2010 in Europe. Philharmonics was certified gold in June 2011 by the Belgian Entertainment Association (BEA) for sales of 10,000 Copies.
</p>
</div>
<div tabindex="0"
role="tabpanel"
id="complexcomplex"
aria-labelledby="complex"
hidden="">
<p>
Fear of complicated buildings:
</p>
<p>
A complex complex complex.
</p>
</div>
</div>
Whatever I dont get invloved with aria because its another layer of complexity to think about and as you can see its not clear as to where and when to apply it unless youre an expert in accessibilty and even then those experts would probably disagreee.
If I was going to follow one of the above solutions it would have to be the official W3.org one. I dont know how Bootstrap 4 or 5 fit in with that concept, one must be incorrect, maybe both.
Copy link to clipboard
Copied
That's Bootstrap 5 documentation - did Bootstrap 4 get it wrong as the tab example on the Bootstrap 4 website includes the aria attributes that are missing now from Bootstrap 5 and replaced with buttons?
Copy link to clipboard
Copied
Blimey.... It did make me wonder that the component still worked despite aria errors.
Copy link to clipboard
Copied
Blimey.... It did make me wonder that the component still worked despite aria errors.
By @Weat01
Browsers are very tolerant, as long as the flow is not impacted like when a missing end tag is missing.
Copy link to clipboard
Copied
Blimey.... It did make me wonder that the component still worked despite aria errors.
By @Weat01
Component will still work as aria has nothing to do with html/javascript/css its another 'language' which unless you are an accessibilty expert you probably shouldnt attempt to deploy and as you can see if Bootstrap struggles to implement it correctly, according to how its meant to be officially applied, what's the chances that you will.
Copy link to clipboard
Copied
In your view, would it be better to use the W3 code? Is it responsive and would it be more future proof than using a particular bootstrap version?
Copy link to clipboard
Copied
l cant be sure that either Bootstrap version is correct when it comes to how they deploy accessibility so personally l would follow the w3.org code IF l was going to deploy aria, which l dont.
I havent looked to see if it is responsive or whether you could swap the use of Bootstrap 4 anchor tags for button tags. Bootstrap 5 code is probably more likely to be advanced of Bootstrap 4 in respect of aria deployment so if l was using Bootstrap and aria l would be inclined to say of the 2 versions that would be the one which was closest to being correct.
Copy link to clipboard
Copied
Will dreamweaver cc update itself to bootstrap 5 and update html pages automatically, or would that need to be done manually?
Copy link to clipboard
Copied
Will dreamweaver cc update itself to bootstrap 5 and update html pages automatically, or would that need to be done manually?
By @Weat01
You CANT use Bootstrap 5 where you have deployed Bootstrap 4 code - the 2 are NOT compatible and no nothing gets automatically updated.
Having looked at this Bootstrap 5 tabs component is almost identical to Bootstrap 4 tabs component, except for one uses anchor tags (Bootstrap 4) to evoke the tab panels and the other uses buttons (Bootstrap 5) so you may as well believe that Bootstrap 5 is the more current at handing accessibility aria, therefore you can easily update Bootstrap 4 tabs to be identical to Bootstrap 5 tabs:
Bootstrap 4 tabs code updated to be identical to Bootstrap 5 tabs:
<ul class="nav nav-tabs" id="myTab" role="tablist">
<li class="nav-item" role="presentation">
<button class="nav-link active" id="home-tab" type="button" data-toggle="tab" href="#home" role="tab" aria-controls="home" aria-selected="true">Home</button>
</li>
<li class="nav-item" role="presentation">
<button class="nav-link" id="profile-tab" type="button" data-toggle="tab" href="#profile" role="tab" aria-controls="profile" aria-selected="false">Profile</button>
</li>
<li class="nav-item" role="presentation">
<button class="nav-link" id="contact-tab" type="button" data-toggle="tab" href="#contact" role="tab" aria-controls="contact" aria-selected="false">Contact</button>
</li>
</ul>
<div class="tab-content" id="myTabContent">
<div class="tab-pane fade show active" id="home" role="tabpanel" aria-labelledby="home-tab">Home</div>
<div class="tab-pane fade" id="profile" role="tabpanel" aria-labelledby="profile-tab">Profile</div>
<div class="tab-pane fade" id="contact" role="tabpanel" aria-labelledby="contact-tab">Contact</div>
</div>
Then add the below css selectors to your css file (NOT the Bootstrap 4 default css file but the css file where you over-ride the default Bootstrap css styling)
#myTab .nav-link {
color: #0d6efd;
background-color: transparent;
}
#myTab .nav-link.active {
color: #212529;
background-color: transparent;
}
Copy link to clipboard
Copied
Thank you, it has been an enlightening discussion.
Copy link to clipboard
Copied
That's Bootstrap 5 documentation - did Bootstrap 4 get it wrong as the tab example on the Bootstrap 4 website includes the aria attributes that are missing now from Bootstrap 5 and replaced with buttons?
By @osgood_
This is for Bootstrap 4 - no role.
<ul class="nav nav-tabs">
<li class="nav-item">
<a class="nav-link active" href="#">Active</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Link</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Link</a>
</li>
<li class="nav-item">
<a class="nav-link disabled" href="#" tabindex="-1" aria-disabled="true">Disabled</a>
</li>
</ul>
Copy link to clipboard
Copied
Thats not what is on the Bootstrap 4 official website, unless they have various versions listed. The version I posted directly from the website sample has 'role' and the other aria attributes mentioned.
A bit of a mess how ever you look at it. 2 Bootstrap versions both using different approaches. I'd go with whats on the official W3.org website and forget Bootstrap as it seems to be a bit conflicting or just forget aria when using Bootstrap as if they can get this incorrect what other aria is potentially wrong.
Copy link to clipboard
Copied
Thats not what is on the Bootstrap 4 official website, unless they have various versions listed. The version I posted directly from the website sample has 'role' and the other aria attributes mentioned.
By @osgood_
It is important for Aria to be included if you do not want to be sued for neglect. One reason to choose `professional` developers over backyard hacks.
https://css-tricks.com/why-how-and-when-to-use-semantic-html-and-aria/
Copy link to clipboard
Copied
Then it must appear in 2 locations on the website where the code differs and where aria is used supposedly incorrectly according to the w3.org website. I'll try and locate it later, going for a beer now for a couple of hours while we still have good weather.
The problem when deploying aria it has to be introduced professional by an accessibility expert which costs more money. I would not trust a framework to get it right and if its not right then its pointless to include it.
Copy link to clipboard
Copied
Enjoy!
Copy link to clipboard
Copied
The complete tab panel component is on the same page as where you have extracted your 'tab' only code. If you scroll down a bit more the example includes aria, which according to W3.org and the statement you posted in an earlier thread should not be used on nav items. Perhaps that is why the latest version of Bootstrap now uses buttons rather than nav items as that is the only difference between the 2 versions.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now