X
HOME HTML CSS JAVASCRIPT SQL PHP JQUERY ANGULAR XML ASP.NET MORE...
REFERENCES | EXAMPLES | FORUM | ABOUT

HTML Lists


HTML can have Unordered Lists, Ordered Lists, or Description Lists:

Unordered HTML List

  • The first item
  • The second item
  • The third item
  • The fourth item

Ordered HTML List

  1. The first item
  2. The second item
  3. The third item
  4. The fourth item

HTML Description List

The first item
Description of item
The second item
Description of item



Unordered HTML Lists

An unordered list starts with the <ul> tag. Each list item starts with the <li> tag.

The list items will be marked with bullets (small black circles).

Unordered List:

<ul>
  <li>Coffee</li>
  <li>Tea</li>
  <li>Milk</li>
</ul>

Try it Yourself »


Unordered HTML Lists - The Style Attribute

A style attribute can be added to an unordered list, to define the style of the marker:

Unorderd List:

<ul style="list-style-type:square">
  <li>Coffee</li>
  <li>Tea
  <li>Milk</li>
</ul>

Try it Yourself »

Style Description
list-style-type:disc The list items will be marked with bullets (default)
list-style-type:circle The list items will be marked with circles
list-style-type:square The list items will be marked with squares

Note <ul type="square"> also works, but the type attribute of the <ul> tag is not valid in HTML5.


Ordered HTML Lists

An ordered list starts with the <ol> tag. Each list item starts with the <li> tag.

The list items will be marked with numbers.

Ordered List:

<ol>
  <li>Coffee</li>
  <li>Milk</li>
</ol>

Try it Yourself »


HTML Ordered Lists - The Type Attribute

A type attribute can be added to an ordered list, to define the type of the marker:

Ordered List:

<ol type="A">
  <li>Coffee</li>
  <li>Tea
  <li>Milk</li>
</ol>

Try it Yourself »

Type Description
type="1" The list items will be numbered with numbers (default)
type="A" The list items will be numbered with uppercase letters
type="a" The list items will be numbered with lowercase letters
type="I" The list items will be numbered with uppercase roman numbers
type="i" The list items will be numbered with lowercase roman numbers


HTML Description Lists

A description list, is a list of terms, with a description of each term.

The <dl> tag defines a description list.

The <dt> tag defines the term, and the <dd> tag defines the description.

Description List:

<dl>
  <dt>Coffee</dt>
  <dd>- black hot drink</dd>
  <dt>Milk</dt>
  <dd>- white cold drink</dd>
</dl>

Try it Yourself »


Nested HTML Lists

List can be nested (lists inside lists).

Nested Lists:

<ul>
  <li>Coffee</li>
  <li>Tea
    <ul>
      <li>Black tea</li>
      <li>Green tea</li>
    </ul>
  </li>
  <li>Milk</li>
</ul>

Try it Yourself »

Note List items can contain new list, and other HTML elements, like images and links, etc.


HTML Lists Summary

  • Use <ul> to define unordered lists
  • Use a style attribute to define the bullet style
  • Use <ol> to define ordered lists
  • Use a type attribute to define the numbering type
  • Use <li> to define list items
  • Use <dl> to define definition lists
  • Use <dt> for terms and <dd> for definitions in definition lists
  • Lists can be nested inside lists
  • List items can contain other HTML elements

Examples

Try-It-Yourself Summary

Unordered list
Demonstrates an unordered HTML list.

Ordered list
Demonstrates ordered HTML list.

Different types of unordered lists
Demonstrates different types of unordered HTML lists.

Different types of ordered lists
Demonstrates different types of ordered HTML lists.

Nested list
Demonstrates nested HTML lists.

Nested list 2
Demonstrates a more complicated nested HTML list.

Description list
Demonstrates an HTML description list.


Test Yourself Exercises

Exercise 1 »    Exercise 2 »    Exercise 3 »    Exercise 4 »    Exercise 5 »   


HTML List Tags

Tag Description
<ul> Defines an unordered list
<ol> Defines an ordered list
<li> Defines a list item
<dl> Defines a description list
<dt> Defines the term in a description list
<dd> Defines the description in a description list



Your suggestion:

Close [X]

Thank You For Helping Us!

Your message has been sent to W3Schools.

Close [X]
Search w3schools.com:

WEB HOSTING

UK Reseller Hosting

WEB BUILDING

Download XML Editor FREE Website BUILDER Free HTML5 Templates FREE Website Templates Free HTML Templates

SHARE THIS PAGE

facebook