[whatwg] void elements vs. content model = "empty"

Ian Hickson ian at hixie.ch
Tue Jun 19 15:28:37 PDT 2007


On Wed, 18 Apr 2007, ryan wrote:
>
> So, I was just trying to check my blog for HTML5 conformance [1] and ran 
> into a conformance problem that I had trouble sorting out.
> 
> The conformance checker said:
> 
> >   1. Fatal Error: End tag param seen even though the element is an empty
> >      element.
> >      Line 121, column 73 in resource http://theryanking.com/blog/
> 
> so, I went to http://www.whatwg.org/specs/web-apps/current-work/#param 
> to see what the restrictions on param are. In that section it says:
> 
> > Content model:
> >    Empty.
> 
> which brought up the question "what's 'empty' mean?". In my mind, it 
> could either be "no content allowed" or "must be a void element" (ie, no 
> end tag).

The content model only describes what conformance means at the DOM level, 
it doesn't affect the syntax.

To tell if you're allowed to have a closing tag, you have to see the 
syntax section, where it says:

# Void elements only have a start tag; end tags must not be specified for 
# void elements.

...and:

# Void elements
#    base, link, meta, hr, br, img, embed, param, area, col, input

 -- http://www.whatwg.org/specs/web-apps/current-work/#elements0


> It'd be nice if we could make this clearer in the spec– even though the 
> language and html serialization are two different things, for the sake 
> of authors it'd be nice to have pointers between the two.

Yeah... I'm not really sure how to do that yet. I think on the long term I 
may add an informative block to the element definitions (the green boxes) 
that says something like:

   Syntax in text/html:
      Start tag may be omitted
      End tag must be omitted

...or whatever.


> Also, if there's a difference between content=empty and 'void elements' 
> it deserves an explanation.

One is just about the content model, the other is just about the syntax. 
They're not really related, though it happens to be the case that all 
elements that have an empty content model are void elements in HTML.

-- 
Ian Hickson               U+1047E                )\._.,--....,'``.    fL
http://ln.hixie.ch/       U+263A                /,   _.. \   _\  ;`._ ,.
Things that are impossible just take longer.   `._.-(,_..'--(,_..'`-.;.'


More information about the whatwg mailing list