- HTML Tutorial
- HTML - Home
- HTML - Introduction
- HTML - Editors
- HTML - Basic Tags
- HTML - Elements
- HTML - Attributes
- HTML - Headings
- HTML - Paragraphs
- HTML - Fonts
- HTML - Blocks
- HTML - Style Sheet
- HTML - Formatting
- HTML - Quotations
- HTML - Comments
- HTML - Colors
- HTML - Images
- HTML - Image Map
- HTML - Iframes
- HTML - Phrase Elements
- HTML - Meta Tags
- HTML - Classes
- HTML - IDs
- HTML - Backgrounds
- 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 Color Names & Values
- HTML - Color Names
- 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 Picker
- HTML References
- HTML - Cheat Sheet
- 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
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.
This tag cannot be placed within a <footer>, <address>, or another <header> element.
Syntax
<header> ... </header>
Attribute
HTML header tag supports Global and Event attributes of HTML.
Examples of HTML header Tag
Bellow examples will illustrate the usage of header tag. Where, when and how to use header tag to create header elements of any website.
Creating header Element
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>
Using header tag with article element
In this example we will create a article element inside of that we will create a header element to define the header of the article element.
<!DOCTYPE html> <html lang="en"> <head> <title>HTML header Tag</title> </head> <body> <!-- Creating header Element --> <h2>HTML 'header' Element</h2> <article> <header>HTML Tags</header> <p> HTML tags are similar to keywords, which specify how a web browser will format and display content. A web browser can differentiate between simple content and HTML content with the use of tags. </p> </article> <article> <header>HTML Attributes</header> <p> An attribute is used to define the characteristics of an HTML element and is placed inside the element's opening tag. All attributes are made up of two parts: a name and a value </p> </article> </body> </html>
Styling header Element
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>
Linking header Element
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>
Supported Browsers
Tag | |||||
---|---|---|---|---|---|
header | Yes 5.0 | Yes 9.0 | Yes 4.0 | Yes 5.0 | Yes 11.1 |
To Continue Learning Please Login
Login with Google