Can you explain when i should use XHTML over HTML?
| SitePoint Sponsor |
Can you explain when i should use XHTML over HTML?


It's fine to use either, in most cases. It's rare that anyone uses true XHTML anyway, because it doesn't work in IE8 and under. For most websites, you have to serve your content as text/html, meaning that the doctype is irrelevant. XHTML has stricter rules, but that doesn't mean you can't follow those rules anyway.
Thanks for your responce.


[QUOTE=a1technology;5386719]HTML's syntax is more concise than XHTML's[/qote]
Really? It would be good to back that up with some reasoning.
Originally Posted by a1technology
Originally Posted by a1technology
Originally Posted by a1technology
Some of your statements seem contradictory.Originally Posted by a1technology

Stephen J Chapman
javascriptexample.net, Book Reviews, follow me on Twitter
HTML Help, CSS Help, JavaScript Help, PHP/mySQL Help, blog
<input name="html5" type="text" required pattern="^$">
Just my personal prediction, but for the foreseeable future, I don't think the XHTML mime type is going to become at all popular.
"Folks who know what they're doing make complexity seem simple."
mhhh... i always thought xHTML couldn't be descripted as a product, it's just a way of using HTML in the correct way and in a structured way. Why wouldn't xHTML work in Explorer 8? it works fine here...


MSIE 8.0 doesn't support the recommended X(HT)ML MIME 'application/xhtml+xml' media type [RFC3236], which is the primary media type for XHTML Family documents. Thus IE 8.0 doesn't understand XHTML and just treats the markup grammar as if it were HTML not XHTML under 'text/html'. If the author served the XHTML as 'application/xhtml+xml' IE 8.0 would ask you to download the file, it wouldn't display... Furthermore XHTML is an application of XML thus requires well-formedness or will use draconian error handling via a XML Processor and halt on none well-formed markup errors.
};-) http://www.xhtmlcoder.com/
Thinking Web: Voices of the Community
> March 2013 - SitePoint forums: Spot the Error 3: Calling all Sleuths! Winner Announced!... She knows how to spot simple <code> errors but do you?


It only works if servered up as text/html, which means it's not actually XHTML anyway. If you serve it up as application/xhtml+xml. it won't work in IE8 and under. It was still recommended because the XHTML rules encouraged more tidy coding.
A real XHTML document would start with something like this:
More details here: http://www.sitepoint.com/forums/show...0-vs-XHTML-1-1Code:<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" dir="ltr"> <head> <meta http-equiv="Content-Type" content="application/xhtml+xml; charset=utf-8" />
and here: http://www.sitepoint.com/forums/show...ML-vs-HTML-FAQ


Ralph, it probably should be more like the following if using XHTML 1.0 Strict:
You cannot really set the MIME type with META when sending to a XML Parser. Think back to the 'purposely malformed' code demo samples I wrote: Spot the Error 3: Calling all Sleuths! and the comments I made in the Judge Feedback.Code:<?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">
};-) http://www.xhtmlcoder.com/
Thinking Web: Voices of the Community
> March 2013 - SitePoint forums: Spot the Error 3: Calling all Sleuths! Winner Announced!... She knows how to spot simple <code> errors but do you?
Bookmarks