Syntax | This element uses separate opening and closing tags.<li>...</li> |
---|---|
Usage | The <li> tag is used to create list items within an ordered, or unordered, list. An ordered list is created using the <ol> tag and an unordered list is created using the <ul> tab. List items can also occur within dir and menu elements which are created using the <dir> and <menu> tags. HTML & XHTML <li> tag example. <p>The following is an ordered list.</p> <ol> <li>This is the first list item.</li> <li>This is the second list item.</li> <li>This is the third list item.</li> </ol> <p>The following is an unordered list.</p> <ul> <li>This is the first list item.</li> <li>This is the second list item.</li> <li>This is the third list item.</li> </ul> |
Content Model | The <li> element can contain the following tags, and Text, between its opening and closing tags. <a>
<abbr>
<acronym>
<address>
<applet>
<b>
<basefont>
<bdo>
<big>
<blockquote>
<br>
<button>
<center>
<cite>
<code>
<del>
<dfn>
<dir>
<div>
<dl>
<em>
<fieldset>
<font>
<form>
<h1>
<h2>
<h3>
<h4>
<h5>
<h6>
<hr>
<i>
<iframe>1
<img>
<input>
<ins>
<isindex>
<kbd>
<label>
<map>
<menu>
<noframes>2
<noscript>
<object>
<ol>
<p>
<pre>
<q>
<s>
<samp>
<script>
<select>
<small>
<span>
<strike>
<strong>
<sub>
<sup>
<table>
<textarea>
<tt>
<u>
<ul>
<var>
Notes:1. The <li> element can contain the <iframe> tag when using DTD Transitional and Frameset documents but not Strict documents. 2. The <li> element can contain the <noframes> tag when using DTD Transitional documents but not Strict or Frameset documents. 3. Red tags have been deprecated and are allowed in DTD Transitional and Frameset documents but not Strict documents. |
Required | Tag Specific | Core | Focus | Events | Language |
---|---|---|---|---|---|
type value | id class style title | onclick ondblclick onkeydown onkeypress onkeyup onmousedown onmousemove onmouseout onmouseover onmouseup | dir lang xml:lang1 | ||
Notes: 1. XHTML only. |
Attribute | Description | ||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
type | The type attribute specifies the numbering style for ordered lists and the bullet style for unordered lists. Possible values are shown in the following tables.
HTML & XHTML <li> example using the type attribute. <p>The following is an ordered list.</p> <ol> <li>This is the first list item.</li> <li type="a">This is the second list item.</li> <li>This is the third list item.</li> </ol> <p>The following is an unordered list.</p> <ul> <li>This is the first list item.</li> <li type="square">This is the second list item.</li> <li>This is the third list item.</li> </ul> Note: This attribute has been deprecated. | ||||||||||||||||||||
value | The value attribute specifies the number for the current list item. If the list items use letters instead of numbers, then the value attribute corresponds to the position of the letter in the alphabet. For example, if the list uses lowercase letters, then the list will start with the letter "b" if the value attribute is set to 2. HTML & XHTML <li> example using the value attribute. <ol> <li>This is the first list item.</li> <li value="7">This is the second list item.</li> <li>This is the third list item.</li> </ol> <ol type="a"> <li>This is the first list item.</li> <li value="7">This is the second list item.</li> <li>This is the third list item.</li> </ol> Note: This attribute has been deprecated. | ||||||||||||||||||||
id | The id attribute assigns a unique name to a tag. This allows style sheets or scripts to reference the tag. See id Example | ||||||||||||||||||||
class | The class attribute assigns a class name to a tag. The class name does not need to be unique. More than one tag can have the same class name. This allows style sheets or scripts to reference multiple tags with a single class name. See class Example | ||||||||||||||||||||
style | The style attribute specifies styles for the tag. For Cascading Style Sheets (CSS), the syntax is name:value. Each name:value pair is separated by semicolons. See style Example | ||||||||||||||||||||
title | The title attribute specifies additional information about the tag. It is common for browsers to display the title when the pointing device stops over the object. See title Example | ||||||||||||||||||||
onclick | The onclick attribute specifies a script to be run when the object is clicked with a mouse or other pointing device. See onclick Example | ||||||||||||||||||||
ondblclick | The ondblclick attribute specifies a script to be run when the object is double clicked with a mouse or other pointing device. See ondblclick Example | ||||||||||||||||||||
onkeydown | The onkeydown attribute specifies a script to be run when a key is pressed down. See onkeydown Example | ||||||||||||||||||||
onkeypress | The onkeypress attribute specifies a script to be run when a key is pressed and released. See onkeypress Example | ||||||||||||||||||||
onkeyup | The onkeyup attribute specifies a script to be run when a key is released. See onkeyup Example | ||||||||||||||||||||
onmousedown | The onmousedown attribute specifies a script to be run when the mouse button, or other pointing device button, is pressed while over the object. See onmousedown Example | ||||||||||||||||||||
onmousemove | The onmousemove attribute specifies a script to be run when the mouse, or other pointing device, is moved while it is over the object. See onmousemove Example | ||||||||||||||||||||
onmouseout | The onmouseout attribute specifies a script to be run when the mouse, or other pointing device, is moved away from an object after being over it. See onmouseout Example | ||||||||||||||||||||
onmouseover | The onmouseover attribute specifies a script to be run when the mouse, or other pointing device, is moved onto the object. See onmouseover Example | ||||||||||||||||||||
onmouseup | The onmouseup attribute specifies a script to be run when the mouse button, or other pointing device button, is released while over the object. See onmouseup Example | ||||||||||||||||||||
dir | The dir attribute tells the browser whether the text should be displayed from left-to-right or right-to-left. It does not reverse the direction of the characters, like the <bdo> tag does, but it can help the browser to determine if the text should be aligned on the left side or the right side. See dir Example | ||||||||||||||||||||
lang | The lang attribute specifies a language. This attribute can help the browser to correctly display text. This attribute can also be useful for braille translation software, speech synthesizers, dictionary definitions, etc. See lang Example | ||||||||||||||||||||
xml:lang | The xml:lang attribute specifies a language for XHTML documents. This attribute can help the browser to correctly display text. This attribute can also be useful for braille translation software, speech synthesizers, dictionary definitions, etc. See xml:lang Example Note: XHTML only. |
<li> tag example. <li> example using the type attribute. <li> example using the value attribute. |