The <header> Element
You'll learn what the <header> element is and how to use it for introductory content in your web pages.
What Is the <header> Element?
The <header> element is a semantic HTML tag that identifies introductory or navigational content at the top of your page or within sections of your document. Think of it like the letterhead on official stationery—it's where you put your branding, title, and quick navigation links.
When to Use <header>
You'll typically use <header> for:
- Page-level headers: The main header at the top of your website containing your logo, site title, and primary navigation
- Section-level headers: Introductory content at the start of an
<article>or<section>
A Simple Example
<header>
<h1>My Awesome Website</h1>
<p>Welcome to my corner of the web!</p>
</header>
You can also use <header> within other semantic elements:
<article>
<header>
<h2>Blog Post Title</h2>
<p>Published on January 15, 2025</p>
</header>
<p>The main content of the article goes here...</p>
</article>
Why It Matters
Using <header> instead of a generic <div> tells browsers, screen readers, and search engines exactly what role this content plays. It's part of writing semantic HTML—code that describes what things are, not just how they look.
Key Takeaway: The <header> element semantically marks introductory or navigational content, making your HTML structure clearer for both humans and machines.