Paul Wellner Bou <pa**********@united-scripts.com> writes:
If I wrap the code in PRE tags, then this fixes it.
It shouldn't. Browserbug... :-)
Not really,
The pre tag wrapper have the correct end tag, so the implicit missing
end tag for the divs are placed before the end tag of the pre element.
You could do the same by wrapping it in any block level element,
except div.
Example:
Incorrect code:
<body>
<div> foo <\div>
<div> bar <\div>
</body>
Browser interprets this as:
<body>
<div> foo <div>
<div> bar <div>
</div></div></div></div>
</body>
This is "correct" behavior (or at least expected). The end tag of div
elements are not optional, but the browsers are forgiving and accepts
it when you leave them out. It inserts the end tags where they are
needed. The </body> terminates an element that started before the
divs, so the divs need to be terminated first to preserve proper
nesting. You could see this pattern when looking at the innerHTML
of the generated page.
Incorrect code with pre's:
<body>
<pre><div> foo <\div></pre>
<pre><div> bar <\div></pre>
</body>
Browser interprets this as:
<body>
<pre><div> foo <div></div></div></pre>
<pre><div> bar <div></div></div></pre>
</body>
Here the pres force the divs to end, so they are not nested. It was
the nesting that positioned the elements incorrectly.
The code is illegal HTML, but tag-soup-browser error correction is
fairly predictable.
/L
--
Lasse Reichstein Nielsen -
lr*@hotpop.com
Art D'HTML: <URL:http://www.infimum.dk/HTML/randomArtSplit.html>
'Faith without judgement merely degrades the spirit divine.'