Thursday, January 15, 2009

HTML supports three kinds of lists.

The first kind is a bulletted list, often called an unordered list. It uses the <ul> and <li> tags.
HTML Code :
<ul>
<li>the first list item</li>
<li>the second list item</li>
<li>the third list item</li>
</ul>
  • the first list item
  • the second list item
  • the third list item
Note that you always need to end the list with the </ul> end tag, but that the is optional and can be left off.

The second kind of list is a numbered list, often called an ordered list. It uses the <ol> and <li> tags.
HTML Code :
<ol>
<li>the first list item</li>
<li>the second list item</li>
<li>the third list item</li>
</ol><br>
  1. the first list item
  2. the second list item
  3. the third list item

Like bulletted lists, you always need to end the list with the </ol> end tag, but the end tag is optional and can be left off.

The third and final kind of list is the definition list.
This allows you to list terms and their definitions.
This kind of list starts with a <dl> tag and ends with </dl>
Each term starts with a <dt> tag and each definition starts with a <dd>.
HTML Code :
<dl>
<dt>the first term</dt>
<dd>its definition</dd>
<dt>the second term</dt>
<dd>its definition</dd>
<dt>the third term</dt>
<dd>its definition</dd>
</dl>
the first term
its definition
the second term
its definition
the third term
its definition
The end tags </dt> and </dd> are optional and can be left off.
Note that lists can be nested, one within another.

The last HTML Code :
<ol>
<li>the first list item</li>
<li>the second list item
<ul>
<li>first nested item</li>
<li>second nested item</li>
</ul>
</li>
<li>the third list item</li>
</ol>
  1. the first list item
  2. the second list item
    • first nested item
    • second nested item
  3. the third list item
You can also make use of paragraphs and headings etc. for longer list items.