Re: Are new void elements really a good idea?

Philip Taylor 2008-08-31 14.10:

> Julian Reschke wrote:
>>
>> The "<tagname />" syntax is not allowed in HTML4, and thus existing 
>> libraries that have been designed to produce HTML4 will not use it.
>>
>> On the other hand, what, except ideological reasons, stops us from 
>> allowing
>>
>>  <tagname></tagname>
>>
>> as well?
> 
> Allowing both syntaxes means there are more opportunities for authors to 
> get confused, and makes the language a bit more complex.
> 
> E.g. <embed> is a void element, and so there's never a need to write 
> </embed>; 


Would you not consider <embed> a self-closing element, like <p>? 
After all, it can take one element, the <noembed> element.

My "HTML 4 unleashed" book from 1998 shows an example where 
<embed> doesn't have a closing tag. But in the reference section 
it says that it has one. And there is no problem finding 
references which says that one should write <embed></embed>. 
Logically, it is the <noembed> element which has created this 
confusion.

> but most people (something on the order of 80%) write <embed 
> ...></embed> anyway. The W3C validator doesn't tell people to just write 
> <embed ...> (since instead it complains that 'embed' is not defined in 
> HTML4), so they have no reason to learn and promote the simpler way of 
> writing it.

The validator also does not promote to use <p> instead of <p></p>.

> Hypothetically, people who are used to writing <embed ...></embed> may 
> get confused when they see a page with just <embed ...>, and incorrectly 
> think that the page is wrong. (I don't know if this a problem in reality.)

If they see <embed><noembed></noembed>, then yes, they could be 
confused.

But as my book from 1998 optimistically said: "If a browser 
doesn't recognize the <embed> tag, it won't recognize the 
<noembed> tag or display anything within its borders."

Assuming that the book told the truth, my guess is that the 
browsers of that time did not consider that the <embed> tag had 
finished until they saw </embed> and hence did not try to render 
what was in <noembed>.

And if that theory is correct, then it tells even back then, void 
elements were unexpected and problematic.

> Also hypothetically, people might write <embed ...>Fallback 
> content</embed> and expect it to work, since all other elements in HTML 
> with start+end tags can contain some content. That's easier to test: 
> Looking at some tens of thousands of pages to find some with non-empty 
> <embed>s, they all seem to contain either whitespace (spaces, &nbsp;, 
> <br>) or <noembed>. That use of <embed 
> ...><noembed>...</noembed></embed> is a bit confused, but harmless.


What do you mean by confused?

> I don't see any cases where there's a real problem caused by this on 
> public sites. (But I have no idea how many authors would have 
> encountered a real problem while testing it themselves privately, and 
> fixed it before uploading.) 

-- 
leif halvard silli

Received on Monday, 1 September 2008 01:09:52 UTC