Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

HTML vs XHTML does it still matter? [closed]

Tags:

html

xhtml

I'm wondering if I should bother at all about the markup language, as long as i produce valid markup.

I've read articles that point out HTML is the best choice and they come directly from the horse's mouth (the browsers implementors!):

  • http://webkit.org/blog/68/understanding-html-xml-and-xhtml/
  • https://developer.mozilla.org/en/Mozilla_Web_Developer_FAQ

Other articles, by James Bennet, make another point that if you're not serving XHTML as XML then you don't want XHTML but HTML.

  • http://www.b-list.org/weblog/2008/jun/18/html/
  • http://www.b-list.org/weblog/2008/jun/21/xhtml/

So i thought that if i wanted to trigger Standard Compliant Mode i should just use HTML strict validation. But that's not the case anymore with at least the most modern browsers (aka everything but IE6): if you have valid XHTML Strict you still trigger Standard Compliant Mode, hence, as long as i produce valid markup, why bother?

like image 831
Lorenzo Avatar asked Jan 05 '09 13:01

Lorenzo


People also ask

Is XHTML still relevant?

Yes unfortunately XHTML is gone.

Should I use XHTML or HTML?

HTML and XHTML are two of the most popular markup languages used for developing web pages and applications. HTML is the standard markup language for creating web pages, while XHTML is a stricter and more standardized version of HTML.

Will XHTML replace HTML?

DEFINITION Extensible Hypertext Markup Language (XHTML) is a transition language that combines HTML and XML. Designed to replace HTML Version 4.0, XHTML is recommended by the World Wide Web Consortium. XHTML Version 1.0, also known as HTML 4.01, is a reformulation of HTML 4.0 as an XML 1.0 application.

Did HTML5 replace XHTML?

Extensible HyperText Markup Language (XHTML) and HyperText Markup Language (HTML5) are both markup languages. XHTML is an extension of HTML that was created to solve compatibility issues across browsers. ​HTML5 is a newer version of HTML.


1 Answers

I always use HTML 4.01 strict for the time being. HTML 5 isn't definitive yet. I used to be a diehard XHTML user, but my reasons etched away and I'm much happier and more productive.

The arguments for XHTML generally tend towards the "cleaner markup" or talking about well-formed markup. This seems mostly like a strawman argument, and doesn't hold up under a thorough beating.

If XHTML is guaranteed to be parsed by an XML parser, it generally won't look cleaner than HTML 4.01 strict (just comparing strict doctypes).

For one, having to write URLs as http://example.com/?foo=bar&baz=qux looks awkward. Declaring the entity types gets old.

The other thing is that markup generally doesn't translate remarkably well as an XML Tree, but a Dom tree is fine.

HTML 4.01 strict is moderately easier to use and create valid sites. You don't have to put meaningless closing tags on elements like <img>, <br> or <link>. Just putting the backslash doesn't change anything of any particular meaning.

Douglas Crockford, of Yahoo and everything markupy, says it best to think of the markup as an application delivery format.

As such, what is going to be the easiest to deliver and more robust and reliable. This is what ultimately made the decision for me. All web browsers handle XHTML differently, and require munging of the Content-type header. If you use "text/xhtml" or "text/xml" you get different results.

Additionally, "text/xml" doesn't play nicely with REST because that should mean XML serialization of the data and not a formatted markup page (Safari gets this one wrong, in my opinion, by requesting text/xml before text/html as desired content-types!)

So, use HTML 4.01 because:

  1. It works more similarly across all browsers
  2. Doesn't require Content-type based handling (text/html does the trick across the board)
  3. Isn't as brittle as XHTML
  4. HTML 5 doesn't offer anything significant over HTML 4.01 strict
like image 171
jshirley Avatar answered Oct 05 '22 20:10

jshirley