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

Definition

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

Examples


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

Required Attributes

NONE

Optional Attributes

compact - this attribute is deprecated, use CSS instead.

start - this attribute is deprecated, use CSS instead.

type - this attribute is deprecated, use CSS instead.

Common Attributes

class - specifies a classname for the element allowing you to apply the style of the predefined class to the content.


<li class="classname">List text here</li>

id - specifies a unique id for the element allowing you to apply the style of the predefined id to the content.


<li id="idname">List text here</li>

style - specifies an inline style for the element allowing you to apply the style to the content.


<li style="color:red;text-align:left">List text here</li>

title - specifies extra information about the content.


<li title="information about the content">List text here</li>

Language Attributes

dir - specifies the directional flow of the content.


<!-- The text will flow from left to right -->
<li dir="ltr">List text here</li>

<!-- The text will flow from right to left -->
<li dir="rtl">List text here</li>

lang - specifies a language code for the content of the element.


<li lang="en">List text here</li>

xml:lang - specifies a language code for the content of the element in XHTML documents.


<li xml:lang="fr">List text here<li>

Document Event Attributes

NONE

Form Event Attributes

NONE

Image Event Attributes

NONE

Keyboard Event Attributes

onkeydown - The JavaScript code to be run when an element is in focus and keyboard key is pressed.


<!-- Executes the go() function -->
<li onkeydown="go()">List text here</li>

onkeypress - The JavaScript code to be run when an element is in focus and keyboard key is pressed down and released.


<!-- Executes the go() function -->
<li onkeypress="go()">List text here</li>

onkeyup - The JavaScript code to be run when an element is in focus and keyboard key is released.


<!-- Executes the go() function -->
<li onkeyup="go()">List text here</li>

Mouse Event Attributes

onclick - The JavaScript code to be run when a mouse is clicked on the element.


<!-- Executes the go() function -->
<li onclick="go()">List text here</li>

ondblclick - The JavaScript code to be run when a mouse is double clicked on the element.


<!-- Executes the go() function -->
<li ondblclick="go()">List text here</li>

onmousedown - The JavaScript code to be run when the mouse button is pressed down while the cursor is over the element.


<!-- Executes the go() function -->
<li onmousedown="go()">List text here</li>

onmousemove - The JavaScript code to be run when the mouse button is moved.


<!-- Executes the go() function -->
<li onmousemove="go()">List text here</li>

onmouseout - The JavaScript code to be run when the mouse cursor moves off an element.


<!-- Executes the go() function -->
<li onmouseout="go()">List text here</li>

onmouseover - The JavaScript code to be run when the mouse cursor moves over an element.


<!-- Executes the go() function -->
<li onmouseover="go()">List text here</li>

onmouseup - The JavaScript code to be run when the mouse button is released while the cursor is over the element.


<!-- Executes the go() function -->
<li onmouseup="go()">List text here</li>

go to home page Homepage go to top of page Top