When to use aria-labelledby

  • This topic has 2 replies, 2 voices, and was last updated 7 months, 3 weeks ago by ElodieA.
Viewing 3 posts - 1 through 3 (of 3 total)
When to use aria-labelledby thread
Author Posts
ElodieA

I’m confused about when I should be using the aria-labelledby attribute. Should it be used on every chapter <section> for a novel? The book I’ve made is organized so that one chapter = one xhtml file. Because only one doc-chapter attribute appears per file, would it be overkill to use an “aria-labelledby” attribute as seen in the code below?

For example:

<body>
<section epub:type=”bodymatter chapter” role=”doc-chapter” aria-labelledby=”hd1″>

<span id=”page1″ epub:type=”pagebreak” role=”doc-pagebreak” aria-label=”Page 1″></span>

<h1 id=”hd1″ class=”chapternumber”>1 <br/>
<span class=”chaptername”>Name</span></h1>

<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p>


</section>
</body>
</html>

Is that the correct markup? Or should the aria-labelledby attribute be removed?

Thank you!

APLN Moderator

Hi ElodieA,

Thanks for your question!

The aria-labelledby attribute points to a label—usually a heading—in a section that is considered an important part of the EPUB, which users can quickly navigate to. It is actually helpful to have a unique aria-labelledby for each chapter since each content chapter has the same role (doc-chapter).

It is up to your discretion to identify key components of the EPUB and apply aria-labelledby to those sections. Key components may include text chapters, prologue, part, glossary, appendix, etc. Aria-labelledby can also be used for titled asides or other important secondary sections (that are marked by headings) that may appear multiple times in a publication.

TL;DR, yes, the use of aria-labelledby in your example is correct. However, I would change the epub:type in your example to epub:type=”chapter”, as “bodymatter” is a separate semantic value and does not have an associated ARIA role.

ElodieA

Thanks so much for responding! I really appreciate it 🙂

Viewing 3 posts - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.

Want to join the discussion?

a wooden table with a white keyboard on top, and a persons hand writing on a piece of paper

View our current resources