Re: HTML end tags for empty elements

On Sat, 2005-09-10 at 10:42 +0200, Alun Jones wrote:
> In HTML the element input and img are not flagged as errors when end
> tags are added:
> <input type="text" />

While it is almost certainly an error on the part of the author, it
isn't a syntax error as defined by SGML and the HTML DTDs, nor is it a
syntax error as defined by the prose of the HTML specification.

The long explanation can be found at
http://www.cs.tut.fi/~jkorpela/html/empty.html

The short version is that:

* <input type="text" / is, in HTML, equivalent to <input type="text">.
Therefore:
* <input type="text" /> is, in HTML, equivalent to <input type="text">>.
Therefore
* <input type="text" /> is, in HTML, equivalent to <input
type="text">&gt;.

and anywhere you are allowed to have an <input> element in HTML, you are
also allowed to have character data (like a visible greater than
symbol).  

Most, although not all, browsers get this wrong (since they use tag soup
slurpers rather than proper SGML parsers) which is why Appendix C of the
XHTML 1.0 Recommendation "works".

The document is valid and conforms to the HTML 4.01 Recommendation but
doesn't say what the author intended it to say.

It is important to keep in mind that the validator, while being a very
useful tool, is not the beginning and end of quality control for
webpages.

                        I have a spelling checker;
                        It came with my PC.
                        It plainly marks four my revue
                        Mistakes I can knot sea.
                        I've run this poem threw it;
                        I'm sore your please too no,
                        It's letter perfect in its weigh,
                        My checker tolled me sew.

-- 
David Dorward                           <http://dorward.me.uk/>
"Anybody remotely interesting is mad, in some way or another."
                             -- The Greatest Show in the Galaxy

Received on Saturday, 10 September 2005 11:54:54 UTC