Lab 3
Page 6


Using Lists

Lists are one of the best organizational tools that HTML provides for use on your web pages. They group text items into numbered, bulleted or indented lists.


Ordered Lists

Perhaps the most common type of list is the "ordered list." Once you open such a list, the web browser will automatically number and indent each item on the list for you. This way, you can add and remove and rearrange items without having to worry about changing your entire numbering scheme.

The first step in using any list is to let the browser know that you want to begin keeping a list. For an ordered list, this is done by typing the <ol> tag in your HTML file. Usually, you'll just want to put it alone on an otherwise blank line.

Next, type <li> to indicate a list item. When displayed, this will start a new line with the correct number and indentation. Also on that line, type whatever you would like to appear next to that number.

When you have finished your first list item, you can follow it with however many others you wish by simply typing a <li> and some text for each.

Finally, when you are ready to finish the list, type in </ol> to close it.

Here is an example of an ordered list:

What you write in your HTML file
How it looks on your web page
<ol>
<li> CS111 homework
<li> Call home
<li> Sleep
</ol>
  1. CS111 homework
  2. Call home
  3. Sleep

Unordered Lists

Unordered lists are nearly identical to ordered lists, except the browser does not automatically number the list items for you. Instead, it uses symbols such as a little box or a circle to mark each list item.

You can create an unordered list in the exact same way as an ordered list. Just use the <ul> </ul> tags instead of <ol> </ol>.

Here's a sample unordered list:

What you write in your HTML file
How it looks on your web page
<ul>
<li> CS111 homework
<li> Call home
<li> Sleep
</ul>
  • CS111 homework
  • Call home
  • Sleep

Definition Lists

Definition lists are somewhat different than ordered and unordered lists. Rather than long indented, bulleted lists, definition lists usually alternate between terms (enclosed in <DT> and </DT>) and indented definitions associated with those terms (enclosed in <DD> and </DD>).

Opening and closing a definition list is much like opening and closing any other list. Simply type <DL> to open one and </DL> to close it.

Within the list, you can use two different types of list items. To create a non-indented list item, simply surround some text with <DT> and </DT>. To create an indented list item, surround it with <DD> and </DD>.

Here's an example of a definition list:

What you write in your HTML file
How it looks on your web page
<dl>
<dt> Computer
<dd> Machine which computes
<dt> Mouse
<dd> Small, furry rodent
<dt> Egg
<dd> Breakfast treat
</dl>
Computer
Machine which computes
Mouse
Small, furry rodent
Egg
Breakfast treat

Other Facts About Lists

Here is a giant list sampler:

What you write in your HTML file
How it looks on your web page
<ol>
<li> This is the first element
<li> Get ready... <ul>
<li> Here's an embedded list!
<li> Isn't this fun?
</ul>
<li> We're back to the main list
<li> Let's <i> italicize </i>
<li> <a href=http://www.microsoft.com > Link to Microsoft </a>
</ol>
  1. This is the first element
  2. Get ready...
    • Here's an embedded list!
    • Isn't this fun?
  3. We're back to the main list
  4. Let's italicize
  5. Link to Microsoft


Adding lists to your page

  1. Add a header to your page (underneath your paragraphs) that is called "My Interests" or something similar.
  2. Use one of the three types of lists to list at least 3 hobbies or interests underneath the header.

PREVIOUS 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 NEXT