|  | 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] |