2

I'm running tests with Lighthouse on this page.

When it comes to Accessibility, it keeps give me this error:

[aria-*] attributes do not have valid values.
Assistive technologies, like screen readers, can't interpret ARIA attributes with invalid values.

The code that causes that error is:

<button role="tab" aria-selected="true" aria-controls="v-pills-home" id="v-pills-home-tab" class="nav-link active" data-toggle="pill" href="#v-pills-login"><img src="./images/come-funziona/iconLogin.png" width="60" alt="login"> Login</button>

<button role="tab" aria-selected="false" aria-controls="v-pills-profile" id="v-pills-profile-tab" class="nav-link" data-toggle="pill" href="#v-pills-localizzazione"><img src="./images/come-funziona/iconLocalizzazione.png" width="60" alt="localizzazione mezzi"> Localizzazione</button>

<button role="tab" aria-selected="false" aria-controls="v-pills-messages" id="v-pills-messages-tab" class="nav-link" data-toggle="pill" href="#v-pills-badge"><img src="./images/come-funziona/iconBadgeRFID.png" width="60" alt="badge rfid"> Badge</button>

<button role="tab" aria-selected="false" aria-controls="v-pills-settings" id="v-pills-settings-tab" class="nav-link" data-toggle="pill" href="#v-pills-manutenzione"><img src="./images/come-funziona/iconManutenzione.png" width="60" alt="manutenzione mezzi"> Manutenzione</button>

<button role="tab" aria-selected="false" aria-controls="v-pills-reports" id="v-pills-report-tab" class="nav-link" data-toggle="pill" href="#v-pills-report"><img src="./images/come-funziona/iconReport.png" width="60" alt="report attività mezzi"> Report</button>

How can I solve it?

1
  • Check what are the valid values for aria-selected and aria-controls for Lighthouse. They should have documentation for it. Commented Apr 24, 2018 at 13:50

1 Answer 1

6

You only have three ARIA related attributes so let's go through all three.

  1. tab is a valid role and the <button> element is allowed to have that role. (See the <button> spec - tab is the last one in the list.)
  2. aria-selected is only valid on certain types of objects, but tab is one of them so you're ok there. And the valid values are true and false, so that's ok too. (See the aria-selected spec.)
  3. aria-controls should contain an id, or list of ids. Your example looks like it contains an id. Does the referred to object exist? When I viewed your test page, the first button/tab says it controls v-pills-home but I didn't see that object on the page. The tabpanel for the first button/tab has an id of v-pills-login. The same problem happens on the other buttons too. They all point to an object that doesn't exist.
Sign up to request clarification or add additional context in comments.

3 Comments

Thank you, you were right. I changed them and now they works.
why do they need to exist? Can the controlled elements not be inserted dynamically into the DOM when the controlling element is interacted with?
> why do they need to exist? - because that's what the spec says. if you try validator.w3.org/nu (the official w3c validator), change "check by" to "text input" and try to validate <button aria-controls="fooID">bar</button>, it'll fail with Error: The aria-controls attribute must point to an element in the same document. if you dynamically create the element that is controlled, then dynamically add aria-controls once the element exists.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.