PDA

View Full Version : Paragraphs and lists


mrbelfry
Wed., Jul. 20, 2005, 4:55 am
Hey there

I have a question that has been bothering me for absolutely ages and I could do with a definitive answer so I can finally get some sleep. When I am doing a list in a paragraph do I close the <p> tag before I start the list or after it? Which of these is semantically correct:

<p>This is about to be a list
<ul>
<li>Here is my list</li>
<li>It is not a long list</li>
</ul>
</p>
or

<p>This is about to be a list</p>
<ul>
<li>Here is my list</li>
<li>It is not a long list</li>
</ul>


Hope someone can help

David Gillaspey
Mon., Jul. 25, 2005, 11:53 pm
Hi MrBelfry,

Well, I don't have the definitive answer, but I devised a test to help suggest an answer. I changed your code to

<p style="font-weight:bold;margin-bottom:48px;">This is about to be a list
<ul>
<li>Here is my list</li>
<li>It is not a long list</li>
</ul>
</p>

<p style="font-weight:bold;margin-bottom:48px;">More text after test</p>

<p style="font-weight:bold;margin-bottom:48px;">This is about to be a list</p>
<ul>
<li>Here is my list</li>
<li>It is not a long list</li>
</ul>

<p style="font-weight:bold;margin-bottom:48px;">More text after test</p>

End of test

The 48 pts of space after the paragraphs is an exaggeration for the purpose of this test.

The result, when posted online, is:

http://www.greatchurchwebsites.org/art/ul_test.jpg

Notice that the excessive extra space appears after "This is about to be a list" in both examples, regardless of whether the list was enclosed by the <p> and </p> or not. What this suggests to me is that the <ul> tag sort of has a built-in </p>. That is, it effectively adds a </p> to the end of any text before.

But, so what? you ask. Well, it appears to me that the answer to your question is, it doesn't matter what you do. Either works fine; the result is the same.

Sincerely,

David Gillaspey
President
Great Church Websites

mrbelfry
Tue., Jul. 26, 2005, 3:42 am
lol - thanks David. Thanks for answering this question even though I know you are busy. This forum is a great help!

HansR
Tue., Jul. 26, 2005, 8:42 am
Hi MrBelfry,

The paragraph tag (<p>) can be used as a paired tag (with the </p>) or alone. If you are writing HTML 4.0 the end tag is not required, but the end tag, </p> is required for writing XHTML. (http://webdesign.about.com/cs/beginninghtml/a/aabg092299a.htm)

Also,

All "presentation attributes" of the p element were deprecated in HTML 4.01. (http://www.w3schools.com/tags/tag_p.asp)

Hans

David Gillaspey
Tue., Jul. 26, 2005, 11:35 am
Hi Hans,

Thanks for weighing in with a definitive answer!

Sincerely,

David Gillaspey
President
Great Church Websites

mrbelfry
Tue., Jul. 26, 2005, 12:01 pm
Hi guys

Thanks for the answers. I know that in XHTML I need to pair my <p> tags which I guess is the crux of the question. If I am including a list do I close the <p> tag before I start the list or after I've finished the list - does it even matter or does it depend on context?

mrbelfry
Tue., Aug. 23, 2005, 9:26 am
Ok - for those boring html fans here is my definitive answer that I discovered whilst working on a different problem.

The ul tag breaks the css of a p tag which makes me thing that I should close my p tags before I do a list.

Sorry to waste precious moments with this

Thanks

mrbelfry

David Gillaspey
Tue., Aug. 23, 2005, 10:16 am
Sorry to waste precious moments with this.Hi mrbelfry,

Conversations like this are never a waste of time. I know I've learned from this conversation (or thread); no doubt this is also true of other forum members. Further, this conversation becomes part of an archive that will save someone time and frustration in the future.

Sincerely,

David Gillaspey
President
Great Church Websites