HTML <li> tagS2C Home   « HTML <li> tag

Definition

The <li> tag is used to define a list item within an ordered <ol> or unordered <ul> list.

Examples


<p>Ordered List</p>
<ol>
  <li>One</li>
  <li>Two</li>
  <li>Three</li>
  <li>Four</li>
</ol>
<p>Unordered List</p>
<ul>
  <li>Tin of Tomatoes</li>
  <li>Bacon</li>
  <li>Loaf of Bread</li>
  <li>Mushrooms</li>
</ul>

Ordered List

  1. One
  2. Two
  3. Three
  4. Four

Unordered List

  • Tin of Tomatoes
  • Bacon
  • Loaf of Bread
  • Mushrooms

Attributes

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


<li> Specific Attributes
Attribute Value Description Example
valueintegerSpecifies a value for this list item to start from.

The value can only be used with the <ol> (ordered list) tag.

<li value="05">List Text</li>
<li> 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.

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

<li id="name">List Text</li>
styleSpecifies an inline style for the element allowing you to apply the style to the contentt.

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

<li title="Content info">List Text</li>
Keyboard
accesskeySpecifies a keyboard shortcut to associate with the element.

<li accesskey="a">List Text</li>
tabindexSpecifies a tab order for the element.

<li tabindex="1">List Text</li>
Language
dirSpecifies the directional flow of the content.

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

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

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

<!-- Valid values true and false. -->
<!-- Default inherited. -->
<li contenteditable="true">List Text</li> 
draggableSpecifies whether the element is draggable.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

 <!-- Executes go() function -->
<li onkeyup="go()">List Text</li>
Media
onabortThe script code to be run on abort.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

 <!-- Executes go() function -->
<li onscroll="go()">List Text</li> 
Window - NONE