HTML <header> tagS2C Home   « HTML <header> tag

Definition

The <header> tag is used to define introductory content for its nearest sectioning ancestor content tag or for a sectioning root element tag.

A document or section can have more than one <header> tag.

The <header> tag cannot be placed in another <header> tag or within an <address> or <footer> HTML tag.

The <header> tag was introduced in HTML5.

Example


<div style="background-color:grey">
  <header style="background-color:cyan">
    <h2>Some heading</h2>
    <p>Header Content</p>
  </header>
  <main style="background-color:yellow">
    <h2>Main content heading</h2>
    <p>Main content</p>
  </main>
  <footer style="background-color:orange">
    <h2>Footer content heading</h2>
    <p>Footer content such as copyright, sitemaps, contact information</p>
  </footer>
</div>

Some heading

Header content

Main content heading

Main content

Footer Content heading

Footer Content such as copyright, sitemaps, contact information

Attributes

The following attributes can be used with the <header> tag.


<header> Specific Attributes
Attribute Value Description Example
There are no required or optional attributes specific to the <header> tag.
<header> Global Attributes
Attribute Description Example
Common
classSpecifies a classname for the element allowing you to apply the style of the predefined class to the content.

<header class="name">Header Content</header>
idSpecifies a unique id for the element allowing you to apply the style of the predefined id to the content.

<header id="name">Header Content</header>
styleSpecifies an inline style for the element allowing you to apply the style to the contentt.

<header style="color:red;">Header Content</header>
titleSpecifies an inline style for the element allowing you to apply the style to the content.

<header title="Content info">Header Content</header>
Keyboard
accesskeySpecifies a keyboard shortcut to associate with the element.

<header accesskey="a">Header Content</header>
tabindexSpecifies a tab order for the element.

<header tabindex="1">Header Content</header>
Language
dirSpecifies the directional flow of the content.

<!-- The text will flow from left to right -->
<header dir="ltr">Header Content</header>
<!-- The text will flow from right to left -->
<header dir="rtl">Header Content</header>
langSpecifies a language code for the content of the element.

<header lang="en">Header Content</header>
spellcheckSpecifies an inline style for the element allowing you to apply the style to the contentt.

<!-- Valid values true and false. -->
<!-- Default inherited / browser specific. -->
<header spellcheck="true">Header Content</header> 
translateSpecifies an inline style for the element allowing you to apply the style to the content.

<!-- Valid values yes and no. -->
<!-- Default yes. -->
<header translate="no">Header Content</header> 
Miscellaneous
contenteditableSpecifies whether the content of the element is editable.

<!-- Valid values true and false. -->
<!-- Default inherited. -->
<header contenteditable="true">Header Content</header> 
draggableSpecifies whether the element is draggable.

<!-- Valid values true and false. -->
<!-- Default browser specific. -->
<header draggable="true">Header Content</header>
hiddenSpecifies whether the element is not yet, or no longer, relevant.

<!-- Valid values an empty string or hidden -->
<header hidden>Header Content</header> 
<header hidden="hidden">Header Content</header> 
<header> Event Attributes
Attribute Description Example
Document Element
oncopyThe script to be run when the user copies the content of an element.

 <!-- Executes go() function -->
<header oncopy="go()">Header Content</header> 
oncutThe script to be run when the user cuts the content of an element.

 <!-- Executes go() function -->
<header oncut="go()">Header Content</header>
onpasteThe script to be run when the user pastes some content into an element.

 <!-- Executes go() function -->
<header onpaste="go()">Header Content</header>
Drag and Drop
ondragThe script to be run when an element is dragged.

 <!-- Executes go() function -->
<header ondrag="go()">Header Content</header>
ondragendThe script to be run when an element has stopped being dragged.

 <!-- Executes go() function -->
<header ondragend="go()">Header Content</header>
ondragenterThe script to be run when an element has been dragged to a valid drop target.

 <!-- Executes go() function -->
<header ondragenter="go()">Header Content</header>
ondragleaveThe script to be run when an element leaves a valid drop target.

 <!-- Executes go() function -->
<header ondragleave="go()">Header Content</header>
ondragoverThe script to be run when an element is being dragged over a valid drop target.

 <!-- Executes go() function -->
<header ondragover="go()">Header Content</header>
ondragstartThe script to be run at the start of a drag operation.

 <!-- Executes go() function -->
<header ondragstart="go()">Header Content</header>
ondropThe script to be run when a dragged element is being dropped.

 <!-- Executes go() function -->
<header ondrop="go()">Header Content</header>
Form
onblurThe script to be run when the element loses focus.

 <!-- Executes go() function -->
<header onblur="go()">Header Content</header>
onchangeThe script to be run when object changed and attempt to leave field.

 <!-- Executes go() function -->
<header onchange="go()">Header Content</header>
oncontextmenuThe script to be run when a context menu is triggered.

 <!-- Executes go() function -->
<header oncontextmenu="go()">Header Content</header>
onfocusThe script to be run when the element gets focus.

 <!-- Executes go() function -->
<header onfocus="go()">Header Content</header>
oninputThe script to be run when an element gets user input.

 <!-- Executes go() function -->
<header oninput="go()">Header Content</header>
oninvalidThe script to be run when an element is invalid.

 <!-- Executes go() function -->
<header oninvalid="go()">Header Content</header>
onresetThe script to be run when a dragged element is being dropped.

 <!-- Executes go() function -->
<header onreset="go()">Header Content</header>
onselectThe script to be run when some or all of the contents of an object are selected.

 <!-- Executes go() function -->
<header onselect="go()">Header Content</header>
onsubmitThe script to be run when a form is submitted.

 <!-- Executes go() function -->
<header onsubmit="go()">Header Content</header>
Keyboard
onkeydownThe script to be run when an element is in focus and keyboard key is pressed down.

 <!-- Executes go() function -->
<header onkeydown="go()">Header Content</header>
onkeypressThe script to be run when an element is in focus and keyboard key is pressed down and released.

 <!-- Executes go() function -->
<header onkeypress="go()">Header Content</header>
onkeyupThe script to be run when an element is in focus and keyboard key is released.

 <!-- Executes go() function -->
<header onkeyup="go()">Header Content</header>
Media
onabortThe script code to be run on abort.

 <!-- Executes go() function -->
<header onabort="go()">Header Content</header>
oncanplayThe script to be run when a file has buffered enough so it is ready to start playing.

 <!-- Executes go() function -->
<header oncanplay="go()">Header Content</header>
oncanplaythroughThe script to be run when a file can be played all the way to the end without further need of buffering.

 <!-- Executes go() function -->
<header oncanplaythrough="go()">Header Content</header>
oncuechangeThe script to be run when the cue changes when using the track element.

 <!-- Executes go() function -->
<header oncuechange="go()">Header Content</header>
ondurationchangeThe script to be run when the length of the media is changed.

 <!-- Executes go() function -->
<header ondurationchange="go()">Header Content</header>
onemptiedThe script to be run when a media resource element suddenly becomes empty, usually due to an error.

 <!-- Executes go() function -->
<header onemptied="go()">Header Content</header>
onendedThe script to be run when the media has reach the end.

 <!-- Executes go() function -->
<header onended="go()">Header Content</header>
onloadeddataThe script to be run when media data is loaded and playback can start.

 <!-- Executes go() function -->
<header onloadeddata="go()">Header Content</header>
onloadedmetadataThe script to be run when metadata has been loaded.

 <!-- Executes go() function -->
<header onloadedmetadata="go()">Header Content</header>
onloadstartThe script to be run whenthe media resource has started loading.

 <!-- Executes go() function -->
<header onloadstart="go()">Header Content</header>
onpauseThe script to be run when the media resource has been paused.

 <!-- Executes go() function -->
<header onpause="go()">Header Content</header>
onplayThe script to be run when the media resource starts playback.

 <!-- Executes go() function -->
<header onplay="go()">Header Content</header>
onplayingThe script to be run when when playback has already begun.

 <!-- Executes go() function -->
<header onplaying="go()">Header Content</header>
onprogressThe script to be run when the browser is fetching the media data.

 <!-- Executes go() function -->
<header onprogress="go()">Header Content</header>
onratechangeThe script to be run when the playback rate changes.

 <!-- Executes go() function -->
<header onratechange="go()">Header Content</header>
onseekedThe script to be run when the seeking attribute is set to false indicating that seeking has finished.

 <!-- Executes go() function -->
<header onseeked="go()">Header Content</header>
onseekingThe script to be run when the seeking attribute is set to true indicating that seeking is currently active.

 <!-- Executes go() function -->
<header onseeking="go()">Header Content</header>
onstalledThe script to be run when the browser is unable to continue fetching media data.

 <!-- Executes go() function -->
<header onstalled="go()">Header Content</header>
onsuspendThe script to be run when media data has stopped before being completely loaded.

 <!-- Executes go() function -->
<header onsuspend="go()">Header Content</header>
ontimeupdateThe script to be run when the media resources current playback position has changed.

 <!-- Executes go() function -->
<header ontimeupdate="go()">Header Content</header>
onvolumechangeThe script to be run when the volume has changed or been muted.

 <!-- Executes go() function -->
<header onvolumechange="go()">Header Content</header>
onwaitingThe script to be run when the media resource has paused but is expected to resume.

 <!-- Executes go() function -->
<header onwaiting="go()">Header Content</header>
Mouse
onclickThe script to be run when when a mouse is clicked on an element.

 <!-- Executes go() function -->
<header onclick="go()">Header Content</header>
ondblclickThe script to be run when a mouse is double clicked on an element.

 <!-- Executes go() function -->
<header ondblclick="go()">Header Content</header>
onmousedownThe script to be run when he mouse button is pressed down while the cursor is over an element.

 <!-- Executes go() function -->
<header onmousedown="go()">Header Content</header>
onmousemoveThe script to be run when the mouse button is moved.

 <!-- Executes go() function -->
<header onmousemove="go()">Header Content</header>
onmouseoutThe script to be run when the mouse cursor moves off an element.

 <!-- Executes go() function -->
<header onmouseout="go()">Header Content</header>
onmouseoverThe script to be run when the mouse cursor moves over an element.

 <!-- Executes go() function -->
<header onmouseover="go()">Header Content</header>
onmouseupThe script to be run when the mouse button is released while the cursor is over the element.

 <!-- Executes go() function -->
<header onmouseup="go()">Header Content</header>
onwheelThe script to be run when the mouse wheel rolls up or down over an element.

 <!-- Executes go() function -->
<header onwheel="go()">Header Content</header>
Scroll
onscrollThe script code to be run when the scrollbar of an element is being scrolled.

 <!-- Executes go() function -->
<header onscroll="go()">Header Content</header> 
Window - NONE