Why polyglot is needed

My university serves html files as text/html.  I have no control over
that.  If I don't produce polyglot, browsers do the wrong thing with,
for instance [1], void tags.

The document at [1] looks like this:

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <title>test void element closure</title>
    <style type="text/css">a {background-color: pink}</style>
  </head>

  <body>
    <h1>test void element closure</h1>
    <p><a name="test" />Inside or outside?</p>
    <hr/>
    <address><a href="mailto:ht@inf.ed.ac.uk">Henry S. Thompson</a></address>
  </body>
</html>

Served as application/xml+xhtml, it validates [2] and displays
correctly (in Firefox 17, Chrome 26, IE9).  Served as text/html, it
doesn't parse [3] and displays incorrectly (same browsers).

ht

[1] http://www.ltg.ed.ac.uk/~ht/void_test.html
[2] http://validator.w3.org/check?uri=http%3A%2F%2Fwww.ltg.ed.ac.uk%2F~ht%2Fvoid_test.xhtml&charset=%28detect+automatically%29&doctype=HTML5&group=0
[3] http://validator.w3.org/check?uri=http%3A%2F%2Fwww.ltg.ed.ac.uk%2F~ht%2Fvoid_test.html&charset=%28detect+automatically%29&doctype=HTML5&group=0
-- 
       Henry S. Thompson, School of Informatics, University of Edinburgh
      10 Crichton Street, Edinburgh EH8 9AB, SCOTLAND -- (44) 131 650-4440
                Fax: (44) 131 650-4587, e-mail: ht@inf.ed.ac.uk
                       URL: http://www.ltg.ed.ac.uk/~ht/
 [mail from me _always_ has a .sig like this -- mail without it is forged spam]

Received on Tuesday, 19 March 2013 19:06:25 UTC