Altova Mailing List Archives>Archive Index >comp.text.xml Archive Home >Recent entries >Thread Prev - Re: XHTML Orphaned text representation in a DOM >Thread Next - Re: XHTML Orphaned text representation in a DOM Re: XHTML Orphaned text representation in a DOMTo: NULL Date: 8/1/2007 10:04:00 AM Peter Flynn <peter.nosp@m...> wrote in <5h9ii4F3j74kmU1@m...>: > Pavel Lepin wrote: >> Mike <raathm@g...> wrote in >> <1185879569.684575.166940@1...>: >>> <div> >>> Some text >>> <span>blah blah</span> >>> Some more text >>> </div> >>> >>> How is this represented in a DOM? The <span> should be a >>> child element - are the "Some text" and "Some more text" >>> sibling elements, >> >> Sibling nodes of 'span' element, not sibling elements. >> And child nodes of 'div' element. > > And in general, don't do this at the div level. It'll make > your teeth fall out, give you white hair, and end in tears > and recriminations. Where possible, use better markup: > > <div> > <p>Some text > <span>blah blah</span> > Some more text</p> > </div> > > Dangling mixed content (what you described) needs to be > avoided. Pardon my bluntness, but to me that looks silly and superfluous; and it doesn't get rid of "dangling" text nodes even if getting rid of them in document markup was a good idea. Stuffing a p into a div looks weird--why would you need a div then? It's just a block element with no additional semantics. If you want a paragraph, use a p. The entire "one text node per element" idea just doesn't make much sense (in context of document markup, as opposed to data markup), unless for some inexplicable reason you want to stuff everything with default semantics into a span; and that doesn't even work, because of the way whitespace is handled in XHTML, and because of Gecko's peculiar idiosyncrasies where long text nodes in DOM are concerned. -- ...the pleasure of obedience is pretty thin compared with the pleasure of hearing a rotten tomato hit someone in the rear end. -- Garrison Keillor | ||||||
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | Mobile | Full Site | |||
|
