4.1. Understanding Lists

Both ordered and unordered lists share a similar syntax in XHTML, as shown in the following pseudocode example:

<list_tag>
  <item_tag>List item</item_tag>
  <item_tag>List item</item_tag>
  <item_tag>List item</item_tag>
</list_tag>

Definition lists are different in syntax due to their unique structure—that is, two items for each list element. See the section on definition lists later in this chapter for more information.

Each list is encapsulated in opening and closing list tags, and each list element in turn is encapsulated in opening and closing list item tags.

Ordered lists have their list items prefixed by incrementing numbers or letters indicating the order of the items. Unordered lists have their list items prefixed by a bullet or other symbol, indicating that their order does not matter.

The following is an example of an ordered list:

  1. Choose Open from the File menu.

  2. Use the File Open dialog to navigate to the file you want to open.

  3. Double-click the file or click the file and then click the Open button.

The following is an example of an unordered list:

  • Banana

  • Chocolate

  • Strawberry

Definition lists have two pieces of information per list item, usually a term and a definition, as shown in the following example:

  • Mozilla

  • Developed by the Mozilla Project, an open source browser for multiple platforms

Ordered and unordered lists have many options that can be used to customize their appearance.

  • Ordered lists can have their items preceded by the following:

    • Arabic ...

Get Web Standards Programmer's Reference: HTML, CSS, JavaScript®, Perl, Python®, and PHP now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.