Skip to main content
AI Assist is now on Stack Overflow. Start a chat to get instant answers from across the network. Sign up to save and share your chats.

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

2
  • 1
    Using aria-labelledby is generally the "best practice" approach if there's already an element on the page that contains the text you need (such as the <h2>). Commented Sep 28, 2021 at 5:35
  • Addendum to slugolicious' already excellent comments, if you plan on going with aria-label rather than aria-labeledby - ask yourself why sighted users wont benefit from a visible title. For a smaller alert such as this, the notification text itself can often work as the accessible name, so you don't need to dream up an additional, potentially redundant heading. Commented Sep 30, 2021 at 10:37