logo
Search:

Login:


Forgot Details? Sign-up

forum >> Programming questions >> HTML / XHTML / HTML5 / CSS

Is it time to use HTML5, or should I stick with XHTML?

Posted Dec 29 2011 at 6:57 PM by
heather (heather)
In your All - in - One book, you teach XHTML Strict, but I hear that HTML5 is really big. I know you did a book on that too. Is XHTML obsolete? I'm confused.
AuthorMessage
Andy
Posted: Dec 29 2011 kl. 7:05 PM

It is kind of confusing.

For now, either one is fine, most of the time. XHTML is a ratified standard, and it will work great in most browsers. It's still probably the safest way to go. If you're not sure, you can generally stick with XHTML and be fine. XHTML Strict teaches really great habits, so if you use that format, you'll have no trouble whatsoever converting to HTML5.

HTML5 is not a completed standard, and the adoption of it varies from browser to browser. (Check this site from my HTML5 book to see which features of HTML5 are supported in your current browser.)

Many of the features are supported in different ways in the different browsers, so it can be frustrating.

However, my current projects all use HTML5. Here's why:
  • HTML5 is easier to write from memory. The messy doctype of XHTML is finally gone. This is probably my favorite part of HTML5.
  • A few key tags (audio and video, and the canvas in particular) are very well supported.
  • Virtually all mobile browsers support the bulk of HTML5.
  • The vast bulk of HTML5 is just like XHTML

So, the choice is up to you. I'll be doing a third edition of the All - in - One book using HTML5 in the next year or so, but it's really fine to use either one for now. Whatever you do, don't forget to check for browser compatibility.
Stephen Reed
Posted: Feb 12 2012 kl. 5:25 PM

I keep meaning to test it, but I've heard that HTML5 will usually fail gracefully in older browsers.

My question is, do the header, nav and footer tags work in older browsers?
Andy
Posted: Feb 23 2012 kl. 8:34 AM

Most of the HTML parts of HTML5 (the navigation tags, the new input types and so on) will still render as something in older browsers. Here's the general rule: If it's a brand new tag (like ) there's no guarantee that older browsers will display it (though most treat it like an ordinary div.) If it's a variation on an older tag (like the new form elements, which are all new varieties of the tag,) it will fall back to the older version.

The most interesting parts of what we call HTML5 are really CSS and JavaScript, and coverage of these features is quite spotty. Often the older browsers will be completely baffled trying to implement them.

In general, though, browsers soldier on when they encounter things they don't know. While the page won't do what you want, the user won't normally see a catastrophic failure like you get in more traditional programming...

If in doubt, check my examples for the html5 book to see how things work.