|
Week Five | Part One: List ItemsHTML Display Characteristics Review Déjà vuHTML elements (words, pictures, etc.) are written into your Web page code in four different ways:
In Week Two - Part One we looked at block-level elements. In Week Three - Part One we discovered we could change the display of block-level and in-line elements by means of the display attribute in CSS. Let's take a few minutes to examine the next type of element --- list item --- and see how we can work it into our designs. The List ItemThe list item is a unique type of block-level element. List items will force other elements underneath them just as common selectors like p, h1, and img. The difference is that list items will put some sort of marker in front of them. Usually this marker is a bullet or other special character, though it can also be a letter or a number. List items can be presented in one of three ways:
Building a ListTo create a list, you must first decide which type of list you would like to use. The tag for the type you wish to use precedes the items you want to list. For example, let's say you decide on an unordered list with three list items. Here's the code: <ul> <!-- ul stands for unordered list --> Your readers would see this:
Remember: the kind of list you chose determines what the specific item in the list will look like. If you choose an ordered list (<ol>) then every item in that list will have an ordered marker (e.g. letter or number). If you choose an unordered list (<ul>) then every item in that list will have an unordered marker (e.g. bullet or box). Nesting ListsIt is common to see instructional information organized like this:
The code for that example is tangled because there are a bunch of nested tags, but the structure is (trust me!) well-formed and valid. Let's take a look: <ol> <!-- this tag opens the entire list --> <li>This is an ordered item: <ul> <!-- this tag opens the nested unordered list --> <li>This is an unordered item. <ol> <!-- this tag opens the nested ordered list --> <li>Here is an ordered item.</li> <li>Here is another ordered item.</li> </ol> <!-- this tag closes the nested ordered list --> </li> <!-- this tag closes the list item for the unordered list --> </ul><!-- this tag closes the nested unordered list --> </li> <!-- this tag closes the first ordered list item --> <li>This is an ordered item: <!-- open --> <ul> <!-- open --> <li>This is an unordered item. <!-- open --> <ol> <!-- open --> <li>Here is an ordered item.</li> </ol> <!-- closed --> </li> <!-- closed --> <li>This is an unordered item. <!-- open --> <ol> <!-- open --> <li>Here is an ordered item.</li> </ol> <!-- closed --> </li> <!-- closed --> <li>This is an unordered item. <!-- open --> <ol> <!-- open --> <li>Here is an ordered item.</li> </ol> <!-- closed --> </li> <!-- closed --> </ul> <!-- closed --> </li> <!-- closed --> </ol> <!-- this tag closes the entire ordered list --> Next to nested tables, nested lists are probably the most intricate bit of markup writing you can perform. This may explain why designers shy away from them! There is something else going on with that example ... something I will touch on a little later in this lecture. For now, please ...
|