472,111 Members | 1,992 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,111 software developers and data experts.

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 5085
"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

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.