HTML provides three types of lists: unordered lists, ordered lists, and definition lists. In this lesson, we will learn how to create all three.
- Create unordered lists.
- Create ordered lists.
- Create nested lists.
- Create definition lists.
Ordered and Unordered Lists
There are three types of lists:
- Unordered Lists - used to create lists in which the order of the list items is not important (e.g., a grocery list or a list of people in a group).
- Ordered Lists - used to create lists in which the order is important (e.g., a recipe or setup instructions).
- Definition Lists - used to create lists containing terms and definitions (e.g, a dictionary or glossary).
Creating ordered and unordered lists in Dreamweaver is simple using the list icons in the Properties Inspector: To illustrate:
- Open ClassFiles/Dreamweaver/Exercises/Anchors-list.html in Dreamweaver.
- Place the cursor on the line with the three linked story titles.
- Click on the Unordered List icon in the Properties Inspector. Your page should appear as follows:
- Place the cursor at the end of "Pooh Goes Visiting" and delete the dividing bar:
- Press Enter:
- Place the cursor at the end of "A Mad Tea-Party," delete the dividing bar and press Enter:
- To add another bullet at the end of the list, place the cursor at the end of "The Naughty Boy" and press Enter and type a story name:
- You can add additional bullets by typing story names and pressing Enter just as you would in a typical Word processing tool.
You create ordered (or numbered) lists in the same way. In step 3 above, you would click the Ordered List icon instead of the Unordered List icon.
To create an ordered or unordered list from scratch, simply start a new paragraph and press the appropriate list icon on the Properties Inspector.
Unordered and ordered lists may be nested any number of levels deep. To illustrate:
- Open ClassFiles/Dreamweaver/Exercises/nested-list.html in Dreamweaver.
- The page is currently empty. Type "Grocery List" and make it a Heading 1.
- With the cursor below the heading, begin an unordered list by clicking on the Unordered List icon in the Properties Inspector.
- Type "Fruit" and press Enter:
- To create your nested list, press Tab (or click the Indent icon on the Properties Inspector) and type "Apples" Enter, "Pears" Enter, "Bananas" Enter:
- There are multiple ways to get back to the parent list:
- Press Enter again.
- Press Shift+Tab.
- Click the Indent icon on the Properties Inspector.
- Type "Meat" and press Enter:
- Continue with your list until it looks like this:
- To get out of a list, make sure the cursor is at the very end of the last item in the list and press Enter twice.
To convert an unordered list to an ordered list (or vice versa), click somewhere within the list (or sublist) and then click the appropriate list icon on the Properties Inspector.
Definition lists, which are used less frequently than unordered and ordered lists, are used to create lists containing terms and definitions. Dreamweaver does not provide a way to create them using the Properties Inspector. You can insert a definition list in Dreamweaver CS6 using the Insert menu:
In Dreamweaver CC:
- Select the location to place the list.
- Choose Format > List > Definition List.
- Enter the list items.
To illustrate how a definition list is added to a page:
- Open ClassFiles/Dreamweaver/Exercises/definition-list.html in Dreamweaver.
- The page is currently empty. Type "Abbreviations" and make it a Heading 1.
- With the cursor below the heading, begin a definition list: Insert > HTML > Text Objects > Definition List. You will not notice any change on the page, but if you look at the Tag Inspector on the bottom left, just above the Properties Inspector, you will see this: This indicates that you are in a defintion term (dt) within the definition list (dl).
- Type the following:
- ol Enter
- Ordered List Enter
- ul Enter
- Unordered List Enter
- dl Enter
- Definition List Enter Enter
- After pressing Enter twice at the end of the list, you should no longer be in the definition list and your page should look as follows:
The display of definition lists is a little odd, but if you learn CSS well, you will be able to change the display to look like the page below (or however else you like):
Converting Existing Content to Lists
Converting existing content to lists in Dreamweaver can be tricky. The easiest way to see this is to illustrate with an example. Our end goal is a list that looks like this:
- Open ClassFiles/Dreamweaver/Exercises/groceries.html in Dreamweaver.
- Open ClassFiles/Dreamweaver/Exercises/groceries.txt and copy and paste its entire content into groceries.html:
- Highlight everything you just pasted in and click the Ordered List icon in the Properties Inspector:
- Now we want to turn the actual food items into sublists. Highlight the three fruit items like this: And press Tab.
- That didn't work, did it? Your list probably looks like this:
- Undo using Edit > Undo Indent or by pressing CTRL+Z.
Here's the problem: those breaks that move the names of the food items to the next lines are line breaks not new paragraphs. The content that comes after them (i.e, the fruit item names) are considered part of the "Fruit" list item. So you cannot indent the individual items without indenting the "Fruit" list item as well.
The solution is to delete the line breaks:
- Place the cursor immediately before the letter "A" in "Apples" and press Backspace until "Apples" is on the same line as "Fruit":
- Press Enter to create a new list item:
- Do the same thing with "Pears" and "Bananas" and then highlight all three fruit:
- Press Tab. That should have worked:
- Now we can covert the sublist to an unordered list by highlighting all three fruit names and clicking the Unordered List icon in the Properties Inspector:
Watch as your instructor repeats this for the "Meat" and "Dairy" list items.
When working with nested lists, if things get messed up, usually the easiest thing is to get rid of the list and start over. To remove a list, highlight the whole thing and click the relevant list icon in the Properties Inspector.