HTML Guides for headings
Learn how to identify and fix common HTML validation errors flagged by the W3C Validator — so your pages are standards-compliant and render correctly across every browser. Also check our Accessibility Guides.
The <article> element is meant to wrap independent, self-contained content such as blog posts, news stories, forum posts, product cards, or user comments. The W3C validator raises this warning because an <article> without a heading has no programmatic label, making it harder for users—especially those relying on screen readers—to understand what the article is about and to navigate between multiple articles on a page.
Screen readers often present a list of landmarks and headings to help users jump through a page’s structure. When an <article> has no heading, it appears as an unlabeled region, which is confusing and defeats the purpose of using semantic HTML. A heading inside the <article> acts as its identifying title, giving both sighted users and assistive technology a clear summary of the content that follows.
This is a warning rather than a hard validation error, but it signals a real accessibility and usability concern. In nearly all cases, every <article> should contain a heading. The heading level you choose should fit logically within the document’s heading hierarchy—typically <h2> if the <article> sits directly under the page’s main <h1>, or <h3> if it’s nested inside a section that already uses <h2>.
How to fix it
- Add a heading element (<h2>–<h6>) as one of the first children inside each <article>.
- Choose the correct heading level based on the document outline. Don’t skip levels (e.g., jumping from <h1> to <h4>).
- Make the heading descriptive. It should clearly summarize the article’s content.
If your design doesn’t visually display a heading, you can use CSS to visually hide it while keeping it accessible to screen readers (see the examples below).
Examples
❌ Article without a heading (triggers the warning)
<h1>Latest news</h1>
<article>
<p>Our new product launched today with great success.</p>
</article>
<article>
<p>We are hiring frontend developers. Apply now!</p>
</article>
Each <article> here has no heading, so assistive technologies cannot identify them, and the validator raises a warning.
✅ Articles with proper headings
<h1>Latest news</h1>
<article>
<h2>Product launch a success</h2>
<p>Our new product launched today with great success.</p>
</article>
<article>
<h2>We're hiring frontend developers</h2>
<p>We are hiring frontend developers. Apply now!</p>
</article>
✅ Nested articles with correct heading hierarchy
<h1>Our blog</h1>
<article>
<h2>How to validate accessibility</h2>
<p>Use automated tools for an in-depth scan of your site.</p>
<section>
<h3>Comments</h3>
<article>
<h4>Comment by Alex</h4>
<p>Great article, very helpful!</p>
</article>
</section>
</article>
When articles are nested (e.g., comments inside a blog post), each level gets the next heading level to maintain a logical outline.
✅ Visually hidden heading for design flexibility
If your design doesn’t call for a visible heading but you still need one for accessibility, use a CSS utility class to hide it visually while keeping it in the accessibility tree:
<style>
.visually-hidden {
position: absolute;
width: 1px;
height: 1px;
padding: 0;
margin: -1px;
overflow: hidden;
clip: rect(0, 0, 0, 0);
white-space: nowrap;
border: 0;
}
</style>
<article>
<h2 class="visually-hidden">Featured promotion</h2>
<p>Save 20% on all items this weekend only!</p>
</article>
This approach satisfies both the validator and assistive technologies without affecting your visual layout. Avoid using display: none or visibility: hidden, as those also hide the heading from screen readers.
The HTML heading elements <h1> through <h6> define a document’s heading hierarchy. The <h1> element represents the highest-level heading, and each subsequent level (<h2>, <h3>, etc.) represents a deeper subsection. This hierarchy is critical for both accessibility and document structure.
The HTML5 specification once introduced a “document outline algorithm” that would have allowed multiple <h1> elements to be automatically scoped by their parent sectioning elements (<section>, <article>, <nav>, <aside>). Under this model, an <h1> inside a nested <section> would be treated as a lower-level heading. However, no browser or assistive technology ever implemented this algorithm. The outline algorithm was eventually removed from the WHATWG HTML specification. In practice, screen readers and other tools treat every <h1> on a page as a top-level heading, regardless of nesting.
This matters for several reasons:
- Accessibility: Screen reader users frequently navigate by headings to get an overview of a page’s content. When multiple <h1> elements exist, the heading list becomes flat and unclear, making it difficult to understand the page’s structure and find specific content.
- SEO: Search engines use heading hierarchy to understand page structure and content importance. Multiple <h1> elements can dilute the semantic signal of your primary page topic.
- Standards compliance: While using multiple <h1> elements is not a validation error, the W3C validator raises this as a warning because it is widely considered a best practice to reserve <h1> for the single, top-level page heading.
To fix this warning, follow these guidelines:
- Use exactly one <h1> per page to describe the main topic or title.
- Use <h2> for major sections beneath it, <h3> for subsections within those, and so on.
- Don’t skip heading levels (e.g., jumping from <h1> to <h3> without an <h2>).
Examples
Incorrect: Multiple <h1> elements
This example uses <h1> inside each sectioning element, which triggers the warning. Screen readers will present all three headings at the same level, losing the intended hierarchy.
<h1>My Blog</h1>
<section>
<h1>Latest Posts</h1>
<article>
<h1>How to Write Accessible HTML</h1>
<p>Writing semantic HTML is important for accessibility.</p>
</article>
<article>
<h1>Understanding CSS Grid</h1>
<p>CSS Grid makes complex layouts straightforward.</p>
</article>
</section>
Correct: Proper heading hierarchy
Use a single <h1> for the page title and nest subsequent headings using the appropriate levels.
<h1>My Blog</h1>
<section>
<h2>Latest Posts</h2>
<article>
<h3>How to Write Accessible HTML</h3>
<p>Writing semantic HTML is important for accessibility.</p>
</article>
<article>
<h3>Understanding CSS Grid</h3>
<p>CSS Grid makes complex layouts straightforward.</p>
</article>
</section>
Incorrect: <h1> nested inside a section without a parent heading
Even a single <h1> nested deeply inside sectioning content can trigger this warning if the structure suggests it is not the page’s primary heading.
<section class="about">
<article>
<h1>Article heading</h1>
<p>Lorem ipsum dolor sit amet.</p>
</article>
</section>
Correct: Section with its own heading and properly ranked article heading
<section class="about">
<h1>About</h1>
<article>
<h2>Article heading</h2>
<p>Lorem ipsum dolor sit amet.</p>
</article>
</section>
Correct: Full page structure with clear heading hierarchy
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Company Homepage</title>
</head>
<body>
<header>
<h1>Acme Corporation</h1>
</header>
<main>
<section>
<h2>Our Services</h2>
<h3>Web Development</h3>
<p>We build modern, accessible websites.</p>
<h3>Design</h3>
<p>Our design team creates beautiful interfaces.</p>
</section>
<section>
<h2>About Us</h2>
<p>We have been in business since 2005.</p>
</section>
</main>
</body>
</html>
In this structure, screen readers will present a clear, navigable outline: one top-level heading followed by properly nested subheadings that reflect the logical organization of the content.
The <section> element defines a standalone thematic grouping within a document — think chapters, tabbed panels, or distinct parts of a page like “About Us” or “Contact.” According to the HTML specification, each <section> should generally include a heading that identifies its content. When a <section> lacks a heading, the validator raises this warning because the element isn’t being used as intended.
This matters for several reasons:
Accessibility. Screen readers and other assistive technologies use headings to build an outline of the page. When a user navigates by sections, the heading is what identifies each one. A <section> without a heading appears as an “untitled section” in the document outline, which makes it difficult or impossible for assistive technology users to understand the page structure or jump to the content they need.
Semantics. The whole purpose of <section> is to group related content under a common theme, and that theme should be labeled with a heading. If your content doesn’t need a heading, it may not be a true “section” in the semantic sense, and a <div> (which carries no semantic meaning) might be a better fit.
Document outline. Browsers and tools that generate document outlines rely on headings within sectioning elements. Missing headings create gaps in the outline, reducing the usefulness of the page structure.
How to fix it
You have three main options:
-
Add a heading — Place an <h2>–<h6> element at the beginning of the <section>. This is the preferred solution when the section genuinely represents a thematic block of content.
-
Use aria-label or aria-labelledby — If a visible heading doesn’t suit your design, you can label the section for assistive technologies using an ARIA attribute. This resolves the accessibility concern, though the validator may still show the warning.
-
Switch to <div> — If the content doesn’t represent a meaningful, identifiable section of the document, replace <section> with a <div>. There’s no expectation for a <div> to have a heading.
Examples
❌ Section without a heading
This triggers the warning because neither <section> has a heading:
<h1>All about guitars</h1>
<section>
<p>Acoustic, electric, classical... we have them all!</p>
</section>
<section>
<p>Analog, digital, portable...</p>
</section>
✅ Fixed: Adding headings to each section
<h1>All about guitars</h1>
<section>
<h2>Guitar types</h2>
<p>Acoustic, electric, classical... we have them all!</p>
</section>
<section>
<h2>Amplifiers</h2>
<p>Analog, digital, portable...</p>
</section>
✅ Fixed: Using aria-label when a visible heading isn’t appropriate
<section aria-label="Guitar types">
<p>Acoustic, electric, classical... we have them all!</p>
</section>
✅ Fixed: Using aria-labelledby to reference an existing element
<section aria-labelledby="guitar-heading">
<span id="guitar-heading" class="visually-hidden">Guitar types</span>
<p>Acoustic, electric, classical... we have them all!</p>
</section>
✅ Fixed: Replacing with <div> when no section semantics are needed
If you’re only using the element as a styling wrapper and the content doesn’t form a distinct thematic group, use a <div> instead:
<h1>All about guitars</h1>
<div class="content-block">
<p>Acoustic, electric, classical... we have them all!</p>
</div>
<div class="content-block">
<p>Analog, digital, portable...</p>
</div>
As a general rule, reach for <section> when your content has a clear topic that deserves a heading, and use <div> when you need a generic container for layout or styling purposes.
Ready to validate your sites?
Start your free trial today.