demosthenes.info

I’m Dudley Storey, the author of Pro CSS3 Animation. This is my blog, where I talk about web design and development with , and . To receive more information, including news, updates, and tips, you should follow me on Twitter.

featured articles

popular favourites

Converting an XHTML Page to HTML5

A great deal of money will be spent over the next several years to rewrite and update existing websites to HTML5. Essentially this is a pre-Y2K period for web developers: a lucrative, once-in-a-generation opportunity to be part of an epochal change.

Technically, merely changing the first line of the HTML code on a page to <!DOCTYPE html> is enough to make it HTML5; even loosely coded pages should validate, given HTML5's lowering of standards. (A number of my full-time second year students, given the final assignment of making an HTML5 website, did exactly that).

Doing so, however, is a merely superficial nod to HTML5. Taking complete advantage of the spec – making a true HTML5 page – means rewriting and re-contextualizing code everywhere in the page.

Apps that promise automatic XHTML to HTML5 conversion will be promoted, sell, and fall far short of expectations, in part because the goal of HTML5 is to add more intelligence to web pages, and find-replace scripts fall far short of achieving that.

This article will outline the workflow process for converting a complete, valid, XHTML 1.0 Strict document to HTML5. It consists of several steps:

  1. Make a copy of your entire website, and work your changes on the copy

    You do not want to be caught halfway through the process and forget what you have changed, or lose your references before rewriting your CSS.

  2. Change the DOCTYPE and <head> section to HTML5 markup
  3. Remove Dublin Core metadata

    HTML5 does not allow schema as an attribute value. Solutions are still being worked on; for right now, remove most traditional metatags from your code.

  4. Add micro formats as appropriate.

    Traditional metadata is supplemented (and, to a degree, supplanted) by micro formats in HTML5. The appropriate format to add, and its associated data, will depend on the content of your page; I'll address microformats in a article shortly.

    Step 5: Update tags for external stylesheets and JavaScript files

    The links themselves will not change, but you should remove unneeded attributes such as type.

  5. Replace generic div containers with their appropriate HTML5 tags

    <div id=“header">, <div id=“footer">, <div id=“sidebar"> and <ul id=“nav"> or their equivalents, should be replaced with <header>, <footer>, <aside> and <nav> respectively.

  6. Divide remaining content, if self-explanatory, with <section> tags

    This is the minimum number of steps you should take to transform an existing web page into HTML5; I'd also suggest that the update process also allows the opportunity for a thorough review of a site's design and features.

You must be signed up in order to leave comments.

You wrote that should be replaced by a tag. Is this correct?

posted by Jeremy Reimer

html tags really dont work in the comments eh? that was the sidebar tag.

posted by Jeremy Reimer

Dudley StoreyHi Jeremy! And well-caught: I've fixed the reference (there is no <sidebar> tag). And tags should work in the comments... but if you want them to apepar as code (rather than, say, active links) you have to surround them with &lt; &gt; HTML entities. (I'll update the About page in this regard).

posted by Dudley Storey

web developer guide

featured comment

by Aisling Brock in New Business Card Design

what i'm reading

A Feast for Crows: A Song of Ice and Fire: Book Four
A Feast for Crows: A Song of Ice and Fire: Book Four

what i'm watching

Prometheus: Collector's Edition (Bilingual) [Blu-ray 3D + Blu-ray + DVD + Digital Copy]
Prometheus: Collector's Edition (Bilingual) [Blu-ray 3D + Blu-ray + DVD + Digital Copy]

what i'm playing

Borderlands
Borderlands

what i'm hearing

Planets
Planets

blogs

podcasts

no ads ever

This blog is free of advertising, and always will be.

creative commons licensed

The content of this blog is free to use in whatever way you wish under the Creative Commons license.