Loading...
Loading...
00:00:00

<header> and <nav> Tag 

The <header> tag in HTML is used to define a header for a web page or section of a web page. The header typically contains elements such as a logo, a navigation menu, a search form, and/or other important information that is relevant to the overall content of the page.

The <header> tag is a semantic element, meaning that it provides meaning to the structure of the web page and is not used to define the appearance of the page.

Here's an example of how the <header> tag can be used in an HTML document:

<!DOCTYPE html>
<html>
  <head>
    <title>My Page Title</title>
  </head>
  <body>
    <header>                                                 <!-- header -->
      <img src="logo.png" alt="Logo">
      <nav>
        <ul>
          <li><a href="#">Home</a></li>
          <li><a href="#">About</a></li>
          <li><a href="#">Contact</a></li>
        </ul>
      </nav>
      <form action="#" method="get">
        <input type="text" name="search">
        <button type="submit">Search</button>
      </form>
    </header>
    <!-- Body content goes here -->
  </body>
</html>

In this example, the <header> tag contains a logo, a navigation menu, and a search form. These elements are typically found in the header of a web page and provide easy access to important information and features of the site.

It's important to note that the <header> tag can be used multiple times within an HTML document to define headers for different sections of the page, if needed. This allows you to structure your web page into logical sections, making it easier to understand and maintain.

nav Tag

The <nav> tag in HTML5 is used to define a section of a web page that contains navigation links. The <nav> tag provides a way to semantically identify a section of a page as a navigation block, making it easier for both users and search engines to understand the structure of the page.

Here's a basic example of how to use the <nav> tag:

<nav>
  <ul>
    <li><a href="#">Home</a></li>
    <li><a href="#">About</a></li>
    <li><a href="#">Contact</a></li>
  </ul>
</nav>

In this example, the <nav> tag is used to define a section of the page that contains navigation links. The <ul> tag is used to create an unordered list, which is a common way to display navigation links, and the <li> tags are used to create individual items in the list. The <a> tags are used to create hyperlinks to other pages.

The <nav> tag can be used multiple times on a single page, allowing you to define multiple sections of navigation links. This can be useful when you want to separate different types of navigation links, such as primary navigation links and secondary navigation links.

In addition to making it easier for users and search engines to understand the structure of the page, the <nav> tag also provides a way to style navigation sections using CSS. For example, you can use CSS to change the background color, font, and other styling properties of the navigation block.

The <nav> tag in HTML5 provides a way to define a section of a web page that contains navigation links, making it easier for both users and search engines to understand the structure of the page. Whether you're creating a simple personal website or a complex e-commerce platform, the <nav> tag is a useful tool for creating clear and accessible navigation.