HTML Tutorial

HTML Tag: <header>

Usage of <header>:

  • Defines the header of a document or section.
  • Typically contains the title, site navigation, and other introductory content.

Attributes of <header>:

None

Examples with <header>:

  • Document header: <header><h1>My Awesome Website</h1></header>
  • Section header: <section><header><h2>Section Title</h2></header>...</section>

Exploring the <header> Tag:

<!DOCTYPE html>
<html>
<head>
  <title>My Page</title>
</head>
<body>
  <header>
    <h1>My Page Title</h1>
    <nav>
      <a href="#">Home</a>
      <a href="#">About</a>
      <a href="#">Contact</a>
    </nav>
  </header>
  <main>
    <!-- Main content of the page -->
  </main>
  <footer>
    <!-- Page footer -->
  </footer>
</body>
</html>

In this example:

  • The <header> tag defines the header of the page.
  • It contains the page title <h1> and a navigation menu <nav>.
  • The <main> tag contains the main content of the page.
  • The <footer> tag contains the page footer.