- Home
- /
- Tutorials
- /
- HTML Tutorial
- /
- HTML <header> Tag
HTML Tags
HTML <header> Tag
The header tag holds the introduction of a page or of a section: usually a logo, the main heading and the navigation. The name is about its role, not its position, so an article can have its own header too.
Do not confuse it with the <head> tag, which holds information about the page that is not displayed, or with headings like <h1>. A header usually contains a heading. It is one of the semantic layout tags.
Syntax
html
<header>
<!-- Introductory content like logo, navigation, heading -->
</header>It has no attributes of its own, only the global ones such as id, class, style and title.
Example
html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Header Tag Example</title>
</head>
<body>
<header style="background-color: #f0f0f0; padding: 20px;">
<h1>My Website</h1>
<nav>
<a href="#">Home</a> |
<a href="#">About</a> |
<a href="#">Contact</a>
</nav>
</header>
<main>
<h2>Welcome to my website!</h2>
<p>This is an example showing the header element.</p>
</main>
</body>
</html>The page starts with a grey band containing "My Website" and three navigation links, followed by the main content.
Page header and article header
Two headers, two jobs
html
<header>
<a href="/">My Kitchen</a>
<nav>...</nav>
</header>
<main>
<article>
<header>
<h1>How to bake bread</h1>
<p>By Asha · 3 March 2025</p>
</header>
...
</article>
</main>The first is the site header. The second introduces one article, with its title and author line. Screen readers treat only the page-level header as a "banner" landmark.
Browser Support
Chrome | Edge | Firefox | Safari | Opera | IE9+ |
|---|---|---|---|---|---|
| Yes | Yes | Yes | Yes | Yes | Yes |
Good to know
- A header cannot contain another
<header>or a<footer>. - It is not required. A simple article with just a heading does not need a header around it.
- The matching closing part is the footer tag.
HTML <header> Tag exercises
Add a page header
Make a page header with the level 1 heading My Site.
Result
