Re: I think I've found a file that fails & shouldn't

David Thielen <dave@windward.net> wrote:

>There is a <p> ... tons of elements ... </p> but they are balanced.

As an alternate way of stating what others have allready said:

<p> elements are not allowed to nest so that when the Validator (or a
browser) sees an opening "<p>" tag it will automatically close (insert
"</p>") any <p> element that is open at that point.


<p>    <!-- Opens first P element -->
  <p>  <!-- P cannot nest; close first P before opening second P -->
  </p> <!-- Closes second P element -->
</p>   <!-- Error, there are no open P elements at this point. -->


In XHTML (which is stricter then HTML 4) you would have gotten an error at
the second <p> because in XHTML elements are not allowed to have omitted
end tags. HTML 4 is more permissive so it lets you get away with the first
implied end tag, but will then complain when you have an apparently
extraneous end tag at the end.

One good way to discover this kind of error is to turn on the Validator's
Verbose mode and look at the Parse Tree. It would have showed you where the
Validator inserted the implied </p> in the above code.

-- 
Now Playing "Strange Fruit" by "Nina Simone"",
 from the album "Feeling Good - The Very Best Of".

Received on Friday, 18 April 2003 16:10:04 UTC