Avoiding Div and Span Soup
You'll learn how to identify meaningless generic containers in your markup and replace them with semantic HTML elements that improve accessibility.
What is "Div and Span Soup"?
"Div and span soup" describes HTML filled with generic <div> and <span> elements that provide zero semantic meaning. Think of it like giving directions using only "go to the thing, turn at the thing, enter the thing"—technically accurate but unhelpful. Screen readers and other assistive technologies rely on semantic HTML to understand page structure and announce content properly.
Why It Hurts Accessibility
When you wrap everything in divs and spans, you force assistive technology users to navigate blindly. A <div> acting as a button won't be keyboard-accessible or announced as interactive. A <span> used for a heading won't appear in the document outline or screen reader heading navigation.
Auditing Your Markup
Look for patterns like:
<div class="button">→ Use<button><div class="heading">→ Use<h1>through<h6><div class="list">→ Use<ul>,<ol>, or<dl><span class="link">→ Use<a><div class="navigation">→ Use<nav>
The Replacement Strategy
Ask yourself: "What does this content represent?" If it's navigational, use <nav>. If it's a distinct section of content, use <section> or <article>. If it's contact information, use <address>. Reserve <div> and <span> only for styling hooks when no semantic alternative exists.
This doesn't mean never using divs—they're perfect for layout containers. But content-bearing elements deserve semantic markup.
Key Takeaway: Audit your HTML for generic containers and replace them with semantic elements that describe their purpose, making your site navigable and understandable for assistive technology users.