Romil N Romil N - 3 months ago 5x
HTML Question

How does HTML 5 differ from HTML 4?

I have seen HTML 5 coming up in near future. How does it differ from HTML 4, which has been 'in' for so many years in web development?



Broadly speaking, there are four main areas of change:

  • Semantic markup, including the following tags:

    <section> <article> <header> <footer> <nav> <aside> <hgroup>

    This also covers changes to the <doctype>, <html> and <meta> tags, as well as link relations (the rel attribute on an <a> tag).

  • Improved form support - mainly semantic additions to input types, and a few neat things like field autofocus and placeholder text.

  • Multimedia tags - <video>, <audio> and <canvas>. <video> and <audio> are intended to improved better support for embedded media in the page; <canvas> is for programmatic two-dimensional bitmap drawing on the page through JavaScript.

  • Changes to the DOM that are just accessible through JS - navigator.geolocation, window.localStorage (storing user data offline), window.applicationCache (storing app data offline), web workers (multithreaded JavaScript, with some caveats)

Different parts of HTML are in different stages of specification and implementation - the form changes are poorly supported outside of Safari, the <video> tag is basically unusable in a cross-platform environment (without multiple video formats), and IE has built-in support for next to none of these changes.

The best place to read up on HTML5 that I've seen is Mark Pilgrim's excellent book in progress, Dive into HTML5