UK Web Focus (Brian Kelly)

Innovation and best practices for the Web

“HTML5: If You Bang Your Head Against The Keyboard You’ll Create a Valid Document!”

Posted by Brian Kelly on 10 Dec 2010

“HTML5 / CSS3 / JS  – a world of new possibilities”

I recently attended the 18th Bathcamp event entitled “Faster, cheaper, better!“.  For me the highlight of the evening was a talk by Elliott Kember (@elliottkember)  on “HTML5 / CSS3 / JS  – a world of new possibilities“.

The Web site describes Elliot as:

freelance web developer based in Bath, England
who builds and maintains high-traffic, powerful web apps,
resorts to using 32pt Georgia – sometimes in italic and printer’s primaries,
has 4978 followers on Twitter, speaks at conferences,
and wants to develop your idea into an application.

Elliott gave a fascinating run through some of the new presentational aspects of HTML5 and CSSS, appropriately using a HTML5 document to give the presentation.  His slides are available at and are well worth viewing. Note that to progress through the slides you should use the forward and back arrows – and not that Elliott was experimenting with some of the innovative aspects of HTML5 and CSS3 so the presentation might not work on all browsers.

In this post I’ll not comment on the HTML5 features which Elliott described. Rather than looking at the additional features I’ll consider the implications of the ways in which the HTML5 specification is being simplified.

HTML5’s Simplicity

Elliot introduced the changes to HTML5’s by pointing out its simplicity. For example a HTML 4 document required the following Doctype definition:


whereas HTML5 simply requires:

<!--doctype html>-->

The following illustrates a valid HTML5 document:

<!--DOCTYPE html>
Small HTML 5

Hello world

As can be seen there is no requirement to include the <head> and <body> elements which are needed in order for a HTML 4 document to be valid (although HTML 4 documents which do not include these mandatory elements will be rendered correctly by Web browsers.

What about IE?

Over the years developments to HTML standards have always given rise to the question “What about legacy browsers?“. Often the answer has been “The benefits of the new standard will be self-evident and provide sufficient motivation for organisations to deploy more modern browsers“.  Whether the benefits of the developments from, say, HTML 3.2 to HTML 4 and HTML 4 to XHTML 1 have provided sufficient motivation for organisations to invest time and effort in upgrading their browers is, however, questionable – I know I have been to institutions which are still providing very dated versions of browsers on their public PCs.   And whether the HTML technology previews which tend to be demonstrated when a new version of HTML is released will be typical of the mainstream uses may also be questioned.  So there is still a question about the deployment of services based on HTML5 in an environment of flawed browsers, which includes Internet Explorer; it should also be noted that other browsers may also have limited support for new HTML5 (and CSS 3) features.

Elliott suggests that a solution to the “What about IE?” question may be provided by a HTML5 ‘shim’. A shim (which is also sometimes referred to as a ‘shiv’) is described in Wikipedia as “a small library which transparently intercepts an API, changes the parameters passed, handles the operation itself, or redirects the operation elsewhere“.

Remy Sharp has developed what he calls the HTML5 shiv, which consists of the following three lines:

// -->

This code provides a mechanism for IE to recognose new elements, such as, as Elliott uses in his presentation, <slide>

Use it Now?

Should you start using HTML5 now?  Back in July in his plenary talk on “HTML5 (and friends): The future of web technologies – today” given at the IWMW 2010 event Patrick Lauke suggested that for new Web development work it would be appropriate to consider using HTML5.

Elliott was in agreement, with his slides  making the point that:

All decent browsers support enough of this stuff to make it worth using.

What this means is that you can start to make use of the simple HTML5 declaration but rather than use every HTML5 feature that is documented in the specification you should check the level of support for various features using, for example the Periodic Table of HTML5 Elements and the HTML5 Test web site and Wikipedia’s Comparison of layout engines (HTML5) as well as running standard usability checks on an appropriate range of browsers and platforms.

What About Validity of HTML5?

Following Elliott’s talk there was a question about the validity of HTML5 documents.  Elliott responding with a very graphic depiction of the much more liberal (if one dare uses that word!) approach to validity: “If you bang your head against the keyboard you’ll probably create a valid HTML5 document!“.

Such an approach is based on observing how few Web resources actually conform with existing HTML specifications.  In many cases browser rendering is being used as an acceptable test for conformity – if a Web page is displayed and is usable in popular Web browsers then it is good enough seems to be the situation today.  “After all” asked Elliott “how many people validate their Web pages today?” The small numbers of hands which were raised (including myself and Cameron Neylon) perhaps supported this view and when the follow-up question “Who bothers about using closing tags on <br> elements in XHTML documents these days?” was asked I think mine was the only hand which was raised.

The evidence clearly demonstrates that strict HTML validity, which was formally required in XHTML, has been rejected in the Web environment. In future, it would seem, there won’t be a need to bother about escaping &s and closing empty tags, although if Web authors wish to continue with such practices they can do so.

What About Complex Documents?

Such simplicity seemed to be welcomed by many who attended the Bathcamp meeting.  But myself and Cameron Neylon, an open science researcher based at the Science and Technology Facilities Council, still had some concerns.  What will the implications be if a HTML resource is being used not just for display and user interaction, but as a container for structured information?  How will automated tools process embedded information provided as RDFa or microdata if the look-and-feel and usability of a resource is the main mechanism for validation of the internal consistency of a resource?

And what if an HTML5 document is used as a container for other structured elements, such as mathematical formulae provided using MathML; chemcial formula provided using CML;  etc.?

There are dangers that endorsing current lax approaches to HTML validity can hinder the development of more sophisticated uses of HTML, especially in the research community. We are currently seeing researchers arguing that the main document format for use in scientific and research papers should move away from PDF to a more open and reusable format. HTML5 has been suggested as a possible solution? But will this require more rigourous use of the HTML5 specification?  And if the market place chooses to deploy tools which fail to implement such approaches, will this act as a barrier to deployment of HTML5 as a rich and interoperable format for the community?


4 Responses to ““HTML5: If You Bang Your Head Against The Keyboard You’ll Create a Valid Document!””

  1. […] This post was mentioned on Twitter by Brian Kelly, Kevin Roast and Ingmar Koch, Brian Kelly. Brian Kelly said: “#HTML5: If You Bang Your Head Against The Keyboard You’ll Create a Valid Document!”: “HTML5 / CSS3 / JS  – a wo… […]

  2. I’m wary of js libraries to extend IE – it can really bloat load times. NB IE 9, with decent HTML 5 support, is in beta. Thus I’d say start building and testing now, with a view to launching when IE 9 is released. A graceful degradation approach could then be used for older browsers.

  3. Zak Mensah said

    sounds like I missed a great session. I quite like Andy Clarkes approach to using html5, all of which is distilled into his latest book .
    Regarding when to switch, in many cases we can simply switch the doctype to html5 now, as we arent using any of the HTML5 only bits of the spec and so all will be well in the world. Same with CSS3, there is no hurt starting to use it (so what if my rounded corners dont appear, they didnt know they were there to begin with)… Also as Andy says, browsers only implement what is being used, so lets start using it. All of my new projects use HTML5 and some fairly well supported CSS3 (though the next project will use some newer stuff) and as long as i know what happens when it doesnt work i can decide if the reward merits the risk.

    It will be interesting to see how things move forward, but i think it is safe to give it a try.
    Finally, I found a great way to get my head around HTML5

    Happy coding

  4. FWIW, I always close my <br /> tags.

Leave a Reply

Please log in using one of these methods to post your comment: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: