html5 & friends

120
HTML 5 and friends

Upload: remy-sharp

Post on 12-May-2015

7.958 views

Category:

Technology


0 download

DESCRIPTION

I look at HTML 5, the language the APIs and the big number 2022.Lots of examples for you check out.

TRANSCRIPT

Page 1: HTML5 & Friends

HTML 5and friends

Page 2: HTML5 & Friends

2022

Page 3: HTML5 & Friends

Queen Elizabeth II Platinum Jubilee

Page 4: HTML5 & Friends
Page 5: HTML5 & Friends

2022 = two completely interoperable

implementations

Page 6: HTML5 & Friends

CSS 2.1

Page 7: HTML5 & Friends

Last call:

October 2009

Page 8: HTML5 & Friends

Get Involved

Page 9: HTML5 & Friends

whatwgwg.org/mailing-list

irc://irc.freenode.net/#whatwg

whatwg.org/html5

dev.w3.org/html5

Page 10: HTML5 & Friends

html5doctor.com

html5demos.com

Page 11: HTML5 & Friends

HTML 5 in 5 seconds

Page 12: HTML5 & Friends

<!DOCTYPE html>

Page 13: HTML5 & Friends

What about XHTML?

Page 14: HTML5 & Friends

“pave the cowpaths”

http://www.w3.org/TR/html-design-principles/#pave-the-cowpaths

Page 15: HTML5 & Friends

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"

"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html xmlns="http://www.w3.org/1999/xhtml"

xml:lang="en" lang="en">

<head>

<meta http-equiv="Content-Type"

content="text/html; charset=utf-8"/>

Page 16: HTML5 & Friends

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"

"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html xmlns="http://www.w3.org/1999/xhtml"

xml:lang="en" lang="en">

<head>

<meta http-equiv="Content-Type"

content="text/html; charset=utf-8"/>

Page 17: HTML5 & Friends

<!DOCTYPE html>

<html lang="en">

<head>

<meta charset=utf-8 />

Page 18: HTML5 & Friends

<style> article, aside, dialog, figure, footer, header, hgroup, menu, nav, section { display: block; }</style>

Page 19: HTML5 & Friends
Page 20: HTML5 & Friends
Page 21: HTML5 & Friends

document.createElement

Page 22: HTML5 & Friends

document.createElement(‘article’);document.createElement(‘nav’);document.createElement(‘section’);document.createElement(‘header’);document.createElement(‘footer’);...

Page 23: HTML5 & Friends

<!DOCTYPE html><html><head><meta charset=utf-8 /><title>HTML 5 complete</title><!--[if IE]><script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script><![endif]--><style> article, aside, dialog, figure, footer, header, hgroup, menu, nav, section { display: block; }</style></head><body><!-- we’re ready for HTML 5 goodness now --></body></html>

Page 24: HTML5 & Friends

<!DOCTYPE html><html><head><meta charset=utf-8 /><title>HTML 5 complete</title><!--[if IE]><script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script><![endif]--><style> article, aside, dialog, figure, footer, header, hgroup, menu, nav, section { display: block; }</style></head><body><!-- we’re ready for HTML 5 goodness now --></body></html>

Page 25: HTML5 & Friends

<!DOCTYPE html><html><head><meta charset=utf-8 /><title>HTML 5 complete</title><!--[if IE]><script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script><![endif]--><style> article, aside, dialog, figure, footer, header, hgroup, menu, nav, section { display: block; }</style></head><body><!-- we’re ready for HTML 5 goodness now --></body></html>

Page 26: HTML5 & Friends

<!DOCTYPE html><html><head><meta charset=utf-8 /><title>HTML 5 complete</title><!--[if IE]><script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script><![endif]--><style> article, aside, dialog, figure, footer, header, hgroup, menu, nav, section { display: block; }</style></head><body><!-- we’re ready for HTML 5 goodness now --></body></html>

Page 27: HTML5 & Friends

<!DOCTYPE html><html><head><meta charset=utf-8 /><title>HTML 5 complete</title><!--[if IE]><script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script><![endif]--><style> article, aside, dialog, figure, footer, header, hgroup, menu, nav, section { display: block; }</style></head><body><!-- we’re ready for HTML 5 goodness now --></body></html>

Page 28: HTML5 & Friends

Firefox 2 & Camino 1

Page 29: HTML5 & Friends

Firefox 2 & Camino 1

...are not A-grade browsers.

Page 30: HTML5 & Friends

HTML 5

Page 31: HTML5 & Friends

Language

Page 32: HTML5 & Friends

Language

Page 33: HTML5 & Friends
Page 34: HTML5 & Friends

•Layout: header, hgroup, footer, section, article, nav, menu, dialog, aside

Page 35: HTML5 & Friends

•Layout: header, hgroup, footer, section, article, nav, menu, dialog, aside

•Inline: time, details, figure, mark

Page 36: HTML5 & Friends

•Layout: header, hgroup, footer, section, article, nav, menu, dialog, aside

•Inline: time, details, figure, mark

•Interactive: audio, video, (source), canvas, datagrid*

Page 37: HTML5 & Friends

Marking upwith thanks to Bruce!

Page 38: HTML5 & Friends
Page 39: HTML5 & Friends
Page 40: HTML5 & Friends

A Blog Post

Credit: fujinonbinos.com

Page 41: HTML5 & Friends
Page 42: HTML5 & Friends

Native MediaElements

Page 43: HTML5 & Friends

<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="425" height="344" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param name="allowFullScreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="src" value="http://www.youtube.com/v/oHg5SJYRHA0&hl=en&fs=1&" /><param name="allowfullscreen" value="true" /><embed type="application/x-shockwave-flash" width="425" height="344" src="http://www.youtube.com/v/oHg5SJYRHA0&hl=en&fs=1&" allowscriptaccess="always" allowfullscreen="true"></embed></object>

Page 44: HTML5 & Friends

<video width="425" height="344">

<source src="dancing_cats.ogg" />

<source src="dancing_cats.mp4" />

</video>

Page 47: HTML5 & Friends
Page 48: HTML5 & Friends

<video> <!-- native support --> <source />

<!-- QuickTime support --> <object><param></object>

<!-- fail down to flash --> <object><param></object></video>

Page 49: HTML5 & Friends

<video> <!-- native support --> <source />

<!-- QuickTime support --> <object><param></object>

<!-- fail down to flash --> <object><param></object></video>

Page 50: HTML5 & Friends

<video> <!-- native support --> <source />

<!-- QuickTime support --> <object><param></object>

<!-- fail down to flash --> <object><param></object></video>

Page 51: HTML5 & Friends

<video> <!-- native support --> <source />

<!-- QuickTime support --> <object><param></object>

<!-- fail down to flash --> <object><param></object></video>

Page 52: HTML5 & Friends

<video> <!-- native support --> <source />

<!-- QuickTime support --> <object><param></object>

<!-- fail down to flash --> <object><param></object></video>

Page 53: HTML5 & Friends

•dirt easy doctype

•a element wraps anything

•video & audio

•Possibility for cross ARIA support

Things that make me go 'Aay:

Page 54: HTML5 & Friends
Page 55: HTML5 & Friends

Stuff that sucks

Page 56: HTML5 & Friends

Stuff that sucks

•legend - in figure & details

Page 57: HTML5 & Friends

Stuff that sucks

•legend - in figure & details

•small - should be like a, ins & del

Page 58: HTML5 & Friends

Stuff that sucks

•legend - in figure & details

•small - should be like a, ins & del

•canvas accessibility

Page 59: HTML5 & Friends

Stuff that sucks

•legend - in figure & details

•small - should be like a, ins & del

•canvas accessibility

•video codecs - no agreement

Page 60: HTML5 & Friends

Stuff that sucks

•legend - in figure & details

•small - should be like a, ins & del

•canvas accessibility

•video codecs - no agreement

•The Vomit Bug

Page 61: HTML5 & Friends

HTML 5 APIs

Page 62: HTML5 & Friends

HTML 5 APIs

Page 63: HTML5 & Friends

JavaScripty Stuff

•Canvas

•Drag & Drop

•History

•Inline Editing

•Messaging

•Offline Apps

•Video & Audio

•Geolocation

•Local Storage

•Selectors

•Server Events

•Web Sockets

•Workers

Page 64: HTML5 & Friends

JavaScripty Stuff

•Canvas

•Drag & Drop

•History

•Inline Editing

•Messaging

•Offline Apps

•Video & Audio

•Geolocation

•Local Storage

•Selectors

•Server Events

•Web Sockets

•Workers

Page 65: HTML5 & Friends

JavaScripty Stuff

•Canvas

•Drag & Drop

•History

•Inline Editing

•Messaging

•Offline Apps

•Video & Audio

•Geolocation

•Local Storage

•Selectors

•Server Events

•Web Sockets

•Workers

Page 66: HTML5 & Friends

JavaScripty Stuff

•Canvas

•Drag & Drop

•History

•Inline Editing

•Messaging

•Offline Apps

•Video & Audio

•Geolocation

•Local Storage

•Selectors

•Server Events

•Web Sockets

•Workers

Page 67: HTML5 & Friends

Canvas

Page 68: HTML5 & Friends

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

// Create radial gradientvar grad = ctx.createRadialGradient(0,0,0,0,0,600); grad.addColorStop(0, '#E4E4E4');grad.addColorStop(1, '#000');

// assign gradients to fillctx.fillStyle = grad; // draw 600x600 fillctx.fillRect(0,0,600,600);

Page 69: HTML5 & Friends

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

// Create radial gradientvar grad = ctx.createRadialGradient(0,0,0,0,0,600); grad.addColorStop(0, '#E4E4E4');grad.addColorStop(1, '#000');

// assign gradients to fillctx.fillStyle = grad; // draw 600x600 fillctx.fillRect(0,0,600,600);

Page 70: HTML5 & Friends

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

// Create radial gradientvar grad = ctx.createRadialGradient(0,0,0,0,0,600); grad.addColorStop(0, '#E4E4E4');grad.addColorStop(1, '#000');

// assign gradients to fillctx.fillStyle = grad; // draw 600x600 fillctx.fillRect(0,0,600,600);

Page 71: HTML5 & Friends

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

// Create radial gradientvar grad = ctx.createRadialGradient(0,0,0,0,0,600); grad.addColorStop(0, '#E4E4E4');grad.addColorStop(1, '#000');

// assign gradients to fillctx.fillStyle = grad; // draw 600x600 fillctx.fillRect(0,0,600,600);

Page 72: HTML5 & Friends

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

// Create radial gradientvar grad = ctx.createRadialGradient(0,0,0,0,0,600); grad.addColorStop(0, '#E4E4E4');grad.addColorStop(1, '#000');

// assign gradients to fillctx.fillStyle = grad; // draw 600x600 fillctx.fillRect(0,0,600,600);

Page 73: HTML5 & Friends
Page 76: HTML5 & Friends

Drag'n Drop

Page 77: HTML5 & Friends

Drag & Drop

•Events: dragover, dragenter, drop

•event.transferData contains strings

•Links & Images draggable by default

•Anything else: draggable="true"*

Page 78: HTML5 & Friends

var drop = document.querySelector('#drop');

// Tells browser that we can drop on this targetaddEvent(drop, 'dragover', cancelEvent);addEvent(drop, 'dragenter', cancelEvent);

addEvent(drop, 'drop', function (event) { // stops browser from redirecting to the text. if (event.preventDefault) { event.preventDefault(); }

alert( event.dataTransfer.getData('Text') );

return false;});

function cancelEvent(event) { if (event.preventDefault) { event.preventDefault(); } return false;}

Page 79: HTML5 & Friends

var drop = document.querySelector('#drop');

// Tells browser that we can drop on this targetaddEvent(drop, 'dragover', cancelEvent);addEvent(drop, 'dragenter', cancelEvent);

addEvent(drop, 'drop', function (event) { // stops browser from redirecting to the text. if (event.preventDefault) { event.preventDefault(); }

alert( event.dataTransfer.getData('Text') );

return false;});

function cancelEvent(event) { if (event.preventDefault) { event.preventDefault(); } return false;}

Page 80: HTML5 & Friends

var drop = document.querySelector('#drop');

// Tells browser that we can drop on this targetaddEvent(drop, 'dragover', cancelEvent);addEvent(drop, 'dragenter', cancelEvent);

addEvent(drop, 'drop', function (event) { // stops browser from redirecting to the text. if (event.preventDefault) { event.preventDefault(); }

alert( event.dataTransfer.getData('Text') );

return false;});

function cancelEvent(event) { if (event.preventDefault) { event.preventDefault(); } return false;}

Page 81: HTML5 & Friends

var drop = document.querySelector('#drop');

// Tells browser that we can drop on this targetaddEvent(drop, 'dragover', cancelEvent);addEvent(drop, 'dragenter', cancelEvent);

addEvent(drop, 'drop', function (event) { // stops browser from redirecting to the text. if (event.preventDefault) { event.preventDefault(); }

alert( event.dataTransfer.getData('Text') );

return false;});

function cancelEvent(event) { if (event.preventDefault) { event.preventDefault(); } return false;}

Page 82: HTML5 & Friends

var drop = document.querySelector('#drop');

// Tells browser that we can drop on this targetaddEvent(drop, 'dragover', cancelEvent);addEvent(drop, 'dragenter', cancelEvent);

addEvent(drop, 'drop', function (event) { // stops browser from redirecting to the text. if (event.preventDefault) { event.preventDefault(); }

alert( event.dataTransfer.getData('Text') );

return false;});

function cancelEvent(event) { if (event.preventDefault) { event.preventDefault(); } return false;}

Page 83: HTML5 & Friends

var drop = document.querySelector('#drop');

// Tells browser that we can drop on this targetaddEvent(drop, 'dragover', cancelEvent);addEvent(drop, 'dragenter', cancelEvent);

addEvent(drop, 'drop', function (event) { // stops browser from redirecting to the text. if (event.preventDefault) { event.preventDefault(); }

alert( event.dataTransfer.getData('Text') );

return false;});

function cancelEvent(event) { if (event.preventDefault) { event.preventDefault(); } return false;}

Page 84: HTML5 & Friends

var drop = document.querySelector('#drop');

// Tells browser that we can drop on this targetaddEvent(drop, 'dragover', cancelEvent);addEvent(drop, 'dragenter', cancelEvent);

addEvent(drop, 'drop', function (event) { // stops browser from redirecting to the text. if (event.preventDefault) { event.preventDefault(); }

alert( event.dataTransfer.getData('Text') );

return false;});

function cancelEvent(event) { if (event.preventDefault) { event.preventDefault(); } return false;}

Page 85: HTML5 & Friends

<style> [draggable=true] { -khtml-user-drag: element; }</style>

<div draggable="true">drag me</div>

<script>var items = document.querySelectorAll('[draggable=true]');

for (var i = 0; i < dragItems.length; i++) { addEvent(items[i],'dragstart',function(event) { event.dataTransfer.setData('Text', this.id); });}</script>

Page 86: HTML5 & Friends

<style> [draggable=true] { -khtml-user-drag: element; }</style>

<div draggable="true">drag me</div>

<script>var items = document.querySelectorAll('[draggable=true]');

for (var i = 0; i < dragItems.length; i++) { addEvent(items[i],'dragstart',function(event) { event.dataTransfer.setData('Text', this.id); });}</script>

Page 87: HTML5 & Friends

<style> [draggable=true] { -khtml-user-drag: element; }</style>

<div draggable="true">drag me</div>

<script>var items = document.querySelectorAll('[draggable=true]');

for (var i = 0; i < dragItems.length; i++) { addEvent(items[i],'dragstart',function(event) { event.dataTransfer.setData('Text', this.id); });}</script>

Page 88: HTML5 & Friends

<style> [draggable=true] { -khtml-user-drag: element; }</style>

<div draggable="true">drag me</div>

<script>var items = document.querySelectorAll('[draggable=true]');

for (var i = 0; i < dragItems.length; i++) { addEvent(items[i],'dragstart',function(event) { event.dataTransfer.setData('Text', this.id); });}</script>

Page 89: HTML5 & Friends

<style> [draggable=true] { -khtml-user-drag: element; }</style>

<div draggable="true">drag me</div>

<script>var items = document.querySelectorAll('[draggable=true]');

for (var i = 0; i < dragItems.length; i++) { addEvent(items[i],'dragstart',function(event) { event.dataTransfer.setData('Text', this.id); });}</script>

Page 90: HTML5 & Friends

<style> [draggable=true] { -khtml-user-drag: element; }</style>

<div draggable="true">drag me</div>

<script>var items = document.querySelectorAll('[draggable=true]');

for (var i = 0; i < dragItems.length; i++) { addEvent(items[i],'dragstart',function(event) { event.dataTransfer.setData('Text', this.id); });}</script>

Page 91: HTML5 & Friends

<style> [draggable=true] { -khtml-user-drag: element; }</style>

<div draggable="true">drag me</div>

<script>var items = document.querySelectorAll('[draggable=true]');

for (var i = 0; i < dragItems.length; i++) { addEvent(items[i],'dragstart',function(event) { event.dataTransfer.setData('Text', this.id); });}</script>

Page 92: HTML5 & Friends

http://html5demos.com/drag

Page 93: HTML5 & Friends

http://html5demos.com/drag

Page 94: HTML5 & Friends

Offline Applications

Page 95: HTML5 & Friends

Offline Apps

•Application cache

•Events: offline, online

•navigator.onLine property

Page 96: HTML5 & Friends

Enable

<html manifest="my.manifest">

Page 97: HTML5 & Friends

CACHE MANIFEST

images/shade.jpg

images/bin.jpg

my.manifest

Page 98: HTML5 & Friends

Cache

•First line: CACHE MANIFEST

•Requires text/cache-manifest

•Recommend using versioning

•window.applicationCache

Page 99: HTML5 & Friends

Cache

•On load will request my.manifest

Page 100: HTML5 & Friends

Cache

•On load will request my.manifest

•Change manifest: trigger reload

Page 101: HTML5 & Friends

Cache

•On load will request my.manifest

•Change manifest: trigger reload

•applicationCache.update() force

Page 102: HTML5 & Friends

Cache

•On load will request my.manifest

•Change manifest: trigger reload

•applicationCache.update() force

•Cache events

Page 103: HTML5 & Friends
Page 104: HTML5 & Friends
Page 105: HTML5 & Friends

Geolocation

Page 106: HTML5 & Friends

Not always accurate!

Page 107: HTML5 & Friends
Page 108: HTML5 & Friends

navigator .geolocation .getCurrentPosition( success, err );

Page 109: HTML5 & Friends
Page 110: HTML5 & Friends

Web Workers

Page 111: HTML5 & Friends

•Threads

Page 112: HTML5 & Friends

•Threads

•Native or via Gears

Page 113: HTML5 & Friends

•Threads

•Native or via Gears

•Sandboxed

Page 114: HTML5 & Friends

•Threads

•Native or via Gears

•Sandboxed

•Debugging?

Page 115: HTML5 & Friends

Without

Page 116: HTML5 & Friends

http://html5demos.com/worker

Page 117: HTML5 & Friends

And a

lotmore...

Page 118: HTML5 & Friends
Page 119: HTML5 & Friends

Attributes: data-*, itemProp, sandbox (on iframes)

Microdata API, datagrid, XHR2, Database Storage

Web Forms 2.0: client validation, new input types, date time pickers

ARIA overlap

querySelector

<progress><meter><datalist><ruby>

Page 120: HTML5 & Friends

RemySharp @[email protected]

html5demos.comhtml5doctor.com

JavaScript Conference:full-frontal.org

Photos by nesster, adactio, badlogik, f_mafra, dearbarbie, ilcello, thefangmonster, anniewong, aztlek, emeraldrose