HTML and CSS Reference
Q: I think I basically understand how block elements and
inline elements are displayed by the browser, but I'm totally
confused about what elements can go inside other elements, or,
as you say, what can be “nested” inside of what.
A: That's one of the hardest things to get straight with HTML. This
is something you're going to be learning for a few chapters, and we'll
show you a few ways to make sure you can keep the relationships
straight. But we're going to back up and talk about nesting a little
more first. In fact, since you brought it up, we'll do that next.
Q: So HTML has ordered and unordered lists. Are there any
other list types?
A: Actually, there is another type: definition lists. A definition list
looks like this:
<dt>Burma Shave Signs</dt>
<dd>Road signs common in the U.S. in
the 1920s and 1930s advertising shaving
<dd>Most famous road in the U.S. highway
Q: Burma Shave?
A: Burma Shave was a company that made brushless shaving
cream in the early part of the 20th century. They began advertising
their product using roadside signs in 1925, and these signs proved to
be very popular (if somewhat distracting for drivers).
Q: Do I always have to use <ol> and <li> together?
A: Yes, you should always use <ol> and <li> together (or <ul> and
<li>). Neither one of these elements really makes sense without the
other. Remember, a list is really a group of items: the <li> element
is used to identify each item, and the <ol> element is used to group
Q: Can I put text or other elements inside an <ol> or <ul>
A: No, the <ol> and <ul> elements are designed to work only with
the <li> element.
Q: What about unordered lists? Can I make the bullet look
A: Yes. But hold that thought. We'll come back to that when we're
talking about CSS and presentation.
Q: What if I wanted to put a list inside a list? Can I do that?
A: Yes, you sure can. Make the content of any <li> either <ol> or
<ul>, and you'll have a list within a list (what we call a nested list ).
<li>Pack for trip
<li>a protein bar</li>
Each item in the list
has a term, <dt>, and
a description, <dd>.
Type this in and
give it a try.
Here' s the
the n ested
The signs were grouped in bunches of four, five, or six, each with one
line from the slogan. At one point, there were 7,000 of these signs
on roadsides throughout the United States. Most are gone now, but
there are still a few left, here and there.