Forum Moderators: not2easy

Message Too Old, No Replies

Continuing text format after lists

surely there is a better way

         

myrrh

7:28 pm on Sep 3, 2008 (gmt 0)

10+ Year Member



When I insert a list (<ul>) in the text somewhere after a <p>, all text after the list loses its formatting, so I have to use </p> before the list and start a new <p> after the list. This gets to be a lot of <p>s and </p>s when I have a lot of lists on a page.

The person that set up my CSS did this:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">

p
{
margin:0px 12px 0px 12px;
font-size:10pt;
text-align:justify;
}

#mainc ul
{
clear: left;
margin-right:12px;
}

Surely there is a simpler way than adding all those </p> and <p> tags before and after the lists.

Marshall

7:36 pm on Sep 3, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



UL's should not be contained within a <p> element. For one thing, they are both block elements. It is correct (and necessary in XHTML) to close the <p> tag before starting something else. You can, however, put a <ul> within a <div>.

Marshall

myrrh

7:51 pm on Sep 3, 2008 (gmt 0)

10+ Year Member



So does that mean that closing the p before the lists and starting a new p after the lists like I have been doing is the correct way to do it and/or there is no better way to maintain the formatting of the text?

D_Blackwell

8:08 pm on Sep 3, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Well, <div> is block level also - strictly speaking.

I would note that the <p> element only allows inline elements within, and should not contain block-level elements, and that that this may be where the problem is coming from. With the <div> you can insert other block-level elements, such as <ul>.

You need to close the <p> before opening the <ul>, which could have the effect of 'closing' the <p> and causing problems.

It would take more code to know if there is a better way. Could be a little redesign of the HTML and CSS might reduce the code requirements and get rid of 'extra' stuff that you have now.