Your Ad Here
HTML Basics

Bookmark and Share
HTML Lists

Lists are basic text structures. While simple in concept, lists can be very powerful in execution. There are three types of lists: unordered lists, ordered lists, and definition lists

Unordered list

The term "unordered list" may be a bit unfamiliar to you, but odds are you've heard of the "bullet list." That's exactly what an unordered list is a list of items, each one preceded by a "bullet" (small black circle).

The unordered list begins and ends with the tags <UL> and </UL> respectively. Each item in the list is marked using the <LI> tag, which stands for "List Item."

<LI> has a corresponding </LI>, but this closing tag is not required to end the list item. Although you could use one if you really wanted to. You can use as many list items as you like, up to your browser's built-in maximum, if any.

Here's the markup for a simple list:

<UL>
<LI>Monday
<LI>Tuesday
<LI>Wednesday
<LI>Thursday
<LI>Friday
</UL>

Output of the above unordered list
  • Monday
  • Tuesday
  • Wednesday
  • Thursday
  • Friday

Almost anything can be put into a list item like line breaks, entire paragraphs, images, links, or even other lists. For example:

<UL>
<LI> Learn tutorials with u3 schools
<LI> <a href="http://u3schools.com"> Learn DOM </a>
<LI><a href="http://u3schools.com"> Learn SQL </a>
    <UL>
        <LI><a href="http://u3schools.com"> Learn SQL Select</a>
        <LI><a href="http://u3schools.com"> Learn SQL Distinct</a>
        <LI><a href="http://u3schools.com"> Learn SQL Between</a>
        <LI><a href="http://u3schools.com"> Learn SQL Like</a>
    </UL>
<LI><a href="http://u3schools.com"> Learn AJAX </a>
<LI>Rate u3 schools :
    <input type="radio" name="rate" value="1"> First
    <input type="radio" name="rate" value="2"> Second
</UL>

Output of the above unordered list :

Ordered list

On the face of it, ordered lists look a lot like unordered lists, and a lot of the same rules apply to both constructs. The only difference in HTML is that instead of using <UL> and </UL>, an ordered list is contained within the tags <OL> and </OL>. Ordered lists are based on list items, just as unordered lists are.

However, when an ordered list is displayed in a Web browser, it uses an automatically generated sequence of item markers. In other words, the items are numbered. The markup for a simple ordered list, based on the first example in this section of the module (Unordered Lists):

<OL>
<LI>Monday
<LI>Tuesday
<LI>Wednesday
<LI>Thursday
<LI>Friday
</OL>

The above markup will look similar to the previously discussed simple unordered list, with the important difference that each day of the week is numbered instead of preceded by a "bullet." In other words, it looks like this:

Output for above ordered list:
  1. Monday
  2. Tuesday
  3. Wednesday
  4. Thursday
  5. Friday

Using the start attribute start your ordered list on any number besides 1.

<OL start="6">
<LI> Learn tutorials with u3 schools
<LI> <a href="http://u3schools.com"> Learn DOM </a>
<LI><a href="http://u3schools.com"> Learn SQL </a>
    <OL>
        <LI><a href="http://u3schools.com"> Learn SQL Select</a>
        <LI><a href="http://u3schools.com"> Learn SQL Distinct</a>
        <LI><a href="http://u3schools.com"> Learn SQL Between</a>
        <LI><a href="http://u3schools.com"> Learn SQL Like</a>
    </OL>
<LI><a href="http://u3schools.com"> Learn AJAX </a>
<LI>Rate u3 schools :
    <input type="radio" name="rate" value="1"> First
    <input type="radio" name="rate" value="2"> Second
</OL>

Output for above ordered list starts from 6:

There are 4 other types of ordered lists. You can replace generic numbers with Roman numberals or letters,both capital and lower-case. Use the type attribute to change the numbering.

Ordered list Type 1

<ol type="a">
    <li>list item1</li>
    <li>list item2</li>
</ol>

Output for above ordered list starts with 'a'
  1. list item1
  2. list item2

Ordered list Type 2

<ol type="A">
    <li>list item1</li>
    <li>list item2</li>
</ol>

Output for above ordered list starts with 'A'
  1. list item1
  2. list item2

Ordered list Type 3

<ol type="i">
    <li>list item1</li>
    <li>list item2</li>
</ol>

Output for above ordered list starts with 'i':
  1. list item1
  2. list item2

Ordered list Type 4

<ol type="I">
    <li>list item1</li>
    <li>list item2</li>
</ol>

Output for above ordered list starts with 'I'
  1. list item1
  2. list item2

Definition List

A definition list is not a list of items. This is a list of terms and explanation of the terms. A definition list starts with the <dl> tag. Each definition-list term starts with the <dt> tag. Each definition-list definition starts with the <dd> tag.

A simple definition list example shown below

<dl>
<dt>Definition list term1</dt>
    <dd>Definition list definition1</dd>
<dt>Definition list term2</dt>
    <dd>Definition list definition2</dd>
</dl>

Output of the above definition list
Definition list term1
Definition list definition1
Definition list term2
Definition list definition2

Today's Deal