Use of Lists
by WebAIM
Using Lists Correctly
HTML lists -
<ul>
, <ol>
, and
<dl>
- also convey a hierarchical content
structure. Each of these has rules regarding their use as well. Unordered
lists should be used when there is no order of sequence or importance.
Ordered lists suggest a progression or sequence. Definition lists should be
used explicitly for presenting a structure for definitions. As with heading,
lists should be used correctly and for the right purposes. Unordered and
ordered lists should always contain list items. Definition lists must always
have definition descriptions. Empty lists are incorrect
HTML. Lists should
never be used for merely indenting or other layout purposes. Nested lists
should be coded properly.
Unordered Lists
An unordered list is a list of items that are marked with bullets (typically small black circles).
HTML 3.0 gives you the ability to customize the bullets, to do without
bullets and to wrap list items horizontally or vertically for multicolumn
lists.
The opening list tag must be <ul>. It is followed by an optional list header (<lh>caption</lh>) and then by the first list item (<li>).
Example:
<ul>
<li>Coffee</li>
<li>Milk</li>
</ul>
Here is how it looks in a browser:
Inside a list item you can put paragraphs, line breaks, images, links, other lists, etc.
Ordered Lists
An ordered list typically is a numbered list of items. HTML 3.0 gives you
the ability to control the sequence number - to continue where the previous
list left off, or to start at a particular number. The numbering style is
left to associated style sheets, e.g. whether nested lists contribute to a
compound item number, e.g. "3.1.5", or whether numbers are rendered as
Arabic, upper or lower case roman numerals or using the numbering scheme
appropriate to the language context.
An ordered list starts with the <ol> tag. Each list item starts with the <li> tag.
<ol>
<li>Coffee</li>
<li>Milk</li>
</ol>
Here is how it looks in a browser:
- Coffee
- Milk
Inside a list item you can put paragraphs, line breaks, images, links, other lists, etc.
Definition Lists
A definition list is not a list of items. A definition list is a list of terms and corresponding definitions. Definition lists are typically formatted with the term on the left with the definition following on the right or on the next line. The definition text is typically indented with respect to the term.
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.
<dl>
<dt>Coffee</dt>
<dd>Black hot drink</dd>
<dt>Milk</dt>
<dd>White cold drink</dd>
</dl>
Here is how it looks in a browser:
- Coffee
- Black hot drink
- Milk
- White cold drink
Inside a definition-list definition (the <dd> tag) you can put paragraphs, line breaks, images, links, other lists, etc.
posted on Jun 6, 2007