|
Posted by Jeff Dege on 08/03/07 20:28
On Fri, 03 Aug 2007 10:54:53 -0700, Jim Moe wrote:
> Jeff Dege wrote:
>> I'm trying to lay out some divs that have content inserted via
>> javascript. Just because it's cleaner, I've been using self-closing
>> div elements: "<div />"
>>
> That is XML syntax, not HTML. To an HTML parser "<div />" resolves to
> "<div>".
> Run the code through a validator.
I'd figured that since every time I type "<br>" into my editor, it
changes it to "<br />", that HTML 4+ had incorporated self-closing
elements.
So off I go to the W3C validator.
Turns out that "<br />" is legal in both html 4.01 and in xhtml 1.0, but
that "<div />" is legal in xhtml 1.0, but illegal in html 4.01.
Which makes no sense to me whatsoever. The parsing of element tags and
element closings should not be dependent upon which element we're talking
about. But that's what I'm seeing.
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.
--
The most dangerous man, to any government, is the man who is able to think
things out for himself without regard to the prevailing superstitions
and taboos. Almost inevitably he comes to the conclusion that the
government he lives under is dishonest, insane and intolerable, and so,
if he is romantic, he tries to change it. And even if he is not romantic
personally he is apt to spread discontent among those who are.
- H.L. Mencken
Navigation:
[Reply to this message]
|