By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,625 Members | 2,261 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,625 IT Pros & Developers. It's quick & easy.

does <ul> tag end <p> tag? What about others?

P: n/a
Hi,

the subject say quite a lot. I have about the following code(4.01
transitional):

<p>blaa blaa blaa
<ul>
<li><a href="foo.html">foo</a></li>
<li><a href="bar.html">bar</a></li>
</ul>
blaa
</p>

And validator says it says "end tag for element "P" which is not open". I
find this a bit strange. If I haven't explictly ended the <p> tag then how
can the <ul> tag end it? Damn I want to say where it ends. Are there any
other tags that can end other tags as well?
Jul 20 '05 #1
Share this Question
Share on Google+
9 Replies


P: n/a
On Wed, 26 May 2004 05:38:40 +0300, Akseli Mäki
<ne********@spam.akseli.net> wrote:
Hi,

the subject say quite a lot. I have about the following code(4.01
transitional):

<p>blaa blaa blaa
<ul>
<li><a href="foo.html">foo</a></li>
<li><a href="bar.html">bar</a></li>
</ul>
blaa
</p>

And validator says it says "end tag for element "P" which is not open". I
find this a bit strange. If I haven't explictly ended the <p> tag then
how
can the <ul> tag end it? Damn I want to say where it ends. Are there any
other tags that can end other tags as well?


Basically: p cannot contain ul, so once ul comes along, p has to close
implicitly.

If you're up to it, read through the DTD and see which elements can
contain what kinds of elements. It's enlightening. And hard. But worth it.
If you want to know what you're doing, you'll have to make it through it
someday.
Jul 20 '05 #2

P: n/a
Neal wrote:
If you're up to it, read through the DTD and see which elements can
contain what kinds of elements. It's enlightening. And hard. But worth
it. If you want to know what you're doing, you'll have to make it
through it someday.


Right. Although I'd recommend to start with the spec itself
(http://www.w3.org/TR/html401) and only then graduate to the DTD.
Without some background, I am afraid the DTD might a little, mmh, terse...

--
Bertrand Mollinier Toublet
closity = 1.0 / farthitude
-- Arthur J. O'Dwyer
Jul 20 '05 #3

P: n/a
On Tue, 25 May 2004 20:33:13 -0700, Bertrand Mollinier Toublet
<be*****************************@enst-bretagne.fr> wrote:
Neal wrote:
If you're up to it, read through the DTD and see which elements can
contain what kinds of elements. It's enlightening. And hard. But worth
it. If you want to know what you're doing, you'll have to make it
through it someday.


Right. Although I'd recommend to start with the spec itself
(http://www.w3.org/TR/html401) and only then graduate to the DTD.
Without some background, I am afraid the DTD might a little, mmh,
terse...


You are certainly correct - I typed DTD meaning the spec. Though for many
there is no appreciable difference...
Jul 20 '05 #4

P: n/a
Neal wrote:
On Wed, 26 May 2004 05:38:40 +0300, Akseli Mäki
<ne********@spam.akseli.net> wrote:
Hi,

the subject say quite a lot. I have about the following code(4.01
transitional):

<p>blaa blaa blaa
<ul>
<li><a href="foo.html">foo</a></li>
<li><a href="bar.html">bar</a></li>
</ul>
blaa
</p>

And validator says it says "end tag for element "P" which is not open". I
find this a bit strange. If I haven't explictly ended the <p> tag then
how
can the <ul> tag end it? Damn I want to say where it ends. Are there any
other tags that can end other tags as well?

Basically: p cannot contain ul, so once ul comes along, p has to close
implicitly.

If you're up to it, read through the DTD and see which elements can
contain what kinds of elements. It's enlightening. And hard. But worth
it. If you want to know what you're doing, you'll have to make it
through it someday.


Reading the DTD might be a little hard for a beginner, as Akseli
appears to be.

Akseli, you should keep these links bookmarked, or print them out if you
like. Then, when you want to lookup whether an element can contain
another, or what attributes it has, or whatever else you want to know;
you can find by simply looking for the element name in either of these
indexes.

HTML 4.01 Index of Elements
http://www.w3.org/TR/html401/index/elements.html

XHTML 1.0
http://www.w3.org/TR/xhtml1/

XHTML 1.1
http://www.w3.org/TR/xhtml11/
XHTML 1.1 Document Type (Element List)
http://www.w3.org/TR/xhtml11/doctype.html#s_doctype

List of Valid DTDs
(Has a good template at the end to use)
http://www.w3.org/QA/2002/04/valid-dtd-list.html

HTML 4.01, XHTML 1.0 and 1.1 all contain essentially the same
elements, except XHTML 1.1 makes a few additions and changes that you
should be aware of [1 and 2]. I recommed avoiding the deprecated
elements and attributes, and try to stick to the XHTML 1.0 Strict DTD.
[1] http://www.w3.org/TR/xhtml11/changes.html
[2] http://www.w3.org/TR/2002/NOTE-xhtml...20801/#summary
Jul 20 '05 #5

P: n/a
In article <r6********************************@4ax.com>,
Akseli Mäki <ne********@spam.akseli.net> writes:
the subject say quite a lot. I have about the following code(4.01
transitional):

<p>blaa blaa blaa
<ul>

And validator says it says "end tag for element "P" which is not open". I


Feed that into the Visual Validator view at Page Valet, and all becomes
much clearer. It'll show you the document tree (including the implied </p>)
with errors and warnings highlighted where they arise.

--
Nick Kew

Nick's manifesto: http://www.htmlhelp.com/~nick/
Jul 20 '05 #6

P: n/a
Neal wrote:
Basically: p cannot contain ul, so once ul comes along, p has to close
implicitly. Ok. That's not exactly the way I would like it to be, though.
If you're up to it, read through the DTD and see which elements can
contain what kinds of elements. It's enlightening. And hard. But worth it.
If you want to know what you're doing, you'll have to make it through it
someday.

Well, ever since I started writing HMTL I've had a local copy of the
defination. I published my first homepages in 14th of June 2001. But that
doesn't make me a expert in any way, since my HTML is very simple.

On the defination of <p> tag it says "It cannot contain block-level
elements (including P itself)." It has a link but I couldn't find a list of
the elements that are block-level. So where exactly can I find information
about this particular thing, what elements can contain what other elements?
Jul 20 '05 #7

P: n/a
On Wed, 26 May 2004 16:49:49 +0300, Akseli Mäki
<ne********@spam.akseli.net> wrote:
Neal wrote:
Basically: p cannot contain ul, so once ul comes along, p has to close
implicitly.

Ok. That's not exactly the way I would like it to be, though.


Sorry. :) Sounds to me you want div instead of p, and CSS it up to look
how you like.
If you're up to it, read through the DTD and see which elements can
contain what kinds of elements. It's enlightening. And hard. But worth
it.
If you want to know what you're doing, you'll have to make it through it
someday.

Well, ever since I started writing HMTL I've had a local copy of the
defination. I published my first homepages in 14th of June 2001. But that
doesn't make me a expert in any way, since my HTML is very simple.

On the defination of <p> tag it says "It cannot contain block-level
elements (including P itself)." It has a link but I couldn't find a list
of
the elements that are block-level. So where exactly can I find
information
about this particular thing, what elements can contain what other
elements?


In a nutshell - any element that automatically goes to the left margin is
considered block-level. That's not precisely true, but it's a general
rule. In-line elements don't invoke a line break. They can go in p.

Jul 20 '05 #8

P: n/a
Akseli Mäki <ne********@spam.akseli.net> wrote:
On the defination of <p> tag it says "It cannot contain block-level
elements (including P itself)." It has a link but I couldn't find a
list of the elements that are block-level. So where exactly can I
find information about this particular thing, what elements can
contain what other elements?


There are various resources on this, in books and elsewhere. There's a
practical, very useful presentation at
http://www.htmlhelp.com/reference/html40/alist.html
where each element is presented with "Contents" and "Contained in" lists.
And there's a different, somewhat confusing presentation of nesting rules
at http://www.cs.tut.fi/~jkorpela/html/nesting.html

By the way, the elements that may lack an end tag in HTML 4 are:
</body>, </colgroup>, </dd>, </dt>, </head>, </html>, </li>, </option>,
</p>, </body>, </td>, </tfoot>, </th>, </thead> ja </tr>. This follows
from the DTD. However, it has always been good practice to close all
elements explicitly. For example,
<p>foo<table>...
is by HTML 4 specification just a shorter form of writing
<p>foo</p><table>...
but browsers have been observed to treat them differently (e.g., by not
leaving a margin below the p element).

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

Jul 20 '05 #9

P: n/a
"Jukka K. Korpela" <jk******@cs.tut.fi> wrote in message
news:Xn*****************************@193.229.0.31. ..
By the way, the elements that may lack an end tag in HTML 4 are:
</body>, </colgroup>, </dd>, </dt>, </head>, </html>, </li>, </option>,
</p>, </body>, </td>, </tfoot>, </th>, </thead> ja </tr>. This follows
from the DTD. However, it has always been good practice to close all
elements explicitly. For example,
<p>foo<table>...
is by HTML 4 specification just a shorter form of writing
<p>foo</p><table>...
but browsers have been observed to treat them differently (e.g., by not
leaving a margin below the p element).


And NN4 has been observed to go berserk.
Jul 20 '05 #10

This discussion thread is closed

Replies have been disabled for this discussion.