Convert XHTML Web Pages to HTML5

There were a couple of questions that cropped up in my HTML5 presentation that I thought I would mention in my blog. Both were somewhat related:

  1. How hard is it to get an XHTML page to validate to HTML5?
  2. Does the HTML5 page allow break tag, or any other empty elements?

The answer to the second questions is “yes“, based on the experimental HTML5 validator from W3C. The validator you know and trust has been set up to test HTML5 albeit in an experimental fashion. Which makes sense since HTML5 is still a specficiation still being written and implemented in bleeding edge browsers.

The answer to the first question is “pretty easy”.

I took a sample XHTML 1.0 Transitional page and converted it to HTML5 by swapping out the DOCTYPE and updating the HTML element’s attributes as noted in the presentation.

I did run into a slight problem of a div attribute not being allowed in a blockquote. However, it was the align attribute set to center. But that’s not really a problem. I should have had the div element set to align center via CSS anyway.

What this means, in theory, is that if you have XHTML pages it should be easy to convert them into HTML5. It should be even easier to convert them if you have pages that validate towards XHTML Strict.

So, the benefits of a stricter coding in XHTML help out the Web developer when heading into HTML5.

Leave a Reply

Your email address will not be published. Required fields are marked *