A11Y 101: Hiding content

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.
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. What are skip l...
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...

We developers tend to hide elements by using display: none or visibility: hidden.
And this works perfectly fine actually to hide elements from the screen. However, be aware this does precisely what we tell it. It hides things from the screen, which includes screen readers!
Let's see what it takes to hide elements from the screen, but not screen readers.
An example of this is: hiding the label for the search field.
We have to be careful about which CSS we want to use to achieve this behavior.
I love to use the CSS provided by the A11Y project as it's super complete and up to date.
.visually-hidden {
clip: rect(0 0 0 0);
clip-path: inset(50%);
height: 1px;
overflow: hidden;
position: absolute;
white-space: nowrap;
width: 1px;
}
If you add this class to any element, It will be removed from the screen but announced by screen readers.
We have to be careful when we hide elements from the screen. Screen readers might not be able to read the information anymore if we entirely hide the element.
Using the provided CSS code, we can achieve the effect we want.
Thank you for reading my blog. Feel free to subscribe to my email newsletter and connect on Facebook or Twitter