A11Y 101: Adding skip links

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.
Alt tags have been along since the dawn of HTML and creating websites. However, for some people (including me), they were never a top priority. Let's change that behavior! And I'll tell you why. What about visually impaired people who cannot see what...
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 evaluating my website, I realized while using a screen reader. A user has to tab quite a lot to get to the main content part.
This is quite annoying as this can take you forever, and you might even lose users over this behavior.
Luckily for us, there is a solution to fix this, called skip links.
These are technically hidden links that sit above navigation areas, so people can quickly skip that section.
To illustrate it could look like this:
<a href="#main-content" class="skip-link">Skip navigation</a>
<nav>
<a href="#">About</a>
<a href="#">Contact</a>
<a href="#">Login</a>
</nav>
<main id="main-content">I'm the main content</main>
<footer>
<a href="#">Privacy</a>
</footer>
This, in general, already works. We can quickly tab and skip the whole navigation section!
It's ugly to have this link sit there, so we can make it visually hidden as we just learned.
In our case, we want to be able to show it on focus, so let's move it outside of the view initially.
.skip-link {
background: #da0060;
color: #fff;
left: 50%;
padding: 8px;
position: absolute;
transform: translate(-50%, -200%);
transition: transform 0.3s;
}
With this code, we set the skip links element above the top of our page, so it's not visible to users.
We can add a focus selector to animate it into the screen when a user focuses on it using tab navigation.
.skip-link:focus {
transform: translate(-50%, 0);
}
And when they now tab into this element, it will appear.
I made this super simple demo for you to play with. Try using your tab navigation and interact with the skip element, then tab again.
You are immediately in the footer, right? Now try not to click on the skip link, but keep tabbing. You are now able to visit the menu!
Thank you for reading my blog. Feel free to subscribe to my email newsletter and connect on Facebook or Twitter