demystifying html5

77
DEMYSTIFYING HTML5 SERGEJUS BARINOVAS ARCHITECT, ADFORM

Upload: sergejus-barinovas

Post on 10-May-2015

3.689 views

Category:

Technology


0 download

TRANSCRIPT

Page 1: Demystifying HTML5

DEMYSTIFYING

HTML5

SERGEJUS BARINOVAS

ARCHITECT, ADFORM

Page 2: Demystifying HTML5

AGENDA

• The history of HTML5

• What’s new in HTML5

• HTML5 vs. Silverlight & Flash

• Next steps

Page 3: Demystifying HTML5

MY HTML5 BACKGROUND

• Interest in HTML5 for ~1 year

• HTML5 workshop in Las Vegas

• Advertising is dependent on Flash (doesn’t work with iOS devices)

Page 4: Demystifying HTML5

DISCLAIMER

This is not about

Page 5: Demystifying HTML5

THE HISTORY OF HTML5

Page 6: Demystifying HTML5

HTML QUIZ

What language HTML is based on?

Page 7: Demystifying HTML5

HTML QUIZ ANSWER

SGML

Page 8: Demystifying HTML5

HTML5 QUIZ

What is HTML5?

Page 9: Demystifying HTML5

HTML5 QUIZ ANSWER

• HTML (HTML5, SVG1.1)

• CSS (CSS3)

• JavaScript API

Page 10: Demystifying HTML5

A BIT OF HISTORY

199

1 H

TM

L

199

4 H

TM

L2

199

6 C

SS

, Ja

va

Sc

rip

t

199

7 H

TM

L 3

.2, H

TM

L4

199

8 C

SS

2

199

9 H

TM

L 4

.01

200

0 X

HT

ML

1.0

200

5 C

SS

3 D

raft

200

8 H

TM

L5

Dra

ft

Page 11: Demystifying HTML5

HTML XHTML

• 1998 XML 1.0

• 1999 HTML 4.01

• 2000 XHTML 1.0• Reformulate HTML in XML without

adding any new elements or attributes• First draft of XForms 1.0

Page 12: Demystifying HTML5

XHTML – THE TRUTH

Who is developing XHTML web sites?

Page 13: Demystifying HTML5

XHTML – THE TRUTH

You are (probably) lying!

Page 14: Demystifying HTML5

XHTML – THE TRUTH

Everything you know about XHTML is wrong

Page 15: Demystifying HTML5

XHTML – THE TRUTH

• HTML 4.01• HTML 4.01 DOCTYPE• MIME type – text/html• Browsers forgive malformed HTML

• XHTML 1.0• XHTML 1.0 DOCTYPE• MIME type – application/xhtml+xml• Browsers fail on the first error

(draconian error handling)

Page 16: Demystifying HTML5

XHTML – THE TRUTH

XHTML – forget about existing (99%) web sites!

Page 17: Demystifying HTML5

XHTML – THE TRUTH

Thousands of web developers upgraded to XHTML syntax and DOCTYPE but kept serving it with a text/html MIME type

Page 18: Demystifying HTML5

XHTML – THE TRUTH

This is not an XHTML!

Page 19: Demystifying HTML5

A-HA MOMENT

We need to move on supporting interop!

Page 20: Demystifying HTML5

THE FUTURE OF HTML

June 2004, W3C Workshop An evolution of the existing HTML 4 standard to include

new features for modern web application developer

Page 21: Demystifying HTML5

THE FUTURE OF HTML 7 PRINCIPLES

• Backwards compatibility, clear migration path

• Well-defined error handling

• Users should not be exposed to authoring errors

• Practical use

• Scripting is here to stay

• Device-specific profiling should be avoided

• Open process

Page 22: Demystifying HTML5

THE FUTURE OF HTML THE POLL

Should the W3C develop declarative extension to HTML and CSS and imperative extensions to DOM?

11 to 8 against

Page 23: Demystifying HTML5

THE FUTURE OF HTML THE SPLIT

• W3C• XHTML 2.0

• WHAT Working Group• Documenting the forgiving error-handling

algorithms that browsers actually used• XForms 2.0• <canvas>• <audio> and <video>

Page 24: Demystifying HTML5

THE FUTURE OF HTMLTHE REUNION

October 2006, Tim Berners-Leeannounced that the W3C would work together with the

WHAT Working Group to evolve HTML

Page 25: Demystifying HTML5

THE FUTURE OF HTMLFIRST DRAFT

January 2008, HTML5 DraftThe first time ever all 5 major browser

vendors collaborate together

Page 26: Demystifying HTML5

THE FUTURE OF HTMLCURRENT SITUATION

First Public Working Draft

Working Draft

Candidate Recommend

ation

Proposed Recommend

ation

Recommendation

Last callCall to implement

HTML5

Page 27: Demystifying HTML5

WHAT’S NEW IN HTML5

JAVASCRIPT API

Page 28: Demystifying HTML5

WHAT’S NEW – JAVASCRIPT API

• New Selectors

• Web Workers*

• Web Sockets*

• Web Storage

• Offline Apps*

• Geolocation

Page 29: Demystifying HTML5

WHAT’S NEW – JS APINEW SELECTORS

• DOM APIvar els = document.getElementsByClassName('section');

els[0].focus();

• Selector APIvar els = document.querySelectorAll('ul li:nth-child(odd)');

Page 30: Demystifying HTML5

WHAT’S NEW – JS APIWEB WORKERS

• Independent JavaScript threadingmain.js:

var worker = new Worker('increment.js');

worker.postMessage(2);

worker.onmessage = function(event) { alert(event.data); };

increment.js:

self.onmessage = function(event) {

var result = event.data + 1;

self.postMessage(result);

}

Page 31: Demystifying HTML5

WHAT’S NEW – JS APIWEB SOCKETS

• Bi-directional full-duplex communicationvar socket = new WebSocket(location);

socket.onopen = function(event) {

socket.postMessage('Hello, WebSocket');

}

socket.onmessage = function(event) { alert(event.data); }

socket.onclose = function(event) { alert('closed'); }

Page 32: Demystifying HTML5

WHAT’S NEW – JS APIWEB STORAGE

• Local Storagevar item = document.localStorage.setItem('key','value');

• Session Storagevar item = document.sessionStorage.getItem('value');

• IndexedDBvar db = indexedDB.open('books', 'Books');

db.createIndex('BookTitle', 'books', 'title');

var index = db.index('BookTitle');

var result = index.get('HTML5');

Page 33: Demystifying HTML5

WHAT’S NEW – JS APIOFFLINE APPS

• Application Cache<html manifest="offline.manifest">

CACHE MANIFEST

styles.css

jquery-1.4.min.js

index.html

• Offline / Online Eventswindow.addEventListener("online",function() {alert('on')});

window.addEventListener("offline",function() {alert('off')});

Page 34: Demystifying HTML5

WHAT’S NEW – JS APIGEOLOCATION

• Geolocation APIif (navigator.geolocation) {

navigator.geolocation.getCurrentPosition(function(pos) {

var lat = position.coords.latitude;

var lng = position.coords.longitude;

alert(lat + ':' + lng);

});

}

Page 35: Demystifying HTML5

WHAT’S NEW IN HTML5

CSS3

Page 36: Demystifying HTML5

WHAT’S NEW – CSS3

• Selectors

• Border Radius

• Backgrounds

• Color & Opacity

• Shadows

• 2D Transforms

• WOFF Fonts

Page 37: Demystifying HTML5

WHAT’S NEW – CSS3SELECTORS

• Selectors.row:nth-child(even) { background: #dde; }

• Specific attributesinput[type="text"] {background: #eee; }

• Negation:not(span) { display: block; }

• Selection::selection { background: #c00; }

Page 38: Demystifying HTML5

WHAT’S NEW – CSS3BORDER RADIUS

border-radius: 20px 10px;

border-top-left-radius: 20px 10px;

border-top-right-radius: 10px 25px;

border-bottom-right-radius: 5px 10px;

border-bottom-left-radius: 15px 25px;

Page 39: Demystifying HTML5

WHAT’S NEW – CSS3BACKGROUNDS

• Multiple backgroundsdiv {

background-image: url(bg1.png), url(bg2.png);

background-position: center center, 20% 80%, top left;

}

• SVG in CSS backgroundsbody { background-image: url("marble.svg") }

Page 40: Demystifying HTML5

WHAT’S NEW – CSS3COLOR & OPACITY

• RGB / RGBAdiv.demo1 { background: rgba(60, 80, 100, 0.25); }

• HSL / HSLAdiv.demo2 { background: hsla(320, 100%, 25%, 0.4); }

• Opacitydiv.demo3 { background:#036; opacity:0.2; }

Page 41: Demystifying HTML5

WHAT’S NEW – CSS3SHADOWS

• Box Shadowdiv { box-shadow: 5px 5px 7px #888; }

• Text Shadowspan { text-shadow: 2px 2px 7px #111; }

Page 42: Demystifying HTML5

WHAT’S NEW – CSS32D TRANSFORMS

div {

transform: scale(0.75) rotate(0deg) translate(0px, 0px) skew(0deg, 0deg);

transform-origin: 0% 0%;

}

Page 43: Demystifying HTML5

WHAT’S NEW – CSS3WOFF FONTS

• Font Linking@font-face {

font-family: Whimsy;

src: url('fonts/Whimsy.woff');

}

Page 44: Demystifying HTML5

WHAT’S NEW IN HTML5

HTML5

Page 45: Demystifying HTML5

WHAT’S NEW – HTML5SIMPLER MARKUP

HTML5 is simpler

Page 46: Demystifying HTML5

WHAT’S NEW – HTML5SIMPLER MARKUP

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

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

<head>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<title>Sergejus apie .NET</title>

<link rel="stylesheet" href="http://sergejus.blogas.lt/wp-content/themes/webby-green-10/style.css" type="text/css" />

<link rel="alternate" type="application/rss+xml" title="Sergejus apie .NET RSS Feed" href="http://sergejus.blogas.lt/feed" />

Page 47: Demystifying HTML5

WHAT’S NEW – HTML5SIMPLER MARKUP

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

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

<head>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<title>Sergejus apie .NET</title>

<link rel="stylesheet" href="http://sergejus.blogas.lt/wp-content/themes/webby-green-10/style.css" type="text/css" />

<link rel="alternate" type="application/rss+xml" title="Sergejus apie .NET RSS Feed" href="http://sergejus.blogas.lt/feed" />

Page 48: Demystifying HTML5

WHAT’S NEW – HTML5SIMPLER MARKUP

<!doctype html>

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

<head>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<title>Sergejus apie .NET</title>

<link rel="stylesheet" href="http://sergejus.blogas.lt/wp-content/themes/webby-green-10/style.css" type="text/css" />

<link rel="alternate" type="application/rss+xml" title="Sergejus apie .NET RSS Feed" href="http://sergejus.blogas.lt/feed" />

Page 49: Demystifying HTML5

WHAT’S NEW – HTML5SIMPLER MARKUP

<!doctype html>

<html>

<head>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<title>Sergejus apie .NET</title>

<link rel="stylesheet" href="http://sergejus.blogas.lt/wp-content/themes/webby-green-10/style.css" type="text/css" />

<link rel="alternate" type="application/rss+xml" title="Sergejus apie .NET RSS Feed" href="http://sergejus.blogas.lt/feed" />

Page 50: Demystifying HTML5

WHAT’S NEW – HTML5SIMPLER MARKUP

<!doctype html>

<html>

<head>

<meta charset="utf-8" />

<title>Sergejus apie .NET</title>

<link rel="stylesheet" href="http://sergejus.blogas.lt/wp-content/themes/webby-green-10/style.css" type="text/css" />

<link rel="alternate" type="application/rss+xml" title="Sergejus apie .NET RSS Feed" href="http://sergejus.blogas.lt/feed" />

Page 51: Demystifying HTML5

WHAT’S NEW – HTML5SIMPLER MARKUP

<!doctype html>

<html>

<head>

<meta charset="utf-8" />

<title>Sergejus apie .NET</title>

<link rel="stylesheet" href="http://sergejus.blogas.lt/wp-content/themes/webby-green-10/style.css" />

<link rel="alternate" type="application/rss+xml" title="Sergejus apie .NET RSS Feed" href="http://sergejus.blogas.lt/feed" />

Page 52: Demystifying HTML5

WHAT’S NEW – HTML5ELEMENTS

HTML5 is more semantic

Page 53: Demystifying HTML5

WHAT’S NEW – HTML5ELEMENTS

• <section>

• <nav>

• <article>

• <header>

• <footer>

• <aside>

• <figure>

• and more…

Page 54: Demystifying HTML5

WHAT’S NEW – HTML5ELEMENTS

Page 55: Demystifying HTML5

WHAT’S NEW – HTML5ELEMENTS

Page 56: Demystifying HTML5

WHAT’S NEW – HTML5WEB FORMS 2.0

HTML5 is for Web Apps

Page 57: Demystifying HTML5

WHAT’S NEW – HTML5WEB FORMS 2.0• <input type="text" required autofocus />

• <input type="email" value="[email protected]" />

• <input type="date" min="2009-11-22" max="2011-11-22" value="2010-11-22"/>

• <input type="range" min="0" max="50" value="10" />

• <input type="search" results="10" placeholder="Search..." />

• <input type="tel" placeholder="(370) 678-00000" pattern="^\(?\d{3}\)?[-\s]\d{3}[-\s]\d{5}.*?$" />

• <input type="color" placeholder="e.g. #bbbbbb" />

• <input type="number" step="1" min="-5" max="10" value="0" />

Page 58: Demystifying HTML5

WHAT’S NEW – HTML5AUDIO/VIDEO

HTML5 is richer

Page 59: Demystifying HTML5

WHAT’S NEW – HTML5AUDIO/VIDEO

• Audio<audio id="audio" src="sound.mp3" controls />

document.getElementById("audio").muted = false;

• Video<video id="video" src="movie.webm" autoplay controls />

document.getElementById("video").play();

Page 60: Demystifying HTML5

WHAT’S NEW – HTML5AUDIO/VIDEO

• Container / Video + Audio Codecs

• MP4 / H.264 + AAC• Ogg / Theora + Vorbis• WebM

No Single

Combination YET

Page 61: Demystifying HTML5

WHAT’S NEW – HTML5CANVAS

• Simple Shapes

• Paths

• Text

• Gradients

• Images

Page 62: Demystifying HTML5

WHAT’S NEW – HTML5CANVAS<canvas id="canvas" width="838" height="220" />

<script>

var canvasContext = document.getElementById("canvas")

.getContext("2d");

canvasContext.fillRect(250, 25, 150, 100);

canvasContext.beginPath();

canvasContext.arc(450, 110, 100, Math.PI*1/2, Math.PI*3/2);

canvasContext.lineWidth = 15;

canvasContext.lineCap = 'round';

canvasContext.strokeStyle = 'rgba(255, 127, 0, 0.5)';

canvasContext.stroke();

</script>

Page 63: Demystifying HTML5

WHAT’S NEW – HTML5SVG<svg xmlns="http://www.w3.org/2000/svg">

<style type="text/css">

circle:hover {fill-opacity:0.9;}

</style>

<g style="fill-opacity:0.7;">

<circle cx="6cm" cy="2cm" r="100" style="fill:red; stroke:black;

stroke-width:0.1cm" transform="translate(0,50)" />

<circle cx="6cm" cy="2cm" r="100" style="fill:blue; stroke:black;

stroke-width:0.1cm" transform="translate(70,150)" />

<circle cx="6cm" cy="2cm" r="100" style="fill:green; stroke:black;

stroke-width:0.1cm" transform="translate(-70,150)"/>

</g>

</svg>

Page 64: Demystifying HTML5

HTML5 VS. FLASH & SILVERLIGHT

Page 65: Demystifying HTML5

HTML5 VS. FLASH & SILVERLIGHT

HTML5 is the future of Open Web

Page 66: Demystifying HTML5

HTML5 VS. FLASH & SILVERLIGHT

HTML5 is not ready

for main stream yet

Page 67: Demystifying HTML5

HTML5 DRAWBACKS

• Draft version of specification

• No standardized audio / video containers and codecs

• Poor video / graphics performance

• Lack of professional HTML5 tools

Page 68: Demystifying HTML5

HTML5 VS. FLASH & SILVERLIGHT

• Flash & Silverlight will stay for• Enhanced video streaming• Digital rights management (DRM)• Complex RIAs

Page 69: Demystifying HTML5

ADOBE AND HTML5

• Working hard on HTML5 support• HTML5 video player with fallback to Flash• Export images as SVG and Canvas from

Illustrator and Photoshop• Convert Flash to HTML5

Page 70: Demystifying HTML5

MICROSOFT AND HTML5

• Big focus on HTML5 and standards• HTML5 is the only true cross platform solution

for everything, including (Apple’s) iOS platform.Bob Muglia, PDC2010

• Silverlight remains top platform for• Mobile• Desktop applications• Video / audio streaming

Page 71: Demystifying HTML5

NEXT STEPS

Page 72: Demystifying HTML5

NEXT STEPS

HTML5 is notall or nothing

Page 73: Demystifying HTML5

NEXT STEPS

HTML5 is foward compatible!

Page 74: Demystifying HTML5

NEXT STEPS

You can start using it right now!

Page 75: Demystifying HTML5

NEXT STEPS

• Read http://diveintohtml5.org

• Modernizr.js – detects HTML5 support

• ASP.NET MVC HTML5 helpers

• Leverage <video> with fallback to Silverlight or Flash

• Leverage <canvas> and <svg> with fallback to image

Page 76: Demystifying HTML5

NEXT STEPS

Have fun and be creative!

Page 77: Demystifying HTML5

Q & A

THANKS!

sergejus.blogas.lt, @sergejusb