Include a header for a document or section in HTML5?


Header tag is used to represent a container consists of set of navigational links or introductory content. It consists of one or more heading elements, icons and authorship information.

In HTML we can place number of <header> elements, but <header> element cannot be placed within a <footer>, another <header> or <address>. <header> tag consists of starting tag, ending tag, in between that content is placed.

Syntax

Following is the usage of <header> tag in HTML −

<header> …………</header>

Example

Following example of <header> tag in HTML −

<!DOCTYPE html>
<html>
<body>
   <h1>Header Tag</h1>
   <hr>
   <article>
      <header>
         <h3>TutorialsPoint Demonstrate the Header Tag</h3>
         <p>Article written by BhanuPriya</p>
         <p> Header tag is used to represent a container consists of set of navigational links or introductory content . It consists of one or more heading elements, icons and authorship information. </p>
      </header>
   </article>
</body>
</html>

We can apply CSS to <header> element with default values, below is the syntax used to by most browsers to display <header> element.

header
{
   display: block;
}

Example

In the following example we are using the <header> tag in HTML to represent navigation links.

<!DOCTYPE html>
<html>
<body>
   <h1>HTML Header Tags represent Links</h1>
   <header>
      <a href="https://www.tutorialspoint.com/questions/category/c"> C Programming</a> || <a href="https://www.tutorialspoint.com/questions/category/operating-system"> Operating System</a> || <a href="https://www.tutorialspoint.com/questions/category/rdbms"> RDBMS</a> || <a href="https://www.tutorialspoint.com/questions/category/computer-network"> Networking</a>
   </header>
</body>
</html>

Including a section in a HTML document

A Section is one of the tag used in HTML, which defines the section of document like header, footers, chapters etc.,

  • Section tag divides the content of document into two parts, section and subsections.

  • It is useful when there is a requirement of two headers or footers or chapter or other sections of document needed.

  • Section tag groups the related content in a generic block.

  • It is a semantic element, that describes meaning to browser as well as developer.

  • Section has open and closing tags, <section> </section>

Syntax

Following is the usage of section tag in HTML -

<section> Content </section>

Example

Let us see an example of the section tag −

<!DOCTYPE html>
<html>
<body>
   <h1>Tutorials Point</h1>
   <!-- html section tag is used here -->
   <section>
      <h2>----- Section 1-----</h2>
      <p>HTML Tutorial</p>
   </section>
   <section>
      <h2>----- Section 2-----</h2>
      <p>JAVA Tutorial</p>
   </section>
   <section>
      <h2>-----Section 3-----</h2>
      <p>Oracle Tutorial</p>
   </section>
</body>
</html>

Updated on: 10-Oct-2023

350 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements