Skip to content

tighten up rules for invalid use of aria-label and aria-labelledby #1334

Description

@scottaohara

With ARIA 1.2 certain roles are prohibited from being named by authors.

ARIA in HTML has identified the HTML elements which share these roles, and in some cases, have no corresponding ARIA role but too should be prohibited from being named by authors. The following list of elements should flag an author error if aria-label or aria-labelledby are specified on them UNLESS a role which allows for naming is also specified.

Note: many of these roles already flag a warning for use of aria-label, but the message implies that if someone feels this is in error, to respond as such. These warnings, as well as other elements from the following list which are not presently flagged would need to flag an error for using these attributes without an explicit role which allows naming from authors.

Many of the following elements map to (generic) or no corresponding role - often which does not adequately support naming from author. Or, to roles which also explicitly prohibit naming from authors.

test case

  • a no href (not flagged)
  • abbr
  • address
  • area no href (not flagged)
  • b
  • bdi
  • bdo
  • body
  • caption (caption)
  • cite
  • code (code)
  • custom elements
  • data
  • del (deletion)
  • div
  • em (emphasis)
  • figcaption (caption)
  • footer (if not scoped to body) (not flagged)
  • header (if not scoped to body) (not flagged)
  • hgroup
  • i
  • ins (insertion)
  • kbd
  • label (not flagged)
  • legend
  • mark (mark)
  • p (paragraph)
  • pre
  • q
  • rt
  • s
  • samp
  • small
  • span
  • strong (strong)
  • sub (subscript)
  • sup (superscript)
  • time (time)
  • u
  • var

Activity

  1. pkra commented on Oct 31, 2025

    @pkra

    👍 for #1930

  2. sideshowbarker commented on Nov 6, 2025

    @sideshowbarker
    Member

    Does these same rules now also apply to use of aria-braillelabel and aria-brailleroledescription?

  3. pkra commented on Nov 7, 2025

    @pkra

    Does these same rules now also apply to use of aria-braillelabel and aria-brailleroledescription?

    Though aria-braillelabel is ARIA 1.3: yes. It has the same restrictions on roles as aria-label, so aria-in-html's changes for ARIA 1.2 have the same effect for brailleLabel.

    (I'm guessing you didn't mean brailleroledescription but something like brailleLabelledBy - which doesn't exist.)

  4. sideshowbarker commented on Nov 8, 2025

    @sideshowbarker
    Member

    Does these same rules now also apply to use of aria-braillelabel and aria-brailleroledescription?

    Though aria-braillelabel is ARIA 1.3: yes. It has the same restrictions on roles as aria-label, so aria-in-html's changes for ARIA 1.2 have the same effect for brailleLabel.

    OK, thanks

    (I'm guessing you didn't mean brailleroledescription

    Right

    but something like brailleLabelledBy - which doesn't exist.)

    Yeah, I was just confused 😄

  5. sideshowbarker commented on Nov 8, 2025

    @sideshowbarker
    Member

    Per https://w3c.github.io/html-aria/#el-rp, rp is a “Naming prohibited” element, right?

    Is there a reason rp isn’t included in the list in the issue description here, and not included in the tests at https://w3c.github.io/html-aria/tests/prohibit-names.html?

  6. sideshowbarker commented on Nov 8, 2025

    @sideshowbarker
    Member

    At https://w3c.github.io/html-aria/#el-address and https://w3c.github.io/html-aria/#el-hgroup and https://w3c.github.io/html-aria/#el-label, the ARIA in HTML spec doesn’t identify address, hgroup, and label as “Naming prohibited” — yet, those elements are included in the list in the issue description here, and in the tests at https://w3c.github.io/html-aria/tests/prohibit-names.html.

    Is there something I’m missing, or does the ARIA in HTML spec need to be updated to identify those as “Naming prohibited”? Or what?

  7. sideshowbarker commented on Nov 8, 2025

    @sideshowbarker
    Member

    The following list of elements should flag an author error if aria-label or aria-labelledby are specified on them UNLESS a role which allows for naming is also specified.

    Can you please clarify exactly what “a role which allows for naming” means?

    Does it just mean the role cannot be caption, code, deletion, emphasis, generic, insertion, paragraph, presentation, strong, subscript, or superscript?

    If that’s not what it means, please instead either explicitly enumerate here exactly which roles allow naming, or else point me to somewhere else normative where I can find a single list of exactly what those roles are.

  8. pkra commented on Nov 9, 2025

    @pkra

    I think the confusion stems from the fact that Scott filed this issue in 2022 and the spec has evolved since then.

    For example in 2023 there's w3c/html-aria#463 adjusting hgroup, address, rp and in 2024 w3c/html-aria#556 adjusts label.

    I would recommend following the spec and seeking clarification on the spec tracker so the ARIA WG can help clarify.

  9. scottaohara commented on Nov 9, 2025

    @scottaohara
    CollaboratorAuthor

    yup, that's exactly it.

    here's the newer issue about hgroup/address - #1626

    maybe rp was a miss, or was clarified sometime in the years gap and i forgot to file an issue? thanks @pkra for helping out with clarifying this / yes the spec is at least all up to date for any gaps in the pr

  10. sideshowbarker commented on Nov 9, 2025

    @sideshowbarker
    Member

    I’m confused about the following test case:

        <div class=test-case>
        <h3><code>footer</code> not scoped to <code>body</code></h3>
        <article>
          <footer aria-label="aria">fail</footer>
          <footer aria-labelledby=name>fail</footer>
        </article>
        </div>

    …and the corresponding one for header.

    Why is fail the expected result for that?

    At https://w3c.github.io/html-aria/#el-footer the ARIA in HTML spec says:

    If not a descendant of an article, aside, main, nav or section element, or an element with role=article, complementary, main, navigation or region then role=contentinfo

    Otherwise, role=generic

    Naming Prohibited if exposed as generic.

    So, what I see is:

    1. That footer is a descendant of an article.
    2. Therefore it does not have the implicit role generic (but instead has the implicit role contentinfo).
    3. Therefore it is not “exposed as generic”.
    4. Therefore it is not “Naming prohibited”.

    What am I misunderstanding?

  11. scottaohara commented on Nov 9, 2025

    @scottaohara
    CollaboratorAuthor

    all of the test cases are contained within a main element, so none of them are scoped to the body.

    but, all of this will be moot, since within the last year there has been new roles created to replace the generic fallback roles for header and footer (sectionheader and sectionfooter) - so once this html aam PR lands (w3c/aria#2543) then header and footer will not have a name prohibited condition anymore, as both of their implicit roles will accept naming.

    tldr; you probably want to ignore the conditions for header and footer since in the past 3.5 years things changed :D

  12. sideshowbarker commented on Nov 27, 2025

    @sideshowbarker
    Member

    @pkra @scottaohara I’ve landed a change for this and pushed it to https://validator.w3.org/nu/

    Please take a look there at and the changes in fb1bf7b and let me know what I missed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions