Use of empty element shortcut for accidentally empty elements.

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Use of empty element shortcut for accidentally empty elements.

ColinFine
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?

--


       *Colin Fine*
       *****Engineering Tools Group
       Pace plc*
       */Bringing Technology Home/*

       *Tel:    +44 1274 538038*
       *****Fax:   +44 1274 538056*
       *Victoria Road, Saltaire, West Yorkshire. BD18 3LF  _
       __www.pace.com_*

       */Think before you print! Please consider the environment before
       printing this e-mail./*

Visit Pace at IBC 2009
This E-mail and any attachments hereto are strictly confidential and intended solely for the addressee. If you are not the intended addressee please notify the sender by return and delete the message. You must not disclose, forward or copy this E-mail or attachments to any third party without the prior consent of the sender. Pace plc is registered in England and Wales (Company no. 1672847) and our Registered Office is at Victoria Road, Saltaire, West Yorkshire, BD18 3LF, UK. Tel +44 (0) 1274 532000 Fax +44 (0) 1274 532010. <http://www.pace.com>
Save where otherwise agreed in writing between you and Pace (i) all orders for goods and/or services placed by you are made pursuant to Pace's standard terms and conditions of sale which may have been provided to you, or in any event are available at http://www.pace.com/uktcsale.pdf (ii) all orders for goods and/or services placed by Pace are subject to Pace's standard terms and conditions of purchase which may have been provided to you, or in any event are available at http://www.pace.com/uktcpurch.pdf. All other inconsistent terms in any other documentation including without limitation any purchase order, reschedule instruction, order acknowledgement, delivery note or invoice are hereby excluded.



This message has been scanned for viruses by BlackSpider MailControl - www.blackspider.com

Reply | Threaded
Open this post in threaded view
|

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

Steven Pemberton-3
<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 <[hidden email]> 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?
>