|
Posted by Sherm Pendley on 08/03/07 21:42
Jeff Dege <jdege@jdege.visi.com> writes:
> Turns out that "<br />" is legal in both html 4.01 and in xhtml 1.0
That's not legal in HTML, just XHTML. A browser will probably just ignore
the / and interpret it as <br>, which doesn't have a closing tag, so the
error correction will usually do what you intended. But that's a far cry
from it being "legal in HTML."
>, but
> that "<div />" is legal in xhtml 1.0, but illegal in html 4.01.
It's legal in XHTML. Your page is being parsed as HTML.
> And now I'm more confused than before, because the document I was having
> trouble with had an xhtml 1.0 DOCTYPE - which means that self-closing
> div's should have been correct code.
>
> But both IE6 and Firefox 2.0 proceeded to treat the page as if they
> weren't.
Of course they do. That's what serving XHTML as text/html does; it causes
browsers to use their HTML parsers, treating your content as broken HTML
rather than XHTML.
How do I know you're serving it as text/html? Easy - if you were serving
it with the correct text/xhtml+xml, IE wouldn't be parsing it at all.
This is why many of the regulars here view XHTML as interesting in theory,
but impractical in practice. You can only get IE to parse it by lying about
the content-type, but if you do that, your page will be parsed using HTML
rules. That being the case, you're better off just serving HTML.
sherm--
--
Web Hosting by West Virginians, for West Virginians: http://wv-www.net
Cocoa programming in Perl: http://camelbones.sourceforge.net
Navigation:
[Reply to this message]
|