Quantcast
Channel: pguides.net » html
Viewing all articles
Browse latest Browse all 10

HTML Lists

$
0
0

Lists


List Types

There are three types of lists:

  • ordered lists
  • unordered lists
  • definition lists

Syntax

A list element consists of an opening and closing ol, ul or dl tags. The contents of the list element can be any number of list item elements. The content of a list item can be another list; nested lists are possible in HTML.

Ordered List

List items in an ordered list are defined with the li tag and are usually rendered one per line and labeled with a number.

1
2
3
4
5
6
7
<p>The outcome of the horse race is:</p>
<ol>
  <li>Dave's Delivery</li>
  <li>Punkin Do</li>
  <li>Cutler</li>
  <li>Brooke's Silky</li>
</ol>

Output:

The outcome of the horse race is:

  1. Dave’s Delivery
  2. Punkin Do
  3. Cutler
  4. Brooke’s Silky

Unordered List

List items in an ordered list are defined with the li tag and are usually rendered one per line and labeled with a bullet.

1
2
3
4
5
6
7
<p>Shopping list:</p>
<ul>
  <li>Bread</li>
  <li>Milk</li>
  <li>Eggs</li>
  <li>Fish</li>
</ul>

Output:

Shopping list:

  • Bread
  • Milk
  • Eggs
  • Fish

Definition List

List items in a definition list consist of two elements – a term and a definition. A term is created using the dt tag. The corresponding definition is created using the dd tag.

1
2
3
4
5
6
7
8
9
<p>Dictionary:</p>
<dl>
  <dt>valiant</dt>
    <dd>courageous intrepid or stout-hearted; brave</dd>
  <dt>vengeful</dt>
    <dd>desiring revenge; vindictive</dd>
  <dt>vigilant</dt>
    <dd>carefully observant or attentive</dd>
</dl>

Output:

Dictionary:

valiant
courageous intrepid or stout-hearted; brave
vengeful
desiring revenge; vindictive
vigilant
carefully observant or attentive

Viewing all articles
Browse latest Browse all 10

Trending Articles