The <header> element is used to display the headers in html page. There are various heading element such as <hgroup> , < h1> to < h6> element. We can use headers by using <h1> to <h6> tag which defines font size according to header tags. Note that <hggroup> tag is removed from the HTML5 specification. We are not using that element in our example. <header> tag represents the group of navigator controls. This tag can be used multiple times in a document. Which leads to the over use of this tag multiple times where it can be reduced.
In short, <header> tag is used for grouping the collection of header tags like <h1> – <h6>. If you are using single formatting tag like <h1>, then there is no need to use header tag.
Syntax of <header> Tag
<header> Body content </header>
Browser Support
<header> element is supported in Internet Explorer 9, Firefox, opera, Chrome and safari browsers.
Example of <header> Tag
<!doctype html> <head> <meta charset="UTF-8"> <title>HTML 5 Example by JavaBeat.net</title> </head> <body> <header> <span style="color:brown;font-style:italic;">JavaBeat Version 1.0</span> <hr> </header> <article> <h1>HTML5</h1> <div style="width:800px"> <p style="text-align:justify">HTML5 is the latest standard for HTML. The previous version of HTML, HTML 4.01, came in 1999, and the internet has changed significantly since then. HTML5 was designed to replace both HTML 4, XHTML, and the HTML DOM Level 2.</p> </div> <footer> <span style="color:brown;font-style:italic;">Copyright ©2014</span> </footer> </body> </html>
- <header> element is used to display the header in html page.
Example Application Test
- Save the file as header_example.html in your system.
- Just open the file in the browser, you will see the below picture in the browser. Note that the browser must support HTML5 specification.
Output
When the execution process is completed successfully we will get the following output :