tags:

views:

89

answers:

3

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, Docbook, MathML, OFX, etc),
  3. never going to manipulate my XHTML to XSL(T)
  4. never goint to server document as application/html+xml
A: 

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

Derek Adair
What is practical benefit of "strict syntax of XML"?
metal-gear-solid
None, really. It forces you to write well formed code, but if you care about that you can do it in HTML. And if you have user-submitted content, a sinalge malformed tag will bring your whole page down.
Javier Badia
Because XHTML documents need to be well-formed, they can be parsed using standard XML parsers—unlike HTML, which requires a lenient HTML-specific parser
Derek Adair
@Javier Badia- is well formed document means W3C valid document?
metal-gear-solid
@Jitendra: Nope. See the link I gave in my answer, I think the difference is epxlained somewhere in that site.
Javier Badia
@Javier Badia - Can u explain more of this line "And if you have user-submitted content, a sinalge malformed tag will bring your whole page down."
metal-gear-solid
@Jitendra: I think the link I gave says something about it, but imagine this: you have a blog. You can have user comments, and allow some XHTML in them. If an error (for example, a br tag without the closing slash) manages to get through to your site, the browser will refuse to render it at all. See my link, section "Benefits of XML".
Javier Badia
It has however a benefit when using a XML based tool to generate/parse/serve webpages, like as in component based MVC frameworks. --This was told you several times before, Jitendra.
BalusC
+6  A: 

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).

Javier Badia
+1 great reference
Mark E
Is the IE only browser which do not support application/xhtml+xml, and does no ie version support application/xhtml+xml , IE 7, 8 ? or only IE6 doesn't support
metal-gear-solid
No version of IE supports it: http://en.wikipedia.org/wiki/Internet_Explorer#Features
Javier Badia
Not all doctypes cause browsers to render in standards mode. Here (http://dev.w3.org/html5/spec/syntax.html#quirks-mode-doctypes) is a list of doctypes that don't.
Alohci
+1  A: 

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.

Tor Valamo
Although XHTML doesn't have much leway in how to present things, IE won't render it, so the point is more or less moot.
Javier Badia
you mean HTML document don't styles render the same way in "all" browsers?
metal-gear-solid
Of course they don't. Maybe a very simple one will, but in many cases you'll have to test against different browsers and adjust the CSS and stuff. IE is especially quirky with this.
Javier Badia
My question is XHTML 1.0 strict vs. HTML 4.01 strict, so u mean HTML 4.01 strict do not render page in standards mode, only XHTML can?
metal-gear-solid
@Javier Badia - but this site using HTML and looking same in all browsers
metal-gear-solid
The point is that what each browser calls "standards mode" doesn't adjust to the same standards as all the others. Standards/quirks mode is a remainder of compatibility problems with sites designed for IE 5 or lower (I think). Just because IE is rendering in standards mode doesn't mean that it follows the W3C standard.
Javier Badia
@Jitera: about your second point: Yes, because with some tweaking it's possible to make it look the same everywhere. But it can be hard sometimes. What I meant is that until you fix it, the layout can be different between browsers.
Javier Badia
"IE won't render it". Sure IE will render XHTML. You just gotta put a doctype in there, like grown ups do.
Tor Valamo
@Javier Badia - You mean HTML 4.01 strict render page as a IE's Standard mode not W3C Standar and XHTML Strict render page as a W3C's Standard mode?
metal-gear-solid
@Tor Valamo: I was under the impression that IE didn't work with XHTML served as `application/xhtml+xml`.
Javier Badia
@Jitendra: see the new edit to my answer.
Javier Badia
@Javier Badia - ok so this is the pros over HTML, as you are saying in your 4th comment, XHTML 1.0 Strict with content="text/html; would be more is cross browser compatible than HTML 1.0 Strict without tweaking.
metal-gear-solid
@Javier - That might be true. Though I always count on xhtml being .html files, thus being served as text/html...
Tor Valamo
@Jitendra: XHTML as text/html is techincally wrong. It doesn't affect cross browser compatilibility. I suggest you read the site I linked to and then do some Googling to find out how validity and such things work, because it's complicated to explain in these comments.
Javier Badia
@Tor Valamo: Then it's being parsed as HTML, not XHTML, so it won't make a difference.
Javier Badia
It may be technically wrong, but it's how it works, since a static server can't tell that a .html file contains xhtml... And I don't think it's fair to count on having a meta content tag in every document. And browsers render it correctly when it's text/html and xhtml doctype, so I'm not complaining.
Tor Valamo