Forum Moderators: open

Message Too Old, No Replies

<ul> inside <p></p> means NN4 forgets positions?

I just lost half a day on this one

         

tedster

8:39 am on May 15, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I just ran into the oddest thing, and thought I'd mention it so that maybe someone else doesn't lose half a day the way I just did.

I still need to support NN4 for several clients, but I want to go with the most up-to-date and valid code that I can write. So I'm in hybrid land with lots of CSS, but the occasional layout table in addition to absolutely positioned divs. I try for valid code (layout tables do validate after all) but most of all, I need to be pragmatic.

I had a pretty sweet template, it performed well in all browsers, so I was just cranking out the pages. I did a routine browser test on a minor font size issue, and all of a sudden saw that NN4 was messing up the position of an absolutely positioned div.

I went to other pages, and most of them rendered just fine but a few had the same problem. Same template, just different text!

As I pokde around, I began to see a pattern - all the incorrectly positioned pages had bulleted lists <ul>. After some more poking, I did an experiment. The lists all appeared within a set of <p></p> tags. But if I closed the paragraph before the list began, instead of including the list, then the page rendered just fine.

Who would have thought?

Eric_Jarvis

10:36 am on May 15, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I would

<p> makes sense inside a list, but a list can't possibly make sense as part of a paragraph...it's always worth making sure the mark up makes sense, it helps avoid exactly this sort of thing

tedster

11:36 am on May 15, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I can see that viewpoint, Eric, but it just didn't occur to me.

In fact, I can still see it both ways. These paragraphs were like this - "Here are some of the services we offer:" followed by a bulleted list. From a meaning-based point of view, the list seemed like part of the paragraph to me. I never gave it a thought.

I now see that lists need their own font declarations in CSS [unless they're illegally inside a paragraph ;)] so it's clear that HTML structure considers a list to be a different critter than a paragraph.

The W3C validator picks up this error, but Homesite/CSE did not. It's just growing pains for me. I never used </p> tags before this project.

Eric_Jarvis

12:41 pm on May 15, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I tend to treat html as if it were a really picky grammar teacher...sometimes I find it hard work...but it gets easier...slowly

tedster

4:00 pm on May 15, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



LOL! That's about right.

In this case, because the </p> is not required except in XHTML, it got very fuzzy for me (and apparently for Homesite and CSE).

The W3C Validator said "</p> tag found when the <p> tag is not open" - something like that anyway. So apparently the minute a <ul> or <ol> tag comes along the <p> tag is assumed closed, just as it would be if another <p> tag were encountered.

Live and learn - I won't do that again. A very painful 4 to 5 hours. Still, what a surprising thing to see the absolute position of the div change as a result!

papabaer

4:39 pm on May 15, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Tedster, that is a great example for the beneifits if validation - I test my Homesite pages by previewing in Opera and hitting Ctrl + Alt + V for quick access to the W3C Validator.

</p>.... ALWAYS a good idea! ;)

pageoneresults

4:50 pm on May 15, 2002 (gmt 0)

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



Ouch! That ending </p> tag has been known to be the culprit of many problems. I've always had ending </p> and </li> tags in my code. A few years ago there were authoritative sites that stated you did not need the </p> or </li> tags. How wrong they were!

tedster

4:50 pm on May 15, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



papabaer, you must not be on a dial up connection!

I get around to W3C checks, but during development I stick with the local validators to catch most errors. I was very surprisd that this got missed - that almost never happens.

papabaer

2:17 am on May 16, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Yeah, DSL is nice! lol!

But seriously, I solve the problem by using TIDY set to XHTML, it makes certain I don't leave any opened tags...

Not much gets past TIDY for the W3C Validator to catch, though I have a few scars from when I got cocky and thought, "Sure, it's valid!" Which usually occured after I went back and made "quick" changes to the page code.

Tidy can also be customized (American English spelling - see other thread) through a simple text editor. You can modify spacing and indents as well as just about everything else.

- papabaer