=========================================================================== Today on The World Vol. 4 #153 Friday, June 12, 1998 =========================================================================== So, have you recovered from my Web interoperability rant in the previous installment? Back to the HTML tutorial... now we get into the more exotic stuff. We'll start with lists, which are not that difficult to learn. (Next week, after a brief detour into the world of "entities", we'll tackle a subject that baffles many HTML authors: tables. The part about tables will build on what I discuss today regarding lists.) (kibo) --------------------------------------------------------------------------- HTML TUTORIAL -- CHAPTER 7 -- LISTS 7.1 Basic lists A "list", in HTML, is what its name implies -- a list of things, displayed as a normal human-readable list that looks like this: 1. Apples 2. Bananas 3. Coconuts You could make that out of
's, but it's hard to keep everything lined up, and of course you'd have to renumber all the items every time you add one in the middle. Fortunately, HTML has all sorts of tags that make lists for you. HTML lists count as a kind of text container, like
...
,.... There are several kinds of lists (most of which you'll never use) but they all share a common feature: The list itself is a pair of tags (such as
, , and .)Nested Example of "UL"
Wow, that's complicated-looking. I tried to indent things to make it clear what was happening. Basically, each
- Apples
- Red
- Yellow
- Green
- Granny Smith
- Unripe
- Moldy
- Bananas
- Coconuts
...
contains only- ...
's. A couple of the- ...
's contain another complete list. So the third item under "Apples" is "Green" plus a list. (Find the that goes with "Green", several lines down.) Your Web browser may use three different symbols to indicate the three different levels of nesting here, such as large and small bullets or boxes. (Incidentally, if I hadn't indented the HTML above, the Web browser would have still displayed things the same way -- the fact that the code is indented the same way the browser displays the lists is just me trying to make the code readable. It could actually have all been on one long line.) Try changing all thes to
s as well!) and see what happens. Now, try this:s (don't forget to change the
Fancy Example of "OL"
Nesting
- Apples
- Red
- Yellow
- Green
- Granny Smith
- Unripe
- Moldy
- Bananas
- Coconuts
inside itself doesn't use different number schemes for the nested lists by default (unlike
, which usually shows up with different kinds of bullets) but
does take an option to let you specify whether you want numbers, Roman numerals, or letters (capitals or lowercase.) Do you see how the above
s specified this? (Older browsers may not support TYPE, as it was introduced by Netscape.) You can also change the shape of the
's bullets in browsers that support Netscape's tags (that is, newer versions of Netscape Navigator and Microsoft Internet Explorer) with
, etc. You can also ask the browser to pack the lines of text more closely together with
or
but many do not do anything in this regard. Similar to
- ...
(list items) is... (list heading). It displays much like- except without a leading bullet or number. (Some browsers may make it bolder than
- , most don't.) Try adding this before the first
- of one of the other examples:
This is a list. It may not look thrilling, but remember that you can mark it up with text-styling tags like or :This is a list. Why isn't that just a? Because those don't go inside lists for the same reason they don't go inside
, and
doesn't go inside
. Headers and lists and
's are mutually exclusive kinds of text containers. (I keep mentioning this point because it becomes even more important in a few chapters when we get to tables. Also, not nesting things inside things that they shouldn't go in decreases the chances that your page will come out "weird" in exotic browsers.) 7.2 Definition lists There's one more kind of HTML list, and it's very useful, but it's different from the others:
...
is a "definition list". Instead of containing- ...
lines, it contains- ...
- ...
lines, which stand for the "definition term" and "definition definition". (Hey, I didn't make up this syntax.) In other words, every line of ahas two parts, and the first is assumed to be relatively short. Here's an example to try:
Remember that you can put stuff like , , or in part or all of the
Definition list example - Apples
- are a popular Earth fruit which can be red, green, or yellow. Most of them run Mac OS but a few run Linux.
- Bananas
- are most often used to injure clowns, after throwing away the fruit inside. The names of Sid and Marty Krofft's "Banana Splits" were Drooper, Fleagle, Plato, and Snork.
- Coconuts
- look like bowling balls, and they taste pretty similar to a freshly-waxed ball. In the Marx Brothers' "Cocoanuts", an early "talkie", note that when Groucho reads the newspaper it's soaking wet, because the microphone had to be very close.
- or
- lines to make things stand out. Try changing all three items in the example
to have a big
- and an italic
- , as in:
- Apples
- are a popular Earth fruit which can be red, green, or yellow. Most of them run Mac OS but a few run Linux.
- ...
and- ...
must go together -- you can't leave out one of them. You can put empty ones in to do special things:Like
- Apples
- Pears
- These fruits are known as Nature's Toothbrush and Nature's Other Toothbrush.
- This is a second paragraph about apples and pears.
and
,
can have an optional attribute for more compact spacing (
) in which case the
- is assumed to be very short (a single word) so that the
- can follow on the same line. And like
and
,
isn't supported by most browsers (attributes like this are simply ignored by browsers that don't understand them -- in fact, any sort of unknown or misspelled tag is generally ignored. A tag with an unknown option is considered to be the tag without the option.) 7.3 Notes on lists I didn't mention
instead. (
, and
an unbulleted in narrow columns. Options of
can be used to make these same styles; see the reference chart below.) By the way, don't confuse the
tag with the DIR option (as in ) used for making text run from right to left for Hebrew and Arabic. (You'll likely never need either
or DIR in any case.) The list tags like and
, and the
- tag for list items, are supposed to take ALIGN="CENTER" or ALIGN="RIGHT" options like
or
but the browsers I've tried don't seem to do anything except left- aligned lists. Supposedly ALIGN="CENTER" is supposed to center items within the list. LIST TAGS
...
Unordered list, usually with bullets. Contains only... and- ...
lines.Without bullets.
More compact spacing.
Solid bullets (level 1).
Hollow bullets (level 2).
Hollow squares (level 3).
...
Ordered list, usually with numbers. Contains only... and- ...
lines.More compact spacing.
Numbers.
Capital letters. THIS OPTION IS CASE-SENSITIVE!
Lowercase letters.
Roman numerals (capitals).
Roman numerals (lowercase). Menu list (plain) -- not widely used. Use
instead.
... Directory list (multiple columns) -- not widely used. Useinstead.
- ...
List item. Use only inside...
or...
.... List heading. Use only in...
or...
....
Definition list. Contains only- ...
- ...
lines (must have both- and
- on every line) or
... lines. Do not use- ...
.More compact spacing, if
- ...
is very short.- ...
Definition list term. First half of each line in...
.- ...
Definition list definition. Second half of each line in...
. (kibo) ========================================================================== [] Send suggestions for tips & URLs to today@world.std.com. We're also collecting links for our Web pages at eyeguy@world.std.com. [] To contact CUSTOMER SUPPORT, send mail to support@world.std.com or call 617-739-0202. [] To subscribe to the "Today" mailing list, send a note saying 'subscribe announcements' to majordomo@world.std.com. Subscriptions to this mailing list are open to World customers only. [] Does anyone notice when I forget to change this line every day? [] Today on The World is (C) Copyright 1998 by Software Tool & Die. Its contents may freely be redistributed as long as credit is given.