HTML and CSS Reference
In-Depth Information
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:
<dl>
<dt>Burma Shave Signs</dt>
<dd>Road signs common in the U.S. in
the 1920s and 1930s advertising shaving
products.</dd>
<dt>Route 66</dt>
<dd>Most famous road in the U.S. highway
system.</dd>
</dl>
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
them together.
Q: Can I put text or other elements inside an <ol> or <ul>
element?
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
different?
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 ).
<ol>
<li>Charge Segway</li>
<li>Pack for trip
<ul>
<li>cell phone</li>
<li>iPod</li>
<li>digital camera</li>
<li>a protein bar</li>
</ul>
</li>
<li>Call mom</li>
</ol>
Each item in the list
has a term, <dt>, and
a description, <dd>.
Type this in and
give it a try.
Here' s the
<li>. It
enclo ses
the n ested
list.
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.
Search WWH ::




Custom Search