IE's XHTML Compatibility

2019-02-07 08:55发布

问题:

I'm having a rather heated debate into IE's XHTML Compatibility. The only thing is, I'm unsure if the guy is trolling.

Essentially he claims that IE has absolutely no XHTML compatibility, and that a document with a defined XHTML doctype means absolutely nothing when served as content type text/html, regardless of the browser used.

I do not believe this and sources say otherwise, but I am wrong?

Edit: Disregarding IE, does it still mean that when XHTML is defined in an HTML document it is NOT XHTML? Like the guy suggested? My current understanding is that XHTML is often contained within the HTML content type. This means that technically you could say that XHTML is merely HTML unless the correct content-type is used. But it's still XHTML syntax and so it a little confusing.

You can find the thread in question over at digitalpoint forums.

回答1:

IE has indeed no support for application/xhtml+xml content type while other browsers would then handle HTML as XML. When text/html is used, every browser will just handle XHTML as HTML, IE does nothing different here (expect from the usual quirks).

More details here: http://hsivonen.iki.fi/doctype/



回答2:

The guy is right. When serving XHTML as text/html, is is no longer XHTML, but funny-looking HTML. MIME type is key.



回答3:

I guess this question is done, but:

IE has absolutely no XHTML compatibility

IE won’t parse XHTML content served as text/html as XHTML. (It’ll parse it as HTML.)

Unfortunately, it won’t display XHTML content served as application/xhtml+xml as a web page — it’ll display it just like it displays any other XML content, i.e. prettified source.

As per the XHTML 1.0 spec, you are allowed to serve it as text/html for compatibility with older browsers (i.e. IE). So IE is sort of compatible with the XHTML 1.0 spec. But as many have argued, if you’re not parsing XHTML as XML, what’s the point?

a document with a defined XHTML doctype means absolutely nothing when served as content type text/html, regardless of the browser used

Depends what he means by “means”. It’s still HTML, so it’s got all the meaning associated with that. And as you say, the content is still XHTML, as it’s written in the XHTML syntax. But it won’t be parsed as XML due to the mimetype, so in that sense it’s not XML, and thus isn’t XHTML.

(If you’re wondering what the practical implications of this are, join the club.)



回答4:

BalusC is correct. More to the point is that the person you are arguing with is assuming that XHTML must be XML, which is false. XHTML 1.0 is a syntax of HTML that is compatible with XML syntax, but is however an SGML serialization that may optionally be processed as XML per paragraph 5.1 of the specification. XHTML 1.1, however, must be processed as XML.

The idea is that XHTML 1.0 is written as a transitional point between SGML and the XML syntax, even XHTML 1.0 strict. The various doctypes of XHTML 1.0 are all transitional and merely indicate the degree of conformance to the XML syntax without regard for the method of processing.



回答5:

The other guy is right. You are wrong. IE has no support for application/xhtml+xml as others have said. IE treats it as "tag soup" when served as text/html as do other browsers.



标签: xhtml html5