You might see <header> Element reference while reading someone else’s HTML, or need it while building a page of your own. Instead of memorizing a definition, look at a working example and see when the element makes sense.
The Idea in Plain English
Introduces a page or section, often with a heading or navigation. Multiple headers can belong to separate article sections.
For a reference page, pay attention to where the element is allowed, whether it needs a closing tag, and what other elements it can contain.
A Working Example
Read the sample once before copying it. Notice the element names and attribute values, then compare them with the explanation below.
<article>
<header>
<h2>Birdwatching Basics</h2>
<p>By Morgan</p>
</header>
<p>Start by listening for birdsong.</p>
</article>
What Each Part Does
- The header introduces a page or nearby section.
- An article identifies a self-contained piece of content.
- The h2 identifies a major subsection.
The header information introduces this article.
Try It Yourself
Try replacing the example content with your own while keeping the valid HTML structure.
Common Beginner Mistakes
- Assuming header always means the top navigation bar.
- Changing several parts of the example at once, making it difficult to see which part caused a different result.
- Choosing a tag only because its default appearance looks right, without checking whether it describes the content correctly.
Key Takeaways
- Introduces a page or section, often with a heading or navigation. Multiple headers can belong to separate article sections.
- The header information introduces this article.
- Test the markup in a browser, and check accessibility and real-world behavior where relevant.