- HTML Tutorial
- HTML - Home
- HTML - History and Evolution
- HTML - Overview
- HTML - Editors
- HTML - Basic Tags
- HTML - Elements
- HTML - Attributes
- HTML - Formatting
- HTML - Headings
- HTML - Paragraphs
- HTML - Quotations
- HTML - Comments
- HTML - Phrase Tags
- HTML - Meta Tags
- HTML - Style Sheet
- HTML - CSS Classes
- HTML - CSS IDs
- HTML - Images
- HTML - Image Map
- HTML Tables
- HTML - Tables
- HTML - Headers & Caption
- HTML - Table Styling
- HTML - Table Colgroup
- HTML - Nested Tables
- HTML Lists
- HTML - Lists
- HTML - Unordered Lists
- HTML - Ordered Lists
- HTML - Definition Lists
- HTML Links
- HTML - Text Links
- HTML - Image Links
- HTML - Email Links
- HTML - Iframes
- HTML - Blocks
- HTML Backgrounds
- HTML - Backgrounds
- HTML Colors
- HTML - Colors
- HTML - RGB
- HTML - HEX
- HTML - HSL
- HTML Forms
- HTML - Forms
- HTML - Form Attributes
- HTML - Form Control
- HTML - Input Attributes
- HTML Media
- HTML - Video Element
- HTML - Audio Element
- HTML - Embed Multimedia
- HTML Header
- HTML - Head Element
- HTML - Adding Favicon
- HTML - Javascript
- HTML Layouts
- HTML - Layouts
- HTML - Layout Elements
- HTML - Layout using CSS
- HTML - Responsiveness
- HTML - Symbols
- HTML - Emojis
- HTML - Style Guide
- HTML Graphics
- HTML - SVG
- HTML - Canvas
- HTML APIs
- HTML - Geolocation API
- HTML - Drag & Drop API
- HTML - Web Workers API
- HTML - WebSocket
- HTML - Web Storage
- HTML - Server Sent Events
- HTML Miscellaneous
- HTML - MathML
- HTML - Microdata
- HTML - IndexedDB
- HTML - Web Messaging
- HTML - Web CORS
- HTML - Web RTC
- HTML Demo
- HTML - Audio Player
- HTML - Video Player
- HTML - Web slide Desk
- HTML Tools
- HTML - Velocity Draw
- HTML - QR Code
- HTML - Modernizer
- HTML - Validation
- HTML - Color Code Builder
- HTML References
- HTML - Tags Reference
- HTML - Attributes Reference
- HTML - Events Reference
- HTML - Fonts Reference
- HTML - ASCII Codes
- ASCII Table Lookup
- HTML - Color Names
- HTML - Entities
- MIME Media Types
- HTML - URL Encoding
- Language ISO Codes
- HTML - Character Encodings
- HTML - Deprecated Tags
- HTML Resources
- HTML - Quick Guide
- HTML - Useful Resources
- HTML - Color Code Builder
- HTML - Online Editor
HTML - <header> Tag
The HTML <header> tag is used to represent introductory content for an HTML document or section. It specifies a header for the document.This element can define a global site header and some headings elements also includes a logo, company name, a search input field, an author name, global navigation, and other elements.
The <header> element originally existed at the beginning of HTML for headings and is the first to be seen on a webpage.
Syntax
Following is the syntax of the <header> tag −
<header>.....</header>
Example
The following program shows the usage of the HTML <header> tag.
<!DOCTYPE html> <html lang="en"> <head> <title>HTML header tag</title> </head> <body> <!--create header tag--> <p>'header' element(tag) example</p> <header> <h1>HTML</h1> <p>Full form of above content: Hyper Text Markup Language.</p> </header> </body> </html>
When we run the above code, it will generate an output consisting of the ltext displayed on the webpage.
Example
Consider the following example, where we are going to use the <header> tag and applying the CSS properties.
<!DOCTYPE html> <html lang="en"> <head> <title>HTML header tag</title> <style> header { color: green; font-style: italic; } </style> </head> <body> <!--create header tag--> <p>'header' element(tag) example</p> <header> <h1>Cricket</h1> <p>I love playing and watching cricket matches. My favorite player is Virat Kohli.</p> </header> </body> </html>
On running the above code, the output window will pop up, consisting of the text along with a CSS applied displayed on the webpage.
Example
In this example, we are going to use the <header> tag with the anchor element
<!DOCTYPE html> <html lang="en"> <head> <title>HTML header tag</title> <style> header { color: rgb(4, 78, 138); font-style: italic; } .demo { background: left / cover url("91442692.webp"); height: 120px; display: flex; align-items: center; justify-content: center; color: white; font-size: 20px; text-decoration: none; } </style> </head> <body> <!--create header tag--> <p>'header' element(tag) example</p> <header> <a class="demo" href="#">Gaming laptop</a> </header> <article> <header> <h2>HTML</h2> <p>Hyper Text Markup Language</p> </header> <p>HTML is a standard markup language for documents designed to displayed in a web browser.</p> </article> </body> </html>
When we run the above code, it will generate an output consisting of the image along with a text displayed on the webpage.
Example
Let's look at the another scenario , where we are going to use the <footer> tag with the search input field.
<!DOCTYPE html> <html lang="en"> <head> <title>HTML header tag</title> </head> <body> <!--create header tag--> <p>'header' element(tag) with search input field example</p> <header> <form> <input type="search"> </form> </header> <article> <header> <p>Enter something to search in above input search field(it just demo example).</p> </header> </article> </body> </html>
When we run the above code, it will generate an output consisting of the input field along with a text displayed on the webpage.