A11Y 101: Ensure landmarks are unique

I'm a full-stack developer from South Africa 🇿🇦. I love writing about JavaScript, HTML and CSS.
Search for a command to run...

I'm a full-stack developer from South Africa 🇿🇦. I love writing about JavaScript, HTML and CSS.
No comments yet. Be the first to comment.
In this series I'll explore the basics of accessibility and you can join me on this learning trip.
When working with forms, we should always opt to have form labels describing the label. However, many designers want to hide these labels in modern-day applications as they make things bulky. Some good examples of forms without labels can be: A sear...
Most of you know me for my consistency, a golden arrow in my blog series. I've written 1000 articles in 1008 days! Almost an article a day, and my honeymoon was the only holiday I ever took. I'm super proud of this achievement; it has been a fantasti...

It's not the first time I'll be talking about community. I think it's an essential aspect of any successful tool. This shows in my previous explorations of Astro, Medusa, and now Vendure as well. All these products thrive in a super open, welcoming, ...

The cool part about Vendure is how easy it is to set up and how abstract each layer is. Basically, we get the following elements: External database Server Worker Admin UI Frontend While this is amazing, it also brings a bit of complexity when it co...

The previous article looked at customizing Vendure on a data and process level. In this article, we'll look at customizing emails, as they are often a big part of a webshop system. We'll be looking at two different layers of customization for customi...

Even though Vendure is a pretty significant project out of the box, in some cases, we might want to go in and modify some elements to work to our specific use case. In this article, I'll take a high-level look at some elements we can customize within...

While analyzing my website, we found the following error: "Ensure landmarks are unique".
This specific error occurred on a post detail page with two <nav> elements.
One is used for the tags, and one is in the footer.
You might be wondering why these landmarks should be unique? And that's a very valid question.
Let's view this scenario from a screen reader perspective.
Screen readers use landmarks to identify the structure on a page. If two or more of the same landmark are present, we need to make them unique with labels.
The screen reader can identify what each landmark is used for. This is especially important for navigation elements.
Let's take my website as an example and fix the issue. There are two nav elements, and we need to identify them.
I added the aria-label as "Tag" for the tag element.
<nav aria-label="Tag">
<ul>
<li>#remix</li>
</ul>
</nav>
Do note that you don't have to explicitly state navigation. As the screen readers will already read this as "tag navigation".
And for the footer we apply the same concept:
<nav aria-label="Footer">
<ul>
<li>about</li>
</ul>
</nav>
And that's it. By defining the aria label, we ensure each landmark is unique.
This concept should also be applied to duplicate headers, footers, and forms as they are all landmarks.
I hear you wonder, but what about repeated landmarks? So, for instance, are your navigation in the header and footer precisely the same?
Well, you can use the same label in that case.
<header>
<nav aria-label="Main">
<ul>
<li>home</li>
</ul>
</nav>
</header>
<footer>
<nav aria-label="Main">
<ul>
<li>about</li>
</ul>
</nav>
</footer>
Thank you for reading my blog. Feel free to subscribe to my email newsletter and connect on Facebook or Twitter