You are here: Re: Layout of self-closing divs - can anyone explain this? « HTML « IT news, forums, messages
Re: Layout of self-closing divs - can anyone explain this?

Posted by Jim Moe on 08/03/07 17:54

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.
>
> Now try a third bit of html:
>
> <div id="first">
> <div id="second" />
> <div id="third" />
> </div
>
> I'd expect this to draw exactly the same as the second example, above.
> We've made no substantive changes from it. Instead, it draws the same as
> the first - as if the third div is nested within the second div. Which
> it isn't, according to everything I thought I understood about how SGML
> parsing worked.
>
> Can anyone explain to me why this works this way?
>
It is HTML, not SGML or XML. You example reduces to:

<div id="first">
<div id="second">
<div id="third"></div>

</div> <-- error recovery
</div> <-- error recovery

with error recovery to handle the unclosed <div>s.

--
jmm (hyphen) list (at) sohnen-moe (dot) com
(Remove .AXSPAMGN for email)

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация