W3C

Bert Bos | HTML5 and the Open Web Platform

HTML5 & the Open Web Platform

● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ●

HTML5 logo

Bert Bos (W3C) <bert@w3.org>

Presented at:
Iran Web Festival
Tehran, Iran
26 January 2012

History of HTML

● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ●

Version Year Syntax Purpose
before 2.0 ±1991 SGML For hypertext documents
HTML 2.0 1995 SGML Bug fixes, better use of SGML
HTML 3.2 1997 SGML Temporary specification to document various HTML variants, preparation for HTML 4
HTML 4.0 & 4.01 1997, 1999 SGML Support for internationalization, style sheets, accessibility, multimedia and scripting
XHTML 1.0 & 1.1 2000, 2001 XML Alternative syntax of HTML 4 for XML-based environments.

Why HTML5?

● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ●

No consensus on anything else for creating the UI of Web applications

Small improvements to document mark-up (<time>, <section>, etc.)

Make SVG (Tiny 1.2) and MathML (3.0) a required part of HTML

Document features (1/2)

● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ●

FeatureDescription
<time> encode date and/or time (e.g., for microformats)
<aside> footnote/sidenote
<details>, <summary> collapsing/expanding text
<figure>, <figcaption> a figure with a caption
<header>, <footer> introductory, resp., concluding section of a chapter
<hgroup> to create subtitles

Document features (2/2)

● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ●

FeatureDescription
<section>, <article> variants of div
<nav> encloses elements that are for navigation, rather than information
<ruby>, <rp>, <rb> ruby annotations
<bdi> bidi isolation, keep words together in bidirectional (right to left) text
MathML MathML 3.0 is included in HTML5
SVG SVG Tiny 1.2 is included in HTML5

SVG filters appled through CSS, not only to SVG, but to any element (proposed feature, first working draft expected soon)

MathML line breaking.

Web Client 2001

● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ●

Web Client 2011

● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ●

Over 100 specifications and counting…

● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ●

Timeline

● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ●

Each component follows its own timeline:

HTML5 or XHTML5?

● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ●

HTML5 <video>

● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ●

<video controls preload=auto poster="poster.png">
 <source src="trailer.mp4" type="video/mp4">
 <source src="trailer.webm" type="video/webm">
 <track kind=subtitles src="brave.en"
   srclang=en label="English">
 <track kind=captions src="brave_bis.en"
   srclang=en label="English for the Hard of Hearing">
 <track kind=subtitles src="brave.fr"
   srclang=fr label="Français">
 <p>Your user agent does not support
  the HTML5 Video element.
</video>

Codecs and formats

● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ●

Codecs and formats

● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ●

Chrome Firefox Internet Explorer Opera Safari
video/mp4 * ✔ ✔
video/ogg ✔ ✔ ✔
video/webm ✔ ✔ * ✔

* if users install a plugin

Canvas

● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ●

Resolution-dependent bitmap canvas

  <canvas width="720" height="400">
  </canvas>

Associated APIs:

ctx = canvas.getContext('2d');

SVG and Video

● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ●

You can use SVG to draw the UI

<video>...</video>
<div id="controls">
 <svg xmlns="http://www.w3.org/2000/svg"...>
  ...
  <g id="s-PlayButton">
   <path id="s-PlayLogo"
    style="fill:#ffffff;fill-opacity:1"
    d="M 43,10 L 43,22 L 53,16 L 43,10 z"/>
   ...
  </g>...</svg>
 ...
</div>
...
document.getElementById("s-PlayBack").
 addEventListener("click", svp_playButton, false);

SVG and Canvas

● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ●

SVG ↔ Canvas
document-based
(Google indexes SVG)
↔ script-based
vectors ↔ pixel operations
object model with hit-testing and events ↔ low-level graphics API, no scene graph
performance hit with large number of shapes ↔ fast rendering
accessible ↔ must create accessible equivalent

SVG vs Canvas

● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ●

SVG ↔ Canvas
user interfaces ↔ fast-paced games
scalable images ↔ very complex images
interactive animations ↔ highly dynamic visualizations
for designers ↔ for developers

Forms & Fallbacks

● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ●

<input placeholder="Type here" type='text'>
<input type='range' min='3' max='18'>
<input type='search' required>
<input type='tel'>
<input type='url'>
<input type='email'>
<input type='date'>
<input type='time'>
<input type='color'>
<input type='number'>
<input type='submit'>

Web Open Font Format (WOFF)

● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ●

Jabberwocky
'Twas brillig, and the slithy toves
Did gyre and gimble in the wabe;
All mimsy were the borogoves,
And the mome raths outgrabe.

(Jabberwocky, by Lewis Carroll)

Memory Game

● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ●

A little game written in JavaScript.

The images are actually letters in a font.

MathML

● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ●

MathML3 is included in HTML5:

...
<ul>
 <li>
  <math mode="display">
   <mrow>
    <munderover>
     <mo>∑</mo>
     <mrow>
      <mi>i</mi>
      <mo>=</mo>
      <mn>1</mn>
     </mrow>
     <mi>p</mi>
    </munderover>
    ...

Web Application APIs

● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ●

Geolocation API

● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ●

Different devices and user agents have different ways to determine position.

(Often multiple ways: GPS, Google Location Services…)

Single API for Web applications.

Privacy considerations: device (or user agent) must provide user with ways to easily grant/revoke permission to use location data.

Web Storage

● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ●

window.localStorage['MyValue']
   = "pretty value";

p.textContent
   = window.localStorage['MyValue'];
p.textContent
   = window.sessionStorage['MyValue'];

WebSockets

● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ●

Audio API

● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ●

Goal: Advanced audio capabilities for HTML5 audio

Device APIs

● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ●

Device APIs to access camera, microphones, calendars, address books and system info

Web Performance APIs

● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ●

Goal: provide methods to enhance aspects of application performance of user agent features and APIs.

requestAnimationFrame

● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ●

Lets computer decide when to draw the next frame

function draw_cb(time) {
  // ... update display here...
  // Re-queue ourselves:
  window.requestAnimationFrame(draw_cb);
}

To start an animation:

id = window.requestAnimationFrame(draw_cb);

To cancel a queued request:

window.cancelRequestAnimationFrame(id);

Web Real-Time Communications API

● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ●

See also IETF RTCWeb.

Security Considerations

● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ●

Be aware of security and privacy considerations before using those features!

As a Web developer:

See also OWASP top 10.

Online Privacy

● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ●

November 14, 2011: First Draft of Standard for Online Privacy

Accessible Rich Internet Applications (WAI-ARIA 1.0)

● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ●

<li role=menuitemcheckbox onclick='...'
  aria-checked=true>Sort by Name</li>

The contract model with accessibility APIs

Status (subset) (1/2)

● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ●

Status Chrome 13 Firefox 6 IE 9Opera 11.50 Safari 5
Video WD ☼ ☼ ☼ ☼ ☼
Video formats - MPEG4 / WebM WebM MPEG4 / WebMWebM MPEG4 / WebM
2D Canvas WD ☼ ☼ ☼ ☼ ☼
SVG ✔ ☼ ☼ ☼ ☼ ☼
Forms WD ☁ ☁ ☼ ☁
Multithreading (Workers) WD ☼ ☼ ☼ ☼
Bidirectional protocol WD ☂ ☂ ☂
Web storage WD ☼ ☼ ☼ ☼ ☼
Indexed DB WD ☁
2D Transforms FPWD ☼ ☼ ☼ ☼ ☼

→

Status (subset) (2/2)

● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ●

Status Chrome 13 Firefox 6 IE 9Opera 11.50 Safari 5
3D Transforms FPWD ☁ ☁ ☁
Transitions FPWD ☼ ☼ ☼ ☂
Animations FPWD ☁ ☁
Fonts WD ☼ ☼ ☼ ☼ ☼
Geolocation ✔ ☼ ☼ ☼ ☼ ☼
Navigation Timing ✔ ☼ ☼
Media Queries ✔ ☼ ☼ ☼ ☼ ☼
Drag/drop WD ☼ ☼ ☼ ☼ ☼
HTML5 parser WD ☼ ☼ ☼ ☼

Try caniuse.com

Feature Detection!

● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ●

Do not copy the following code:

if (/MSIE (\d+\.\d+);/.test(navigator.userAgent)){
 var ieversion=new Number(RegExp.$1) // capture x.x portion and store as a number
 if (ieversion>=9)
  return true;
 else
  return false;

You should write instead:

if (!!navigator.geolocation)

Try Modernizr

Can you use this platform?

● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ●

What's missing? (1/2)

● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ●

→

What's missing? (2/2)

● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ●

The end

● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ●

http://www.w3.org/Talks/2012/0125-HTML-Tehran/

W3C

To Lead the Web to its full potential

To Anticipate the Trends

To Increase your company value

Join W3C

http://www.w3.org/Consortium/join

or contact: Bernard Gidon <bgidon@w3.org>

Bert Bos <bert@w3.org>
GPG fingerprint:
7744 0204 52A5 14D9 147D
2A13 2D7A E420 184B 5BA4