469,290 Members | 1,922 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,290 developers. It's quick & easy.

Which content for <li>

Hi!

A stupid question (I think I have to read the spec more detailed): what kind
of content is allowed for <li>-Elements? Is this valid html:

<ul>
<li><div>somecontent</div></li>
<li><div>somecontent</div></li>
<li><div>somecontent</div></li>
</ul>

TIA

Bernd
Jul 23 '05 #1
4 5005
"Bernd Schlingenkamp" <be*****************@hotmail.com> wrote:
Hi!

A stupid question (I think I have to read the spec more detailed): what kind
of content is allowed for <li>-Elements? Is this valid html:

<ul>
<li><div>somecontent</div></li>
<li><div>somecontent</div></li>
<li><div>somecontent</div></li>
</ul>


Yes. http://www.w3.org/TR/html4/sgml/dtd.html

--
Harlan Messinger
Remove the first dot from my e-mail address.
Veuillez ôter le premier point de mon adresse de courriel.
Jul 23 '05 #2
Bernd Schlingenkamp wrote:
Hi!

A stupid question (I think I have to read the spec more detailed): what kind
of content is allowed for <li>-Elements?
You do need to read the spec, where it's very clear:

http://www.w3.org/TR/html401/struct/lists.html#h-10.2

states %flow as legal content for <li>, and the DTD:

http://www.w3.org/TR/html401/sgml/dtd.html#flow

defines %flow as any block or inline element.

Is this valid html:

<ul>
<li><div>somecontent</div></li>
<li><div>somecontent</div></li>
<li><div>somecontent</div></li>
</ul>


Yes.

--
Mark.
http://tranchant.plus.com/
Jul 23 '05 #3
"Bernd Schlingenkamp" <be*****************@hotmail.com> wrote:
Is this valid html:

<ul>
<li><div>somecontent</div></li>
<li><div>somecontent</div></li>
<li><div>somecontent</div></li>
</ul>


As others have said, it is valid. But I wonder why you ask. Why would you
like to use the <div> markup? It has no visual effect by default - inside
<li> elements, since each list item starts on a new line anyway - and it
has no semantic meaning. But it could be used for various tricks - e.g.,
if you wish to make list bullets red without affecting text color, you
could make the <ul> element's text color red but the color of <div>
elements inside <li> elements black (or whatever). And there's nothing
syntactically wrong with such tricks.

--
Yucca, http://www.cs.tut.fi/~jkorpela/
Pages about Web authoring: http://www.cs.tut.fi/~jkorpela/www.html

Jul 23 '05 #4
Okay, thank you all for your advice.
As others have said, it is valid. But I wonder why you ask. Why would you
like to use the <div> markup? It has no visual effect by default - inside
<li> elements, since each list item starts on a new line anyway - and it
has no semantic meaning. But it could be used for various tricks - e.g.,
if you wish to make list bullets red without affecting text color, you
could make the <ul> element's text color red but the color of <div>
elements inside <li> elements black (or whatever). And there's nothing
syntactically wrong with such tricks.


The idea behind this is to make a special kind of menu. Lists can be
arranged inline, horizontally. So, with divs you could arrange a container
just along the topic-entries.

Bernd
Jul 23 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

8 posts views Thread by Michael | last post: by
5 posts views Thread by toylet | last post: by
2 posts views Thread by Andrew Donaldson | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by suresh191 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.