A11Y 101: Semantic HTML always wins

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 auditing my website, I noticed a weird double tab behavior on my cards. This is a common accessibility issue in card designs. To illustrate, let's take one of my cards. In the image, we can see the whole card. Inside the card, it starts with a...
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...

This is less of a technical article but more a description and call out why semantic HTML always wins.
The main difference between semantic and non-semantic HTML is that semantic is a descriptive way of coding.
We (the developers) define elements that describe what they are. Some examples:
These semantic elements, as you see by their name, are already more descriptive than their non-semantic cousins:
Even when we take accessibility out of the acquisition, it's always good to focus and invest time and effort into learning semantic HTML.
It's a way to define your structure and for all kinds of other wins.
And besides that, what good argument can you give me that a div is better than a <header>, for instance?
Of course, we are focusing on improving accessibility and so why is this semantic important for this?
First, screen readers and other tools that people with disabilities might use love semantic HTML.
Some other examples could be the keyboard navigation, specific read-only software (which might remove everything outside your article part), or people using different navigation ways, such as a mouth-driven input device.
You get the picture and many different use-cases, and they love semantic HTML because that's how they identify your website.
Let's take this simple example.
A: non-semantic layout
<div class='header'></header>
<div class='nav'></nav>
<div class='main'>
<div class='article'>
<h1>Title of article</h1>
<p>...</p>
</div>
</div>
<div class='sidebar'></div>
<div class='footer'></div>
Layout-wise, we can make this work and look stunning, but screen readers have no idea where your navigation is, where your articles start and end, and your sidebar.
And if you are wondering, those tools can't read your website based on the classes because, again, every developer will use custom names or even smudge them together with some build tools.
To help them identify these elements, we can leverage the semantic version:
B: Semantic layout
<header></header>
<nav></nav>
<main>
<section>
<article>
<h1>Title of article</h1>
<p>...</p>
</article>
</section>
</main>
<aside></aside>
<footer></footer>
This makes the element finable by their type, which is used by these fantastic accessibility helper tools.
And that is precisely why semantics always wins! It's structured, it's clear, and it's searchable.
Not just by accessibility helpers but also by SEO engines and other tools users or robots might use.
I hope this article motivates you to change to semantic. Trust me. It's not that hard to switch to the semantic side.

Thank you for reading my blog. Feel free to subscribe to my email newsletter and connect on Facebook or Twitter