Lists

M

Mike Massonnet

Hello,

I'm wondering how to write lists, and especially the case where there
are sub-lists.

Which one of both is correct?

<ul>
<li>My item</li>
<ul>
<li>Sub item...</li>
</ul>
<li>EOL</li>
</ul>

Or,

<ul>
<li>My item
<ul>
<li>Sub item...</li>
</ul>
</li>
<li>EOL</li>
</ul>

I prefer the prefer because of its structure. But it doesn't looks to
be the default choice of webmasters. I see most of the time the second
case being used.

Greetz,
Mike
 
A

Andy Dingley

I'm wondering how to write lists, and especially the case where there
are sub-lists.

Go read the W3C recommendations for HTML, in particular the DTD for HTML
4.01 Strict. _This_ is what says is correct, not a tutorial somewhere
or a common preference. DTDs aren't the easiest things to learn to
read, but they're worth making the effort if you're starting to care
about such things.
Which one of both is correct?
<ul>
<li>My item
<ul>
<li>Sub item...</li>
</ul>
</li>
<li>EOL</li>
</ul>

The _ONLY_ thing you can validly out in a <ul> is a <li>

So if you want <ul> "inside" another <ul> (or a <p> inside a <ul>, or
whatver you're after), then you have to do it by having an intermediate
<li> between them, as your example shows.
 
E

Ed Seedhouse

<ul>
<li>My item</li>
<ul>
<li>Sub item...</li>
</ul>
<li>EOL</li>
</ul>

Or,

<ul>
<li>My item
<ul>
<li>Sub item...</li>
</ul>
</li>
<li>EOL</li>
</ul>

I prefer the prefer because of its structure. But it doesn't looks to
be the default choice of webmasters. I see most of the time the second
case being used.

That would be because only the second is legal html.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,780
Messages
2,569,611
Members
45,280
Latest member
BGBBrock56

Latest Threads

Top