This is an archived snapshot of W3C's public bugzilla bug tracker, decommissioned in April 2019. Please see the home page for more details.

Bug 3810 - Doesn't correctly validate non "empty" elements that use shortcut
Summary: Doesn't correctly validate non "empty" elements that use shortcut
Status: NEW
Alias: None
Product: Validator
Classification: Unclassified
Component: check (show other bugs)
Version: HEAD
Hardware: PC Linux
: P2 normal
Target Milestone: ---
Assignee: Olivier Thereaux
QA Contact: qa-dev tracking
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-10-06 11:01 UTC by Brett Parker
Modified: 2009-06-23 15:39 UTC (History)
1 user (show)

See Also:


Attachments
Self-closing anchor tag can break IE8 layout (406 bytes, text/html)
2009-06-14 12:05 UTC, Glen
Details

Description Brett Parker 2006-10-06 11:01:04 UTC
When using XHTML, according to the specification (XHTML1 spec, section 4.3, http://www.w3.org/TR/xhtml1/#h-4.3) it is required that any element that has not got EMPTY declared in the DTD should always use the form <tag></tag>, but testing this, for example with a simple XHTML document containing <div /> passes validation.
Comment 1 Olivier Thereaux 2006-10-13 02:38:47 UTC
Hi Brett,

(In reply to comment #0)
> When using XHTML, according to the specification (XHTML1 spec, section 4.3,
> http://www.w3.org/TR/xhtml1/#h-4.3) it is required that any element that has
> not got EMPTY declared in the DTD should always use the form <tag></tag>, but
> testing this, for example with a simple XHTML document containing <div />
> passes validation.

My interpretation of the specification is:

* 4.3 says end tags are necessary, unlike in HTML <= 4.01
However, according to XML rules, for elements without content, minimization such as <foo /> is equivalent to having a start and end tag for the element.

* 4.6 says [[ Empty elements must either have an end tag or the start tag must end with />. ]]

* The (informative) appendix C for the compatibility of XHTML 1.0 documents served as text/html specifies that [[ Given an empty instance of an element whose content model is not EMPTY (for example, an empty title or paragraph) do not use the minimized form (e.g. use <p> </p> and not <p />). ]] That is, however, beyond the realm of validation, and an informative guideline, as far as I can tell. 


This aspect of the specification is confusing to me, I confess. Partly because "empty elements" are not defined anywhere, and are sometimes meant as "elements defined as EMPTY in the DTD", sometimes as the generally accepted definition of an element without content.

Discussion threads I could find on the matter seem to dodge the question by stating that non EMPTY (as in, not declared EMPTY in the DTD) should never be empty (as in, no content), and that <div /> makes no sense. Still, my interpretation of the spec is that <div /> is a valid and well-formed construct, however not recommended for content served as text/html.

That's probably worth asking the HTML working group, responsible for the edition (and exegesis) of the spec, for clarifications. I'll try to get their attention on this bug report.

Thanks.
Comment 2 Glen 2009-06-14 12:05:31 UTC
Created attachment 709 [details]
Self-closing anchor tag can break IE8 layout

One thing to note is that a self-closing anchor tag can break a layout in Internet Explorer 8. See attachment.
Comment 3 Brett Parker 2009-06-23 15:39:05 UTC
Just wondering if there's any movement on this ticket... it appears that the validator still (incorrectly, IMO, and by the looks of various browsers, in their interpretation of the spec) doesn't produce and error or warning for documents containing empty elements that aren't declared as EMPTY. (e.g. <div />).

Thanks,
Brett Parker