Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why does IE11 give this warning: HTML1406: Invalid tag start: "<?"

My pages are written and declared as XHTML 1.0 Strict. The first lines goes like this:

<?xml version="1.0" encoding="utf-8" ?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
        <html xmlns="http://www.w3.org/1999/xhtml">
            <head>

Which I belive is correct for a XHTML 1.0 Strict but nevertheless IE11 gives this warning:

HTML1406: Invalid tag start: "<?". Question marks should not start tags. File: default.aspx, Line: 1, Column: 2

Anyone know if this is somthing I should worry about?

like image 259
Muleskinner Avatar asked Nov 22 '13 10:11

Muleskinner


1 Answers

The problem is that although you have created a file with an XHTML doctype you have served it using a text/html media type.

So IE11 (and other browsers) treat the file as an HTML file and parse it with their HTML parser. An XML declaration in an HTML file is invalid, and that's what the browser is telling you. If you had served the file with an application/xhtml+xml media type, the browser would have treated the file as XHTML and used its XML parser to parse it. Then the XML declaration would be handled correctly according the XML rules and IE11 would not give you that warning message.

There's no real problem here. The HTML parser will treat the declaration as a bogus comment and just carry on regardless.

For more information you should read Sending XHTML as text/html Considered Harmful and/or HTML 4, HTML 5, XHTML, MIME types - the definitive resource

like image 174
Alohci Avatar answered Nov 15 '22 17:11

Alohci