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 Chris F.A. Johnson on 08/03/07 21:29

On 2007-08-03, Jeff Dege wrote:
> 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.

<br> is an empty tag; <div> isn't (or shouldn't be).

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

Save yourself some trouble, and use HTML 4.01 strict.


--
Chris F.A. Johnson <http://cfaj.freeshell.org>
===================================================================
Author:
Shell Scripting Recipes: A Problem-Solution Approach (2005, Apress)

 

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

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