GAZAR

Principal Engineer | Mentor

More Accessible with Semantic HTML

More Accessible with Semantic HTML

It might sound a bit technical, but it's actually pretty straightforward and makes a big difference for users, especially those who rely on assistive technologies like screen readers.

Semantic HTML basically means using elements that give meaning to your content beyond just how it looks. Instead of just using generic divs and spans, we use special tags like <header>, <nav>, <main>, and so on to structure our content in a way that makes sense.

Now, why does this matter? Well, for one, it makes our websites more accessible. Screen readers depend on these semantic elements to understand and present content to users with disabilities. Plus, search engines love semantic HTML too, because it helps them better understand what our sites are all about.

Here's how we do it:

  • We use <header> for things like logos and navigation menus.
  • Navigation links go inside a <nav> tag to let users know where they can go on the site.
  • Our main content goes in a <main> tag, making it easy for everyone to find.
  • Related content gets grouped together using <section>, with each section having a clear heading.
  • Standalone pieces of content, like blog posts or articles, go inside a <article> tag.
  • Supplementary content, like sidebars, can be wrapped with a <aside> tag.
  • Finally, footer information, such as copyright and contact details, goes in a <footer> tag.

Once we've got all that in place, we use tools like axe or Lighthouse to make sure everything is working as it should. These tools help us identify any accessibility issues and make sure our sites are compliant with standards like WCAG.

So, by using semantic HTML, we're not just making our websites easier to use for everyone – we're also making them more accessible and inclusive. And that's pretty cool, if you ask me!