Does `aria-labelledby` work if the id is on a parent element?

I have a unique use case where I have a {{ heading }} twig expression that renders markdown. So {{ heading }} will evaluate to something like <h2>Lorem ipsum</h2>. Therefore, I need to put the id on a parent element (see attached). Will this still be accessible? I'm trying to provide a name to my section
No description
4 Replies
vince
vinceOP3mo ago
Reading mdn docs too, I could use aria-label which would be the same thing but easier
No description
clevermissfox
clevermissfox3mo ago
It is preferred to use an existing heading/labelledby if it exists on the page rather than the redundancy of an aria-label when there’s already a heading that you can create the relationship with. And , yes you can reference the id of a parent element for the attr value
vince
vinceOP3mo ago
Ty!!
Want results from more Discord servers?
Add your server