HTML5
HTML5
Webpage Design
Overview
• Historical context
• DOCTYPEs and such
• Can/should I use HTML5 now?
– The problem with browsers...
• Syntax
• Semantics
– The new (structural) elements
– HTML5 content model
• Audio, Video and Canvas
• HTML5 APIs
HTML5 is the first markup language to have its own official logo!
XML is the future of the Web
• Somewhere along the way, W3C lost sight of the
purpose of web markup when they proposed the
radical XHTML 2 – an attempt to move the web to XML.
• It envisaged a new web built with new tools – and it
was not backwards compatible with existing web
content.
• It’s as if they were mainly interested in the markup
language itself and not with those who were going to
use it (browser-makers and front-end developers).
• Things came to a head in 2004 when Ian Hickson
proposed an extension of HTML which was rejected by
W3C.
• Hickson and other rebels formed the Web Hypertext
Application Technology Working Group (WHATWG)
OK, we got it wrong!
• WHATWG wanted a markup language that could
be used to build web applications and not just
webpages.
• They began developing Web Forms 2.0 and Web
Apps 1.0, which merged to become HTML5.
• In 2006, W3C admitted that their approach just
wasn’t working.
• Shortly afterwards, W3C issued a new charter for
an HTML Working Group.
• They decided to use the work begun by WHATWG
as the basis for the new specification.
HTML5 here we come!
• For a while, W3C were developing two different
and totally incompatible markup languages.
• But in 2009, they announced the end of XHTML2
development.
• Once the ambiguity was removed, web designers
pounced on HTML5 as the “new kid on the
block”.
• Both WHATWG and W3C continue to work on
HTML5 but they are working together and
progress has been faster than expected.
HTML5 development principles
• Partly as a reaction against the idealist nature of
XHTML 2 development, HTML5 is a very pragmatic
markup language.
• Rather than attempting to impose a new order on the
web, it looks at what people are already doing and tries
to codify it. The introduction of the <header> and
<footer> elements are a good example of this.
• HTML5 development principles:
– Support existing content
– Do not reinvent the wheel
– Pave the cowpaths
HTML5 by W3C
I want it now!
• There are plenty of reasons why you may want to
use HTML5 now.
• It’s sexy.
• Freedom from proprietary technologies (almost).
• Better functionality.
• Future-proofing websites.
<!--[if lt IE 9]>
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
The key difficulty in implementing HTML5 now is that older versions of Internet
Explorer (those before IE9) do not understand the new HTML5 elements. The
workaround is to use JavaScript to tell IE how to interpret them. This is best done
using Remy Sharp’s lovely html5shiv, now hosted at Google.
Syntax
Strict XHTML 1.0 syntax
<h2>Students</h2>
<p>Typically, our students fall into three groups...</p>
<p>See <a href="/our-students/">Our students</a> for more information.</p>
<img src="/our-students/graduation.jpg" width="552" height="413"
alt="Graduation" />
HTML5 has been designed to give web designers the tags they need to markup
common page elements without needing to use id and class names.
Built-in Obsolescence
HTML5 aims to be backward compatible. Therefore there are no deprecated
elements, only obsolete elements. This means that you can use obsolete
elements, which your browser will still render, however your web page will be
“non-conforming” due to the use of these.
<small> – no longer means “render this at a small size.” It now means “this is the
small print” for legals, T’s & C’s or privacy agreements.
<b> – previous meaning “render in bold.” New meaning “to be visually different
from the normal text, without conveying extra importance.”
<i> – previous meaning “italicize.” New meaning “in an alternate voice or mood”.
These changes are largely made to keep the specification and elements relevant to
non visual user agents such as screen readers.
‘Bold’ and ‘Italic’ are words that only make sense visually. The idea of developing
towards non visual user agents encourages designers to think beyond basic visual
design and development.
The <a> (anchor) element has always been an inline element meaning
multiple <a> elements were needed for hyperlinks that span multiple
elements.
<a href="index.html">
<h1>Welcome to my site</h1>
<p>Paragraph</p>
</a>
If we were to describe the document outline described by the markup above, it would look like this:
In the markup above, we can convey the hierarchy of headings by cascading through the descending
levels of heading. On the left, we must use <h2> because <div> conveys no hierarchy to its children.
Whereas, the children of <article> are considered to be subordinate to elements at the same level as
<article>. In this case, the second <h1> is subordinate to the first. So, in both cases, the document
outline looks like this:
HTML5 is weird
In this context the article title is <h2>... but in this context the article title is <h1>
Audio and Video
• For the first time, HTML5 provides a way to play audio and
video in a browser without the use of plugins like Flash.
• Unfortunately, there is still a problem with media formats.
• The most popular formats like MP3, are not open and
browser makers must pay to support them.
• So, although the “big boys” can afford to pay for MP3
support in their browsers, Mozilla cannot – Firefox does not
support MP3 but it does support the open Ogg Vorbis
format.
• Unfortunately, not all of the other browsers support the
.ogg format.
• The result is that we must provide different formats to
different browsers.
Come together (please!)
An example from HTML5 for Web Designers by Jeremy Keith
<audio controls>
<source src="witchitalineman.ogg" type="audio/ogg">
<source src="witchitalineman.mp3" type="audio/mpeg">
<object type="application/x-shockwave-flash"
data="player.swf?soundFile=witchitalineman.mp3">
<param name="movie"
value="player.swf?soundFile=witchitalineman.mp3">
<a href="witchitalineman.mp3">Download the song</a>
</object>
</audio>
HTML5 Doctor by Rich Clark, Steve Faulkner, Bruce Lawson, Remy Sharp, Oli Studholm and Ian Devlin