Re: Use of empty element shortcut for accidentally empty elements.

<p/> is in fact correct XHTML 1, and the validator is correct in allowing  
it.

Section 4.3 explains that in XHTML 1.0, you must terminate all elements  
(SGML and HTML terminate some elements for you).
So you must write
	<p>Para 1</p><p>Para 2</p>
where you used to be able to write
	<p>Para 1<p>Para 2

However, the informative (rather than normative) guideline in section C.3  
points out that if you want your XHTML 1.0 documents to work in both XHTML  
and HTML user agents, then you should use <p></p> instead of <p/>, since  
HTML user agents don't recognise the <p/> form.
(C.2 points out that for similar reasons you should use <br/> and not  
<br></br>).

Note that there is a more up-to-date set of guidelines at  
http://www.w3.org/TR/xhtml-media-types/#compatGuidelines

Hope this helps.

Best wishes,

Steven Pemberton


On Thu, 20 Aug 2009 16:28:51 +0200, Colin Fine <colin.fine@pace.com> wrote:

> Some while ago I realised that the XHTML1.0 spec (in section 4.3)  
> licences the empty element shortcut (<xxx/>) only for elements defined  
> as empty in the DTD; so that <br/> is legal but <p/> is not.
>
> Recently I pointed this out to somebody on a mailing list  
> (http://groups.google.com/group/prototype-scriptaculous/t/7df119e31a7c30a9?hl=en)  
> and he replied that the W3C validator accepted forms such as <p/>.
>
> I have verified that this is the case.
>
> As things stand, this appears to me to be a bug in the validator - or is  
> there some sort of update to the spec which allows it?
>

Received on Thursday, 20 August 2009 14:48:15 UTC