473,320 Members | 1,900 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

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

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
9 6813
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
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
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
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
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
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
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
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
"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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: bearclaws | last post by:
I am looping through a list of categories and want to display the list horizontally (instead of vertically). I want to create a single row with 4 list items in each cell of the row. I thought...
4
by: abs | last post by:
Anybody has an idea how to get the <ul> element which is not nested in <li> element ? In other words I have several lists like this: <ul id="1"> <li>Aaaaaaaa</li> <li>Bbbbbbbb</li>...
2
by: Shaun | last post by:
Hello! I have a quick question regarding CSS and having it applied to all elements. I am trying to eliminate the gap between a paragraph and a list that usually occurs in html and I've found...
4
by: opt_inf_env | last post by:
Hello, I have the following part of code sentence_1 <ul> <li> sentence_2 </ul> And I would like to decrease distance between sentence_1 and
11
by: namenotgivenhere | last post by:
My design goal is to make the white space above and below <p> and <ul> equal to the height of my font. The first step to achieving this I believe is to have an equal amount of white space above or...
5
by: Syl | last post by:
Hello experts!! The top menu navigation bar displays perfectly in IE, but does not display properly in Mozilla or Netscape : http://checkeredshirt.com/textonly.html For some reason the non-IE...
6
by: capricious | last post by:
Is it possible, so that when you do multiple <UL>'s to control how deep the UL's are marked? For example, it would defaultly look like this with multiple ULs and LIs: -- Code : Main...
7
by: turnernm | last post by:
error: document type does not allow element "ul" here; missing one of "object", "ins", "del", "map", "button" start-tag what i wanted in my site was to float an img to the left and a list to the...
1
by: Chinsu | last post by:
<html> <head> <style> #ex { width: 700px; background: red; float: left; } a, span { display: block;
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.