开发者

What are pros to use XHTML 1.0 strict with content="text/html; over HTML 4.01 strict?

I'm sure everyone here knows that we cannot serve the pages with the correct MIME type (application/xhtml+xml) for XHTML without breaking IE compatibility, and that any content served with text/html will be parsed as HTML by any browser out there. So if the content is not parsed as XML.

I use a xhtml doctype only for one reason: it helps me find “errors” in my markup in a more stricter way compared to html. Even if my documents are served as text/html

Is there any other benefit to use XHTML 1.0 Strict with content="text/html; over HTML 4.01 strict at all? At present or and in the future.

  1. if i'm already writing well formed valid HTML 4.01 strict and
  2. not want to use any extra XHTML features (SVG, Docbo开发者_Python百科ok, MathML, OFX, etc),
  3. never going to manipulate my XHTML to XSL(T)
  4. never goint to server document as application/html+xml


None. You don't get any of XHTML's benefits. As far as the browser is concerned, it's getting weird HTML, not XML. If you want to get the benefits of XML, like extensibility and the stricter parser (if that's a benefit), you have to serve your page as application/xhtml+xml, and IE won't support it. Not to mention XHTML 1.0 is incompatible with 2.0, while HTML will always be future proof.

You may want to read this, among many others. In short, only use XHTML if you know you need to, otherwise it's useless.

XHTML also doesn't necessarily mean that the browsers will adjust to standards. Don't worry about the Standards vs Quirks mode stuff, it's something that has be mantained for backwards compatibility. When a browser encounters a page with a doctype (any doctype, HTML or XHTML), it will try to render it according to standards. It doesn't mean that it will render it just like the W3C says, it just means that it will try to (and maybe not succeed).


XHTML comes with default style rules (css), at least to some degree. And also some strict rendering rules. Any browser implementing XHTML doesn't have much leeway in how to present things, so in making an XHTML document, developers may find that their document renders the same in most browsers (although there are still some minor problems, especially with IE).

In later years this has improved greatly, and most XHTML documents' styles render the same way in "all" browsers.

You may also have heard of "standards mode" and "quirks mode". Quirks mode is when (mainly IE) takes into account all the wrong things it's been doing in previous versions, and renders pages the way it used to, so it will render the way it was intended THEN. Standards mode is a strict mode, which uses only standardized rules. This breaks some older pages, but lightens the load for many developers.


XHTML consists of all the elements in HTML 4.01, combined with the strict syntax of XML.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜