HTML5 Reference

HTML <section> tag

Definition

The <section> tag is used to define a section within a HTML document.

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

Avoid using the <section> tag for styling content, the <div> tag is more suitable for this purpose.

The <section> tag was introduced in HTML5.

Example


<article style="background-color:cyan">
  <h2>Article heading</h2>
  <section style="background-color:yellow">
    <h2>Section content heading 1</h2>
    <p>Section content</p>
  </section>
  <section style="background-color:orange">
    <h2>Section content heading 2</h2>
    <p>Section content</p>
  </section>
  <section style="background-color:lime">
    <h2>Section content heading 3</h2>
    <p>Section content</p>
  </section>
</article>

Article heading

Section content heading 1

Section content

Section content heading 2

Section content

Section content heading 3

Section content

Attributes

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


<section> Specific Attributes
Attribute Value Description Example
There are no required or optional attributes specific to the <section> tag.
<section> 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.

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

<section id="name">Section content</section>
styleSpecifies an inline style for the element allowing you to apply the style to the contentt.

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

<section title="Content info">Section content</section>
Keyboard
accesskeySpecifies a keyboard shortcut to associate with the element.

<section accesskey="a">Section content</section>
tabindexSpecifies a tab order for the element.

<section tabindex="1">Section content</section>
Language
dirSpecifies the directional flow of the content.

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

<section lang="en">Section content</section>
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. -->
<section spellcheck="true">Section content</section> 
translateSpecifies an inline style for the element allowing you to apply the style to the content.

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

<!-- Valid values true and false. -->
<!-- Default inherited. -->
<section contenteditable="true">Section content</section> 
draggableSpecifies whether the element is draggable.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

 <!-- Executes go() function -->
<section onkeyup="go()">Section content</section>
Media
onabortThe script code to be run on abort.

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

 <!-- Executes go() function -->
<section oncanplay="go()">Section content</section>
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 -->
<section oncanplaythrough="go()">Section content</section>
oncuechangeThe script to be run when the cue changes when using the track element.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

 <!-- Executes go() function -->
<section onscroll="go()">Section content</section> 
Window - NONE

Relevant HTML Tutorials

HTML Advanced - HTML Structure - Page