—HTML Series · Post 10: HTML Accessibility Basics

HTML Accessibility Fundamentals
Accessibility (A11Y Basics) — HTML Is for Humans | CodeHerWay
Post 10 · HTML Fundamentals

Accessibility Basics:
HTML Is for Humans

This is not optional. If your site doesn't work for everyone, it doesn't work. Here are the a11y fundamentals every developer needs from day one.

#HTML #A11Y #Accessibility 10 min read

Let's get one thing straight before we go any further: accessibility is not a bonus feature. It's not something you "add later." It's not a nice-to-have for extra credit. It's a fundamental part of writing HTML.

When you write HTML, you're not just writing for Chrome on a MacBook. You're writing for screen readers, keyboard-only users, people with low vision, motor impairments, cognitive differences — the full spectrum of how humans interact with the web. And if your HTML doesn't account for that, your HTML is broken.

The good news? Accessibility starts with things you already know. Proper headings, good alt text, correct form labels — most of a11y is just writing good HTML in the first place.

🧠 What "a11y" Means

a11y is the numeronym for "accessibility" — the "a", then 11 letters, then "y." You'll see it everywhere in the dev world. It's pronounced "ally," which is fitting because that's exactly what accessible code makes you.

The Six Things You Need to Learn Right Now

You don't need to become a WCAG expert overnight. But you do need to understand these six fundamentals. They cover the vast majority of accessibility issues beginners create — and they're all fixable with basic HTML.

🔢
Heading Order
Headings create the document outline. Never skip levels — go h1 → h2 → h3 in order. Screen readers use this to navigate.
🖼️
Alt Attributes
Every image needs meaningful alt text. It's how screen readers describe images and how broken images communicate.
📝
Form Labels
Every input needs a label. Not a placeholder, not a nearby div — a real <label> element linked with "for."
🏷️
ARIA Basics
ARIA attributes add extra info for assistive tech. But rule one: don't use ARIA if native HTML does the job.
⌨️
Keyboard Navigation
Every interactive element must be reachable and usable with a keyboard alone. No mouse required.
🚫
Div Misuse
A div is not a button. A div is not a link. If it's clickable, use the right element — not a styled div with an onclick.

1. Proper Heading Order

Headings aren't just big text. They create the document outline — a structural map of your page that screen readers use to let users jump between sections. Think of headings like a table of contents: h1 is the title, h2s are chapters, h3s are sub-sections.

HTML · ❌ Wrong
<!-- Skipping heading levels --> <h1>My Portfolio</h1> <h4>About Me</h4> <!-- Skipped h2 and h3! --> <h2>My Projects</h2> <h6>Contact</h6> <!-- Just because it's small? -->
HTML · ✅ Correct
<!-- Logical heading hierarchy --> <h1>My Portfolio</h1> <h2>About Me</h2> <p>I'm a frontend developer...</p> <h2>My Projects</h2> <h3>CodeHerWay</h3> <p>A learning platform for women in tech.</p> <h3>Weather Dashboard</h3> <p>Real-time weather with API integration.</p> <h2>Contact</h2>
⚠️ Common Mistake

Don't pick a heading level because of how it looks. Pick it based on the document structure. If you want smaller text, use CSS — that's what it's for. Headings communicate hierarchy, not font size.

2. Alt Attributes — Describe What Matters

The alt attribute on images is one of the most important accessibility features in HTML. Screen readers read it aloud. Search engines index it. And if the image fails to load, the alt text shows up instead.

HTML
<!-- ❌ Bad alt text --> <img src="photo.jpg" alt="image"> <img src="banner.png" alt="banner"> <img src="DSC_0042.jpg" alt="DSC_0042.jpg"> <!-- ✅ Good alt text --> <img src="photo.jpg" alt="Woman in a hoodie writing code at a coffee shop"> <img src="banner.png" alt="CodeHerWay — Where women code on their own terms"> <!-- Decorative image? Use empty alt --> <img src="divider.svg" alt="">
💡 The Phone Test

Write alt text like you're describing the image to a friend over the phone. Be specific and useful. "Photo" tells them nothing. "Woman in a hoodie writing code at a coffee shop" paints the picture.

And if the image is purely decorative (a line, a pattern, a background shape), use alt="" — an empty alt tells the screen reader to skip it entirely.

3. Labeling Forms Properly

Every form input needs a <label>. Not a placeholder. Not a <div> next to it. A real, linked label. This is how screen readers know what each input is for, and it's how users with motor impairments can click the label to focus the input.

HTML · ❌ vs ✅
<!-- ❌ No label — screen reader says "edit text" --> <input type="email" placeholder="Your email"> <!-- ❌ Label exists but isn't linked --> <div>Email</div> <input type="email"> <!-- ✅ Proper label with "for" attribute --> <label for="email">Email Address</label> <input type="email" id="email" name="email"> <!-- ✅ Or wrap the input inside the label --> <label> Email Address <input type="email" name="email"> </label>

The for attribute on the label must match the id on the input. That link is what makes it accessible. And as a bonus, it makes the label clickable — click the text, and the input gets focused. Better UX for everyone.

ℹ️ Placeholders Are Not Labels

Placeholders disappear as soon as the user starts typing. That means once someone is filling out your form, they can't see what the field was asking for. Always use a visible <label>. Placeholders are optional hints, not replacements.

4. ARIA Basics — The Intro Level

ARIA stands for Accessible Rich Internet Applications. It's a set of attributes you can add to HTML elements to provide extra information to assistive technology. Think of ARIA as a way to annotate your HTML with instructions for screen readers.

But here's the most important ARIA rule you'll ever learn:

⚠️ The First Rule of ARIA

Don't use ARIA if native HTML does the job. A <button> is always better than <div role="button">. A <nav> is always better than <div role="navigation">. Native HTML has built-in keyboard support, focus management, and screen reader announcements. ARIA adds none of that — it only adds labels.

That said, there are times when ARIA is genuinely useful. Here are the most common attributes you'll encounter as a beginner:

HTML · Common ARIA
<!-- aria-label: names an element that has no visible text --> <button aria-label="Close menu"></button> <!-- aria-hidden: hides decorative elements from screen readers --> <span aria-hidden="true">🎨</span> Choose your theme <!-- aria-describedby: links an element to a description --> <input type="password" aria-describedby="pw-hint"> <p id="pw-hint">Must be at least 8 characters.</p> <!-- aria-live: announces dynamic content changes --> <div aria-live="polite"> <!-- Screen reader announces when this content updates --> 3 items in your cart </div>

You don't need to memorize every ARIA attribute right now. Just remember: use native HTML first, and reach for ARIA only when you need to fill in gaps that HTML can't cover on its own.

5. Keyboard Navigation Awareness

Not everyone uses a mouse. Some people navigate entirely with a keyboard — Tab to move between interactive elements, Enter or Space to activate them, Escape to close things, arrow keys to navigate within components.

If your site requires a mouse to use, it's broken for these users. Here's what you need to know:

HTML · Keyboard-Friendly
<!-- ✅ Native elements are keyboard-accessible by default --> <button>Submit</button> <!-- Tab + Enter ✓ --> <a href="/about">About</a> <!-- Tab + Enter ✓ --> <input type="text"> <!-- Tab + type ✓ --> <!-- ❌ These are NOT keyboard-accessible --> <div onclick="submit()">Submit</div> <!-- Can't tab to it --> <span onclick="goTo()">About</span> <!-- Can't tab to it --> <!-- Never remove the focus outline! --> <!-- This breaks keyboard navigation --> /* ❌ Don't do this in CSS */ /* *:focus { outline: none; } */ <!-- ✅ Style it instead --> /* button:focus-visible { outline: 2px solid #ff69b4; } */
💡 The Tab Test

Here's a quick accessibility check you can do right now: open your project in the browser, put your mouse away, and try to navigate your entire page using only Tab, Enter, and Escape. Can you reach every button? Every link? Every form field? If not, you've found your first accessibility bug.

6. Avoiding Div Misuse

We covered <div> in the last post — and this is where it connects directly to accessibility. A <div> has zero semantic meaning. Screen readers don't announce it. It doesn't receive keyboard focus. It has no built-in behavior.

So when you use a div as a button, you're creating something that looks clickable but isn't accessible:

HTML
<!-- ❌ Looks like a button but isn't one --> <div class="btn" onclick="handleClick()"> Sign Up </div> <!-- No keyboard focus, no screen reader announcement, no Enter key activation, no role --> <!-- ✅ Just use a button --> <button class="btn" onclick="handleClick()"> Sign Up </button> <!-- Keyboard accessible, announced as "button", activates with Enter and Space -->

The same applies to links. If something navigates the user to a new page, it should be an <a> tag — not a div or span with a click handler.

🧠 The Bottom Line on Divs

Use <div> for layout and grouping. Never for interaction. If a user clicks it, tabs to it, or activates it — it needs to be the right element. Buttons are buttons. Links are links. Let HTML do its job.

// dev_fession

I once built an entire contact form with zero labels. Every input just had a placeholder. I thought it looked "cleaner."

Then I tested it with a screen reader and every single field announced as "edit text." Just… "edit text." Over and over. No indication of what any field was actually for.

I added labels that same day. Took me five minutes. Should've been there from the start. Lesson learned — accessible doesn't mean ugly. It means usable. 💯

The Big Picture: HTML Is for Humans and Machines

Here's the thing about accessibility that changes how you think about HTML: you're not just writing code for browsers to render. You're writing instructions that get interpreted by a whole ecosystem of tools — screen readers like NVDA and VoiceOver, search engine crawlers, browser extensions, voice assistants, and more.

When you write semantic, accessible HTML, you're giving all of those tools the information they need to present your content correctly. When you write div soup with no labels, no headings, and no structure, you're saying "figure it out" — and most of the time, they can't.

Accessibility isn't about checking boxes for compliance. It's about recognizing that the web was built to be universal — and writing HTML that lives up to that promise.

🔨 Mini Build: A11Y Audit Your Last Project

Open your most recent HTML project and run through this accessibility checklist:

1
Heading check: Do your headings go in order? h1 → h2 → h3? No skipping levels? Only one <h1> per page?
2
Image check: Does every <img> have a descriptive alt attribute? Are decorative images using alt=""?
3
Form check: Does every input have a <label> with a matching for attribute? Are you relying on placeholders alone anywhere?
4
Keyboard check: Tab through your entire page. Can you reach every interactive element? Can you activate every button with Enter?
5
Div check: Are any divs or spans acting as buttons or links? Replace them with <button> or <a>.
6
Semantic check: Are you using <header>, <nav>, <main>, <footer>, and <article> where they belong? Or is everything a div?

The Bottom Line

Accessibility isn't advanced. It isn't a specialization. It's HTML fundamentals. If you use the right heading order, write meaningful alt text, label your forms correctly, understand basic ARIA, respect keyboard navigation, and stop misusing divs — you're already ahead of a huge percentage of the web.

HTML was designed to be accessible from the start. The only way it becomes inaccessible is when developers break it. So don't break it.

Write HTML for humans. All of them.

🎉 Series Checkpoint

You've made it through 10 posts of HTML fundamentals — from document structure to accessibility. You now have a solid foundation in how HTML actually works, not just what tags exist. The next step? Start building. Take everything you've learned and create something real. You've got the knowledge — now go ship it.

Previous
Previous

—HTML Series · Post 11: HTML Forms

Next
Next

—HTML Series · Post 9: Container Showdown: <div> vs <span>