Echo HTML5

71
HTML5 & the future today of the web

description

Slides I co-presented with John Dyer at the 2010 Echo Conference in Dallas, TX. http://johndyer.name/ http://echoconference.com/

Transcript of Echo HTML5

Page 1: Echo HTML5

HTML5 & thefuture todayof the web

Page 2: Echo HTML5

Hello. We are Johnand Nathan. Here isa bit of backgroundabout each of us...

Page 3: Echo HTML5

Master of Divinity

Asbury Theological Seminary

John Dyer

Nathan Smith

Master of TheologyDallas Theological Seminary

+=

= +Desktop OS = Windows

Desktop OS = Mac

Mobile = iOS

Mobile = Android

Page 4: Echo HTML5

What we have in common: We are both web developers who want to see the “Big-C” church better utilize web technologies.

We also both ♥ JavaScript :)

Page 5: Echo HTML5

So, what is HTML5? It is the newest version of HTML. But also a phrase for everything cool + new on the web. Not all that’s labeled HTML5 *is* HTML5. But that’s okay...

Page 6: Echo HTML5

New Hotness!HTML5 + CSS3 + JavaScript

Page 7: Echo HTML5

http://www.apple.com/html5/

Apple likes HTML5

Page 8: Echo HTML5

http://www.html5rocks.com/

Google likes HTML5

Page 9: Echo HTML5

Mozilla (Firefox) likes HTML5

https://developer.mozilla.org/en/HTML/HTML5

Page 10: Echo HTML5

Opera likes HTML5

http://www.opera.com/docs/specs/presto25/html5/

Page 11: Echo HTML5

http://ie.microsoft.com/testdrive/

Last (but not least) – Microsoft likes HTML5

Page 12: Echo HTML5

HTML5is terse

Page 13: Echo HTML5

HTML5<!DOCTYPE html>

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

Simplified doctype declaration

Page 14: Echo HTML5

HTML5<script>// Code here.

</script>

XHTML 1.0 Transitional<script type="text/javascript">/* <![CDATA[ */// Code here./* ]]> */

</script>

Simplified JavaScript embedding

Page 15: Echo HTML5

HTML5<style>// Code here.

</style>

XHTML 1.0 Transitional<style type="text/css">// Code here.

</style>

Simplified embedded styles

Page 16: Echo HTML5

HTML5<link rel="stylesheet" href="file.css" />

XHTML 1.0 Transitional<link rel="stylesheet" href="file.css" type="text/css" media="all" />

Simplified stylesheet linking

Page 17: Echo HTML5

New tagsin HTML5

Page 18: Echo HTML5

<header>

<footer>

<aside>

<nav>

<div class=”content”>

<article>

<section>

<hgroup>

<section>

<dialog>

<p>

etc...

<figure>

<figcaption>

<img />

<details>

<summary>

<p>

etc...

Page 19: Echo HTML5

But the aforementioned tagsdon’t work well in InternetExplorer (IE8 and older).

To make IE behave, youcan use an “HTML5 shim”JavaScript library...

code.google.com/p/html5shim

Page 20: Echo HTML5

... but this requires extra code and adds a bit of fragility to your site (IE breaks w/ JS off).

The up-side is improved semantic richness. In practicality though, there are not (yet) any tangible SEO or accessibility gains to be had.

Given the trade-offs involved, and lack of tangible benefit, we’d recommend continuing to use <div> with “HTML5” class names...

Page 21: Echo HTML5

<div class=”header”>

<div class=”footer”>

<div class=”aside”>

<div class=”nav”>

<div class=”content”>

<div class=”article”>

<div class=”section”>

<div class=”hgroup”>

<div class=”section”>

<div class=”dialog”>

<p>

etc...

<div class=”figure”>

<div class=”figcaption”>

<img />

<div class=”details”>

<div class=”summary”>

<p>

etc...

Page 22: Echo HTML5

... that way, you are writing code with the “semantics” of the new HTML5 tags, without the headaches of worrying about legacy browser support. Then, one great day when IE8 no longer has significant market-share, you can “flip the switch” so to speak.

Now that we’ve got those tags out of the way, let’s talk about the fun parts of HTML5.

Page 23: Echo HTML5

<canvas>+ <svg>

Though SVG (Scalable Vector Graphics) pre-dates HTML5, it is finally viable now that IE9 supports it. This means all major browsers will support SVG and canvas.

Page 24: Echo HTML5

We won’t cover <svg> or <canvas> in detail during this talk, but two helpful JavaScript libraries are worth noting...

Raphaël (SVG) – Dmitry Baranovskiy Processing JS (Canvas) – John Resig

http://www.raphaeljs.com/ http://www.processingjs.org/

Page 25: Echo HTML5

SVG is like construction paper. Layers retaindistinct shapes. SVG files can live without JS.

http://www.flickr.com/photos/124330160/2127121118/

Page 26: Echo HTML5

Canvas is like a whiteboard drawing. No layers.Note: Canvas only works in the browser via JS.

http://www.flickr.com/photos/azuriblue/3350954960/

Page 27: Echo HTML5

Canvas demos – ChromeExperiments.com

Page 28: Echo HTML5

New <form> elements

<select><option>...<textarea></textarea><input type="checkbox" /><input type="file" /><input type="radio" /><input type="text" />... etc.

<input type="date" /><input type="datetime" /><input type="email" /><input type="month" /><input type="number" /><input type="range" /><input type="tel" /><input type="time" /><input type="url" />

HTML4,XHTML(and HTML5)

New inHTML5

Page 29: Echo HTML5

All form elements – in Opera

Page 30: Echo HTML5

http://www.diveintohtml5.org/forms.html

Adaptive HTML5 keyboards on mobile devices

Page 31: Echo HTML5

HTML5“Apps”

Page 32: Echo HTML5

Example – ScrumCards.net

iOS – Home screen app icon.<link rel=”apple-touch-icon” />

iOS – No browser chrome.Status bar color can be set.

Android – Browser chrome always present. Caching only.

Page 33: Echo HTML5

Making an HTML5 “app” is pretty easy

Page 34: Echo HTML5

*.manifest lets you store files offline

Page 36: Echo HTML5

http://www.phonegap.com/

PhoneGap helps HTML5 power “native” apps

Page 37: Echo HTML5

HTML5’s (experimental) JavaScript APIs

Desktop Features– Drag and drop– Live notifications

Browser Database– Web SQL– IndexedDB

Much Much More!– document.querySelector– Geolocation– localStorage– Web workers

Cool! But not(yet) ready for

prime-time.

Page 38: Echo HTML5

<video>How do we makeit work reliably?

Page 39: Echo HTML5

Flash was the mostreliable way to playvideo on the web.

Roughly 99% ofall desktops have Flash player.

iPhone/iPad don’t. They do support HTML5 <video>

http://www.apple.com/hotnews/thoughts-on-flash/

Page 40: Echo HTML5

H.264 = MoneyFiguratively + Literally... It’s the most widely supported format. But licensing costs browser makers $5 million a year.

http://www.readwriteweb.com/archives/will_idealism_be_firefoxs_downfall.php

Page 41: Echo HTML5

Internet Explorer 9 Google Chrome Safari

Firefox Opera

H.264 support in the “Big-5”

YES

NO

Page 42: Echo HTML5

Ogg = “Ugh!”Nobody wants to re-encode countless hours of video so Firefox & Opera can play it.– And have it look sub-par.

http://www.xiph.org/ogg/

Page 43: Echo HTML5

WebM/VP8From: Google, Mozilla, Adobe. Looks great. Is open source. IE9 is on the fence. It doesn’t (yet) work on mobile devices.

http://www.webmproject.org/

Page 44: Echo HTML5

1 file to rule them all...

H.264 via HTML5 with a fallback to Flash or Silverlight (playing the same file) if the browser cannot play H.264 natively via <video>.

http://www.mediaelementjs.com/

Page 45: Echo HTML5

Native <video> UI controls

OPERA

SAFARI

FIREFOX

CHROME

IE9

http://dev.opera.com/articles/view/custom-html5-video-player-with-css3-and-jquery/

Page 46: Echo HTML5

CSS styled video controls – MediaElementJS.com

Page 48: Echo HTML5

CSS3not HTML5but is stillawesome

Page 49: Echo HTML5

.gradient {background: #eee url(gradient.png) repeat-x;

background: -webkit-gradient(linear, left top, left bottom,color-stop(0, #fff),color-stop(1, #eee));

background: -moz-linear-gradient(top center,#fff 0%,#eee 100%);

}

CSS3 gradients

The first declaration works in all browsers. The second is for Safari and Google Chrome, which both use the WebKit rendering engine. The last is for Firefox (Mozilla prefix).

Tip: Crop gradient images from a screenshot of a CSS3 page render. Ensures visual consistency and saves work.

Page 51: Echo HTML5

.drop_shadow {

-webkit-box-shadow: rgba(0, 0, 0, 0.5) 0 2px 5px;

-moz-box-shadow: rgba(0, 0, 0, 0.5) 0 2px 5px;

box-shadow: rgba(0, 0, 0, 0.5) 0 2px 5px;

}

CSS3 box-shadow

The first declaration is for Safari and Chrome. The second is for Firefox. The third is for all browsers, which will eventually support box-shadow without a prefix.

Currently: Opera and IE9 support it.

Page 52: Echo HTML5

.rounded_corners {

-webkit-border-radius: 5px;

-moz-border-radius: 5px;

border-radius: 5px;

}

CSS3 border-radius

The first line is for Safari and Chrome. Second is for Firefox. The third is for all browsers, which will eventually support border-radius without a prefix. Currently: Opera and IE9.

More border-radius code here:gist.github.com/262663

Page 53: Echo HTML5

.text_shadow {text-shadow: rgba(0, 0, 0, 0.5) 0 1px 1px;

}

CSS3 text-shadow

Thankfully, all browsers that support text-shadow do so with the exact same syntax: Chrome, Safari, Firefox, Opera.

– No word from IE9 yet.

Page 54: Echo HTML5

@font-faceTimes + Helvetica

have a posse

Page 55: Echo HTML5

Common fonts on Windows + Mac

TimesGeorgiaArial -or-HelveticaCourier

PalatinoComic SansTrebuchetVerdana... etc.

http://www.ampsoft.net/webdesign-l/WindowsMacFonts.html

Page 56: Echo HTML5

How can we use non-common fonts?

Flat images: It works. But hard to maintain.

sIFR: Pretty. Uses Flash. Fails on iPhone/iPad. Can be affected by ad-blocking extensions.

Cufón: Better. Uses JavaScript + <canvas>. But can be intensive. Best used on headlines.

@font-face: No scripting. Pure CSS. Can be used for any text. Yet tricky to implement.

Page 57: Echo HTML5

Paul Irish’s “Bulletproof @font-face syntax”

http://paulirish.com/2009/bulletproof-font-face-implementation-syntax/

Page 58: Echo HTML5

@font-face

@font-face {font-family: 'GentiumRegular';src: url('genr102_0-webfont.eot');src: local('☺'), url('genr102_0-webfont.woff') format('woff'), url('genr102_0-webfont.ttf') format('truetype'),url('genr102_0-webfont.svg#webfontX7s0ZYjS') format('svg');

}

p {font-family: 'GentiumRegular';

}

File generatorfontsquirrel.com/fontface/generator

Google fonts API (super easy)code.google.com/webfonts

Page 59: Echo HTML5

Bible Web AppHTML5 + CSS3 + @font-face

biblewebapp.com

Page 60: Echo HTML5
Page 61: Echo HTML5

jQuery DesktopHTML5 + CSS3 + JavaScript

desktop.sonspring.com

Page 62: Echo HTML5
Page 63: Echo HTML5

“Slablet”HTML5 + CSS3 + JavaScript

host.sonspring.com/slablet

Page 64: Echo HTML5
Page 65: Echo HTML5

Social “Graph”Cool! But who owns your data?

Page 66: Echo HTML5

Lots of standards and protocols that aren't really being used right now.

Facebook “Like”: not open, social, or graphic. But fun and gives advertisers data.

Page 67: Echo HTML5

http://www.openlike.org/

Helpful tool for adding “Like” buttons

Page 68: Echo HTML5

Open social data – A cautionary tale...

http://www.youropenbook.org/