12-15-2011 HTML5 Design

226
OREILLYMEDIA 2011 HTML5 D E S I G N Christopher Schmitt | http ://tw itter .com/ @teleject

Transcript of 12-15-2011 HTML5 Design

Page 1: 12-15-2011 HTML5 Design

OREILLYMEDIA 2011

HTML5D E S I G N

Christopher Schmitt | http://twitter.com/@teleject

Page 2: 12-15-2011 HTML5 Design

2

Things are good Between Things are good Between US, XHTML, right?US, XHTML, right? I MEAN. WE GET ALONG WELL. AND WE BOTH LIKE STUFF.3

Page 3: 12-15-2011 HTML5 Design

3http://dev.opera.com/articles/view/mama-markup-validation-report/3

“imagine you made a browser that only rendered sites authored in valid HTML or XHTML. How much of the web would your users be able to see? 1%? 0.1%?

Less?”Mark PILGRIM

Page 4: 12-15-2011 HTML5 Design

44

Page 5: 12-15-2011 HTML5 Design

5

“The attempt to get the world to switch to XML, including quotes around attribute values and slashes in empty tags and namespaces all

at once didn’t work.”

Sir Tim Berners-Lee5

Page 6: 12-15-2011 HTML5 Design

6http://www.flickr.com/photos/teleject/432030263/6

Page 7: 12-15-2011 HTML5 Design
Page 8: 12-15-2011 HTML5 Design

9191http://www.w3.org/TR/html4/index/elements.html

Page 9: 12-15-2011 HTML5 Design

99

Page 10: 12-15-2011 HTML5 Design

1010

http://microformats.org/

Page 11: 12-15-2011 HTML5 Design

1111

Page 12: 12-15-2011 HTML5 Design

12

Page 13: 12-15-2011 HTML5 Design

1313

Page 14: 12-15-2011 HTML5 Design

14

BLUEPRINTS vs REALITY

14

http://www.amazon.com/gp/product/0140139966

Page 15: 12-15-2011 HTML5 Design

15

“Take care of the luxuries and

the necessities will take care of themselves.”

FRANK LLOYD WRIGHT

15

Page 16: 12-15-2011 HTML5 Design

16

Agenda ITEMS

• What’s different from XHTML to HTML5

• Building with HTML5 (You are here.)

• Basic Syntax, Progressive Markup, Accessibility, Geolocation, Audio/Video, Web Forms

• Prizes! http://oreil.ly/tU1iH6

Page 17: 12-15-2011 HTML5 Design

17

BUILDING WITH HTML5

Page 18: 12-15-2011 HTML5 Design

18

DOCTYPE

Page 19: 12-15-2011 HTML5 Design

19

HTML 4.01 Transitional DTD: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/1999/REC-html401-19991224/loose.dtd">

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

Page 20: 12-15-2011 HTML5 Design

20

<!DOCTYPE html><html lang="en"> <head> <meta charset="utf-8"> <title>AUSTIN, TX BBQ RESTAURANTS</title> </head> <body> <h1>....</h1> <p>...</p> </body></html>

Page 21: 12-15-2011 HTML5 Design

21

EXERCISE• Go to HTML validator at

http://validator.w3.org/#validate_by_input

• Then type the following HTML (below) and hit validate:

<!DOCTYPE html> <title>Small HTML5</title> <p>Hello world</p>

Page 22: 12-15-2011 HTML5 Design

2222

Page 23: 12-15-2011 HTML5 Design

2323

Page 24: 12-15-2011 HTML5 Design

24

CHARACTER SET

Page 25: 12-15-2011 HTML5 Design

25

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

Page 26: 12-15-2011 HTML5 Design

26

<!DOCTYPE html><html lang="en"> <head> <meta charset="utf-8"> <title>AUSTIN, TX BBQ RESTAURANTS</title> </head> <body> <h1>....</h1> <p>...</p> </body></html>http://shiflett.org/blog/2005/dec/googles-xss-vulnerability

Page 27: 12-15-2011 HTML5 Design

27

SPECIFY YOUR LANGUAGE

Page 28: 12-15-2011 HTML5 Design

28

<!DOCTYPE html><html lang="en"> <head> <meta charset="utf-8"> <title>AUSTIN, TX BBQ RESTAURANTS</title> </head> <body> <h1>....</h1> <p>...</p> </body></html>

Page 29: 12-15-2011 HTML5 Design

29

INCLUDING <SCRIPT> & <STYLE>

Page 30: 12-15-2011 HTML5 Design

30

<!DOCTYPE html><html lang="en"> <head> <meta charset="utf-8"> <link rel="stylesheet" href="styles.css" /> <script src="scripts.js"></script> <title>AUSTIN, TX BBQ RESTAURANTS</title> </head> <body> <h1>....</h1> <p>...</p> </body></html>

Page 31: 12-15-2011 HTML5 Design

31

SYNTAX

Page 32: 12-15-2011 HTML5 Design

32

<img src=“file.png” />

Page 33: 12-15-2011 HTML5 Design

33

<IMG SRC=file.png />

Page 34: 12-15-2011 HTML5 Design

34

<iMg SrC=file.png />

Page 35: 12-15-2011 HTML5 Design

35

<IMG SRC=file.png />

Page 36: 12-15-2011 HTML5 Design

36

<video controls=controls>

Page 37: 12-15-2011 HTML5 Design

37

EVERYTHING THAT WAS BAD IN 1999IS GOOD AGAIN

Page 38: 12-15-2011 HTML5 Design

38

RElEARNING SYNTAX• Attribute quotes “not really” required

• UPPERCASE and lowercase HTML elements allowed

• So is CaMeLcAse typing.

• No more need to do self-closing tags like <IMG /> or <BR />

• Also, no more minimalization. So, this is okay: <dl compact>

• Basically, everything that was bad from HTML4 in XHTML5 is good again.

• Full circle, baby! One more time.

Page 39: 12-15-2011 HTML5 Design

39

BRINGING BACK <b>and OTHER TAGS

Page 40: 12-15-2011 HTML5 Design

40

<p>My name is <em>Jane</em>, not

John.</p>

Page 41: 12-15-2011 HTML5 Design

41

<p>Sally thought to herself, <i>when will IE6

die?</i></p>

Page 42: 12-15-2011 HTML5 Design

42

<p><strong>Registration is required</strong> for

this event.</p>

Page 43: 12-15-2011 HTML5 Design

43

<p><b>Once upon a time,</b> there was a

man who lost his mind.</p>

Page 44: 12-15-2011 HTML5 Design

44

<p><small>The owner of this blog is not responsible for mind blowage. Please

consume at your own risk.</small></p>

<p><small>Copyright &copy; 2011 Awesomest

Blog. All rights reserved.</small></p>

Page 45: 12-15-2011 HTML5 Design

45

<abbr title="Accessible Rich Internet

Applications">ARIA</abbr>

No more <acronym>

Page 46: 12-15-2011 HTML5 Design

46

THE COOLEST THING EVER ABOUT HTML5.

(TO ME.)

Page 47: 12-15-2011 HTML5 Design

47

<h1> <a href="http://example.com"> HTML5, for Fun &amp; Profit </a></h1>

<a href="http://example.com"> <img src="logo.png" alt="HTML5 for Fun and Profit" /></a>

Page 48: 12-15-2011 HTML5 Design

48

<a href="http://example.com"> <h1>HTML5, for Fun &amp; Profit</h1> <img src="logo.png" alt="HTML5 for Fun and Profit" /></a>

Page 49: 12-15-2011 HTML5 Design

49

Figures & CAPTIONS

Page 50: 12-15-2011 HTML5 Design

50

<figure><img src="chart.png" alt="Chart of

increasing awesomeness" /><figcaption>The increasing amount

of awesome that this blogdemonstrates.</figcaption></figure>

Page 51: 12-15-2011 HTML5 Design

51

FIGURE

• Not restricted to containing IMGs

• Tables

• Audio

• Video

• Charts

• Code snippets

Page 52: 12-15-2011 HTML5 Design

52

COLLAPSABLE CONTENT

Page 53: 12-15-2011 HTML5 Design

53

Page 54: 12-15-2011 HTML5 Design

54

<details> <summary>Upcoming Topics</summary> <p>For the new year, we have a great line up of articles!</p> <ul> <li>Understanding the Outline Algorithm</li> <li>When to Use

<code>hgroup</code></li> <li>Machine Semantics with Microdata</li></ul></details>

Only works in Chrome; all others - https://gist.github.com/370590

Page 55: 12-15-2011 HTML5 Design

55

NUMBERINGLISTS

Page 56: 12-15-2011 HTML5 Design

56

Page 57: 12-15-2011 HTML5 Design

57

<ol start="3"> <li>Apples</li> <li>Oranges</li> <li>Bananas</li></ol>

Page 58: 12-15-2011 HTML5 Design

58

Page 59: 12-15-2011 HTML5 Design

59

<p>The results are in for your favorite fruit, and we have a tie for first place!</p><ol><li value="1">Bananas</li><li value="1">Oranges</li><li value="2">Apples</li></ol>

Page 60: 12-15-2011 HTML5 Design

60

EDITABLE ELEMENTS

Page 61: 12-15-2011 HTML5 Design

61

Page 62: 12-15-2011 HTML5 Design

62

<div contenteditable><p>Quick Fox Jumped Over the Lazy Dog</p></div>

Page 63: 12-15-2011 HTML5 Design

63

http://markdotto.com/playground/3d-text/

Page 64: 12-15-2011 HTML5 Design

64

DRAG n DROP

Page 65: 12-15-2011 HTML5 Design

65

<h2 draggable>Block-Level Links</h2>

http://html5doctor.com/native-drag-and-drop/

Page 66: 12-15-2011 HTML5 Design

66

HTML5, Microformats & METADATA

Page 67: 12-15-2011 HTML5 Design

67

“Designed for humans first and machines second,

microformats are a set of simple, open data formats built upon

existing and widely adopted standards.”

Page 68: 12-15-2011 HTML5 Design

68

“HTML design patterns for common chunks of content that web builders need

to markup anyway.”

“Oh, and Google understands them, too.”

Page 69: 12-15-2011 HTML5 Design

69

Page 70: 12-15-2011 HTML5 Design

70

Replacing ABBR

• <ABBR> element is used by screenreaders to expand abbreviations like “lbs” or “NCAAP”

• However unintended consequences occurred trying to workaround browser bugs for other HTML elements

• What happens when a screenreaders text like this:

• “Let’s go to <abbr class="geo" title="30.300474;-97.747247">Austin, TX</abbr>”

http://www.brucelawson.co.uk/2009/microformats-accessibility-html-5-again/

Page 71: 12-15-2011 HTML5 Design

71

<div class="vevent"> <a class="url" href="http://www.web2con.com/">http://www.web2con.com</a> <span class="summary">Web 2.0 Conference</span>: <abbr class="dtstart" title="2007-10-05">October 5</abbr>- <abbr class="dtend" title="2007-10-20">20</abbr>,at the <span class="location">Argent Hotel, San Francisco, CA</span></div>

Page 72: 12-15-2011 HTML5 Design

72

<div class="vevent"> <a class="url" href="http://www.web2con.com/">http://www.web2con.com</a> <span class="summary">Web 2.0 Conference</span>: <time class="dtstart" datetime="2007-10-05">October 5</time>- <time class="dtend" datetime="2007-10-19">19</time>,at the <span class="location">Argent Hotel, San Francisco, CA</span></div>

http://www.brucelawson.co.uk/2009/microformats-accessibility-html-5-again/

Page 73: 12-15-2011 HTML5 Design

73

POSTSCRIPT

• <ABBR> issue has ben resolved with new pattern (dropping <ABBR> altogether):http://microformats.org/wiki/value-class-pattern

• <p>Let’s go to <span class="geo">51° 30' 48.45", -0° 8' 53.23" (<span class="value">51.513458;-0.14812</span>)</span> </p>

Page 74: 12-15-2011 HTML5 Design

74

DATA-ATTRIBUTE

• You can set data-attribute to any element you want.

• Set meta information that can be utilized by JavaScript or CSS later on.

<img src=“john-smith.jpg” data-imgtype=“mugshot” alt=“John Smith’s mugshot”>

Page 75: 12-15-2011 HTML5 Design

75

ATTR SELECTOR

img[data-imgtype=“mugshot”] {/* CSS rules go here */}

Page 76: 12-15-2011 HTML5 Design

76

Page Structure

Page 77: 12-15-2011 HTML5 Design

77

DIV ID=“header”

DIV ID=“section”

DIV ID=“article”DIV ID=“sidecolumn”

DIV ID=“footer”

DIV ID=“nav”

Page 78: 12-15-2011 HTML5 Design

78

<HEADER>

<SECTION>

<ARTICLE><ASIDE>

<FOOTER>

<NAV>

Page 79: 12-15-2011 HTML5 Design

79

ArtiCLE vs ASIDE VS SECTION

• Marc Grabsanki says:

• Article is unique content to that document

• Section is a thematic grouping of content, typically with a heading - pretty generic

• Aside is content that is tangentially related, like a sidebardiv has no meaning whatsoever, so there is nothing semantic about divs

Page 80: 12-15-2011 HTML5 Design

80

ArtiCLE vs ASIDE VS SECTION

• Bruce Lawson says:

• Aside is for something tangentially related to its parent element. Or, if a sibling to the main content, it can be used to make sidebars of navigation, recent comments, colophons, author bios etc.

• Article is a discrete piece of content that could be syndicated - a blog post, a news item, a comment, a widget

• Section can also contain articles. for example, you could have a page with a <section> full of entertainment articles, and a section of political news etc.

Page 81: 12-15-2011 HTML5 Design

81

ArtiCLE vs ASIDE VS SECTION

• Molly Holzschlag, Opera standards evangelist, says:

• <section> clarifies <div>

• <article> 'replaces' <div id="content">

• <aside> 'replaces' <div id="sidebar">

• Chris Mills, Opera browser employee, plays it safe: http://boblet.tumblr.com/post/130610820/html5-structure1

Page 82: 12-15-2011 HTML5 Design

82

WHAT ABOUT THE DIVS?

• Marc Grabanski, jQuery and HTML5 guy:

• “div has no meaning whatsoever, so there is nothing semantic about divs”

• Bruce Lawson, Opera browser employee:

• “Like all semantic questions, it depends on the context. If your only reason for wanting an element is to group stuff for styling, it's a div.”

Page 83: 12-15-2011 HTML5 Design

83

<body> <header> <h1>Heading </h1> </header> <nav> <h3>Site Navigation</h3> <ul>...</ul> </nav> <section> <article> <h3>Weblog Entry</h3> </article> </section> <aside> <p>You are reading "Chocolate Rain", an entry posted on <time datetime="2009-03-05">5 March, 2009</time>, to the <a href="#">Misty collection</a>. See other posts in <a href="#">this collection</a>.</p> </aside> <footer> <p>...</p> </footer></body>

Page 84: 12-15-2011 HTML5 Design

8484

Page 85: 12-15-2011 HTML5 Design

8585

Page 86: 12-15-2011 HTML5 Design

86

<script type="text/javascript">document.createElement('header');document.createElement('nav');document.createElement('section');document.createElement('article');document.createElement('aside');document.createElement('footer');</script>

http://ejohn.org/blog/html5-shiv/

Page 87: 12-15-2011 HTML5 Design

8787

Page 88: 12-15-2011 HTML5 Design

88

ProgressiveLYENhanced HTML5(infused with SHIM)

Page 89: 12-15-2011 HTML5 Design

8989

Page 91: 12-15-2011 HTML5 Design

91

<script src="-/js/modernizr.min.js" type="text/javascript" ></script>

Page 92: 12-15-2011 HTML5 Design

92

<html lang="en" class=" canvas canvastext geolocation rgba hsla multiplebgs borderimage borderradius boxshadow opacity cssanimations csscolumns cssgradients cssreflections csstransforms csstransforms3d csstransitions video audio localstorage sessionstorage webworkers applicationcache fontface">

Page 93: 12-15-2011 HTML5 Design

93

.audio #error { display: none;}.no-audio #error-box { background-color: #ffffcc; padding: 1px 10px; color: #000; border: 5px solid #ffff66;}

CSS Feature Detection

Page 94: 12-15-2011 HTML5 Design

94

<script>if (Modernizr.audio) { function playPause() { var myAudio = document.getElementsByTagName('audio')[0];if(myAudio.paused) myAudio.play(); else myAudio.pause();}}</script>

JS Feature Detection

Page 95: 12-15-2011 HTML5 Design

95

Modernizr.load({ test: Modernizr.geolocation, yep : 'geo.js', nope: 'geo-polyfill.js'});

JS Feature Detection

Page 96: 12-15-2011 HTML5 Design

96

Page 97: 12-15-2011 HTML5 Design

97

Pick and Choose Features to Detect

Page 98: 12-15-2011 HTML5 Design

98

AUDIO/VIDEO

Page 99: 12-15-2011 HTML5 Design

99

HTML5 AUdio

Page 100: 12-15-2011 HTML5 Design

100

<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><title>Basic HTML5 Web Document Structure</title>

</head><body>

<h1>Video Example</h1><audio src="html5test.ogg" autoplay controls>

<a href="html5test.ogg">Download audio</a></audio>

</body></html>

Page 101: 12-15-2011 HTML5 Design

101

HTML5 audio

• AUDIO element attributes are SRC, AUTOBUFFER, AUTOPLAY, LOOP, CONTROLS

• If you don’t have CONTROL, player becomes transparent

Page 102: 12-15-2011 HTML5 Design

102

HTML5 Audio SUPPORT

FF3.5+ S4+ Ch3+ Op10.5+ IE9+

Ogg Vorbis Y Y Y

MP3 Y Y Y

WAV Y Y Y

Page 103: 12-15-2011 HTML5 Design

103

SUPPORTING AUDIO

<audio controls autobuffer> <source src="html5audio.mp3" /> <source src="html5audio.ogg" /> <!-- include Adobe Flash player EMBED and OBJECT code here --> </audio>

Use Flash for older versions of IE

Page 104: 12-15-2011 HTML5 Design

104

Supporting AUDIO

• If you do insert audio, setting the file to autoplay is not recommended, as it interferes with the experience for web surfers using screen readers.

• Don’t use WAV file type.

• Better to ship a compact disc to the user instead.

Page 105: 12-15-2011 HTML5 Design

105

HTML5 Video

Page 106: 12-15-2011 HTML5 Design

106

<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><title>Basic HTML5 Web Document Structure</title>

</head><body>

<h1>Video Example</h1><object width="425" height="344"><param name="movie" value="http://www.youtube.com/v/4GuKSqAg5xI&hl=en&fs=1"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/4GuKSqAg5xI&hl=en&fs=1" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="425" height="344"></embed></object>

</body></html>

Page 107: 12-15-2011 HTML5 Design

107

<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><title>Basic HTML5 Web Document Structure</title>

</head><body>

<h1>Video Example</h1><video src="html5test.ogg"

width="320" height="240" controls poster="html5testvideoposter.jpg">

<a href="html5testvideo.ogg">Download movie</a></video>

</body></html>

Page 108: 12-15-2011 HTML5 Design

108

HTML5 Video

• WIDTH and HEIGHT should be required, IMO, but movie plays anyway based on the values in the video file itself.

• Video formats may have their own posterframe. The browser should use that by default unless overridden by valid POSTER attribute value.

• Text can be included within VIDEO element to allow user to download video if their browser doesn’t support.

• If you want to give users control, use CONTROL attribute.

Page 109: 12-15-2011 HTML5 Design

109

HTML5 Video

• Video can start automatically if using the AUTOPLAY=”1” attribute and value.

• Spec provides for LOOP, AUTOBUFFER which also take a value of O or 1.

• Codecs support...

Page 110: 12-15-2011 HTML5 Design

110

HTML5 Video“It would be helpful for interoperability if all browsers could support the same codecs. However, there are no known codecs that satisfy all the current players: we need a codec that is known to not require per-unit or per-distributor licensing, that is compatible with the open source development model, that is of sufficient quality as to be usable, and that is not an additional submarine patent risk for large companies. This is an ongoing issue and this section will be updated once more information is available.”- http://www.whatwg.org/specs/web-apps/current-work/#video-and-

audio-codecs-for-video-elements

Page 111: 12-15-2011 HTML5 Design

111

CodeCS• Ogg (or “Vorbis”)

• No need to worry about patents

• H.264

• Created by the MPEG group

• If you have blu-ray disc player, you are using it

• WebM

• A wrapper for the VP8 video and Ogg audio streams

Page 112: 12-15-2011 HTML5 Design

112

VIDEO CODEC SUPPORT

FF3.6+ S Ch5+ Op10.6+ IE9+

Ogg Y Y Y

H.264 Y Y* Y

WebM (W4.02+) (Ch6+) Y

Page 113: 12-15-2011 HTML5 Design

113

LESSONS LEARNED• To get most <video> support, you need 2 video files: H.264 and .OGG.

• iOS Devices can handle MP4 (H.264)

• Safari, IE, Flash can deliver MP4 (H.264)

• Firefox, Opera can deliver .OGG

• Then hit them with FLV video, which supports H.264

http://camendesign.com/code/video_for_everybody

Page 114: 12-15-2011 HTML5 Design

114

http://firefogg.org/

114

Page 115: 12-15-2011 HTML5 Design

115

http://www.videolan.org/vlc/

115

Page 116: 12-15-2011 HTML5 Design

116

http://handbrake.fr/

116

Page 117: 12-15-2011 HTML5 Design

117

LESSONS LEARNED

• Use VLC or Firefogg to encode common movie files types to OGG

• H.264 encoding? Use Handbrake

• If you are hot to trot for HTML5 Video, like, right now, check out Mark Pilgrim’s tutorial: http://diveintohtml5.org/video.html

• Good primer: http://dev.opera.com/articles/view/introduction-html5-video/

Page 118: 12-15-2011 HTML5 Design

118118

Page 119: 12-15-2011 HTML5 Design

119119

Page 120: 12-15-2011 HTML5 Design

120

<script> function playPause() { var myVideo = document.getElementsByTagName('video')[0]; if (myVideo.paused)

myVideo.play(); else myVideo.pause(); }</script>

Page 121: 12-15-2011 HTML5 Design

121

<input type=button onclick="playPause()" value="Play/Pause" tabindex="0" />

Page 122: 12-15-2011 HTML5 Design

122

HTML5 VIDEO & CAPTIONS

Page 123: 12-15-2011 HTML5 Design

123

•For students with LD and struggling or beginning readers, the use of captions or subtitles can lead to increases in:reading speed,word knowledge,decoding,vocabulary acquisition,word recognition,reading comprehension, andoral reading rates.

123

Page 124: 12-15-2011 HTML5 Design

124

[Captioning] has been shown to improve reading skills among adults who are non-readers.

http://www.ldonline.org/article/35793124

Page 125: 12-15-2011 HTML5 Design

125125

Page 126: 12-15-2011 HTML5 Design

126

Quick & DirtyCAptioning

Page 127: 12-15-2011 HTML5 Design

127

http://github.com/johnmcc/jCaps127

Page 128: 12-15-2011 HTML5 Design

128128

Page 129: 12-15-2011 HTML5 Design

129

Page 130: 12-15-2011 HTML5 Design

130

SRT FILES• SRT files are text files used in video playback; therefore, they do not contain any video data.

• Text file containing subtitles used by various video playback programs; supported by DivX, DVD, and other video formats;

• Includes the time each subtitle should be displayed followed by the text of the subtitles.

• Subtitle files are often named according to the language of the subtitles, i.e. "moviename-eng.srt" for English and "moviename-ger.srt" for German subtitles.

Page 131: 12-15-2011 HTML5 Design

131

TRANSCRIPT-EN.SRT100:00:00,000 --> 00:00:6,000Allow me to introduce myself My name is Tay It's T-A-Y, T-A-Y to the Z

200:00:06,000 --> 00:00:9,000This is the web and it's gonna murder your TV It was Chocolate Rain

300:00:09,500 --> 00:00:11,500Wrote a song about that history Chocolate Rain

400:00:12,000 --> 00:00:15,000Now I'm paid a hefty hefty fee Chocolate Rain

131

Page 132: 12-15-2011 HTML5 Design

132

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.1/jquery.js"></script><script src="jquery.jcap.js"></script>

Page 133: 12-15-2011 HTML5 Design

133

 <video id="myVid" width="400" src="cherry-chocolate-rain.ogv" autobuffer controls>   <track src="transcript-en.srt" type="text/srt" language="en" role="textaudesc"></track>  <track src="transcript-gr.srt" type="text/srt" language="gr" role="textaudesc"></track>  <p>Alternative text...</p> </video>

Page 134: 12-15-2011 HTML5 Design

134

 <video id="myVid" width="400" src="cherry-chocolate-rain.ogv" autobuffer controls>   <track src="transcript-en.srt" type="text/srt" language="en" role="textaudesc"></track>  <track src="transcript-gr.srt" type="text/srt" language="gr" role="textaudesc"></track>  <p>Alternative text goes here.</p> </video>

Page 135: 12-15-2011 HTML5 Design

135

http://mediaelementjs.com/

Page 136: 12-15-2011 HTML5 Design

136

http://popcornjs.org/

Page 137: 12-15-2011 HTML5 Design

137

HTML5 GEOLOCATION

Page 138: 12-15-2011 HTML5 Design

138

OH, PATHOS!

http://youtu.be/_naLuRykun8

Page 139: 12-15-2011 HTML5 Design

139

Page 140: 12-15-2011 HTML5 Design

140

Page 141: 12-15-2011 HTML5 Design

141

Page 142: 12-15-2011 HTML5 Design

142

Page 143: 12-15-2011 HTML5 Design

143

Page 144: 12-15-2011 HTML5 Design

144

Modernizr.load({ test: Modernizr.geolocation, yep : 'geo.js', nope: 'geo-polyfill.js'});

if (navigator.geolocation) {

navigator.geolocation.getCurrentPosition(show_coordinates);

function show_coordinates(position){ alert('Your latitude is ' + position.coords.latitude +

' ' + 'and your longitude is ' + position.coords.longitude

+ '.'); }

}

...or use Modernizr!

Page 145: 12-15-2011 HTML5 Design

145

http://ion.christopherschmitt.com/geolocation/

Page 146: 12-15-2011 HTML5 Design

146

That’s Great, But

• I don’t read longitude and latitude.

• More importantly, my clients or site visitors don’t comprehend longitude and latitude.

• And I don’t love the code!

Page 147: 12-15-2011 HTML5 Design

147

http://2010.incontrolconference.com/eats/

Page 148: 12-15-2011 HTML5 Design

148

http://atxwebshow.com/coffeeshops/

Page 149: 12-15-2011 HTML5 Design

149

http://atxwebshow.com/coffeeshops/

Page 150: 12-15-2011 HTML5 Design

150

Step #1

Muck-N-Dave's Texas BBQ 1603 South CongressAustin, TX 78704 USA 512-590-3387Old School BBQ and Grill2326 E Cesar Chavez StAustin, TX, 78702 USA 512-974-6830The Shed BBQ Rolling Joint1816 E 6th Street.Austin, TX, 78702 USA 504-432-4718Franklin Barbecue3421 N. I-35Austin, TX, 78722 USA 512-653-1187

Old School BBQ and Grill2907 E MLK Jr Blvd.Austin, TX, 78702 USA 512-974-6830Snow's BBQ516 Main StreetLexington, TX 78947 USA 979-773-4640

Page 151: 12-15-2011 HTML5 Design

151

Step #2

• Convert addresses to hCard microformats

151

http://microformats.org/code/hcard/creator

Page 152: 12-15-2011 HTML5 Design

152

<div class="vcard"><a class="url fn n" href="http://www.theqcard.com/"> <span class="given-name">Jane</span><span class="additional-name"></span><span class="family-name">Smith</span></a><div class="org">Old School BBQ and Grill</div>

<div class="adr"><div class="street-address">2907 E MLK Jr Blvd.</div><span class="locality">Austin</span>, <span class="region">TX</span>, <span class="postal-code">78702</span><span class="country-name">USA</span>

</div><div class="tel">512-974-6830</div><div class="note distance"></div>

</div>http://microformats.org/code/hcard/creator

Page 153: 12-15-2011 HTML5 Design

153

Step #3

hCard

hCard

hCard

hCard

Page 154: 12-15-2011 HTML5 Design

154

Step #3

hCard

hCard

hCard

hCard

<ol><li>

<li>

<li>

<li>

</li>

</li>

</li>

</li>

Page 155: 12-15-2011 HTML5 Design

155

<div id="locations"><ol>

<li><!-- Microformats address 1 --></li><li><!-- Microformats address 2 --></li><li><!-- Microformats address 3 --></li><li><!-- Microformats address 4 --></li>...

</ol></div>

STEP #4

Page 156: 12-15-2011 HTML5 Design

156

http://github.com/teleject/HTML5-GeoLocation-jQuery-Plugin

STEP #5

Page 157: 12-15-2011 HTML5 Design

157

<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js"></script><script type="text/javascript" src="js/jquery-location.js"></script>

STEP #6

Page 158: 12-15-2011 HTML5 Design

158

http://code.google.com/apis/maps/signup.html

STEP #7

Page 159: 12-15-2011 HTML5 Design

159

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script><script type="text/javascript" src="js/jquery-location.1.0.0.js"></script> <script type="text/javascript">

$(document).ready(function(){

$('#locations2').location({ 'apiKey' : 'YOUR_API_KEY_HERE'});

});</script>

STEP #8

Page 160: 12-15-2011 HTML5 Design

160

STEP #9 PROFIT!

Page 161: 12-15-2011 HTML5 Design

161

One MORE THING...

Page 162: 12-15-2011 HTML5 Design

162

<div class="vcard"><a class="url fn n" href="http://www.theqcard.com/"> <span class="given-name">Jane</span><span class="additional-name"></span><span class="family-name">Smith</span></a><div class="org">Old School BBQ and Grill</div>

<div class="adr" data-longitude="-97.723410" data-latitude="30.262098">

<div class="street-address">2907 E MLK Jr Blvd.</div><span class="locality">Austin</span>, <span class="region">TX</span>, <span class="postal-code">78702</span><span class="country-name">USA</span>

</div><div class="tel">512-974-6830</div><div class="note distance"></div>

</div>http://geocoder.us/

Page 163: 12-15-2011 HTML5 Design

163

$('#locations').location( {

apiKey: 'YOUR_API_KEY_HERE', geodata: '#geodata', // site visitor’s

locationnotification: '.notification', // progress

indicatorrecheck: '.recheck',distance: '.distance', //where the distance

appearsgeoAdr: '.geoAdr', // longitude and latitudelistElement: 'li' // different listing element?

} );

Page 164: 12-15-2011 HTML5 Design

164

WEB FORMS

Page 165: 12-15-2011 HTML5 Design

165

Page 166: 12-15-2011 HTML5 Design

166

<form> <p><label>Search <input type="search" name="query"></label></p> <p><button type="submit">Submit</button></p></form>

Page 167: 12-15-2011 HTML5 Design

167

Page 168: 12-15-2011 HTML5 Design

168

<form><fieldset><legend>Contact Information</legend> <p><label>E-mail address <input type="email" name="email"> </label></p> <p><label>Web site <input type="url" name="website"> </label></p> <p><label>Telephone number <input type="tel" name="phone"> </label></p></fieldset> <p><button type="submit">Submit</button></p></form>

Page 169: 12-15-2011 HTML5 Design

169

Page 170: 12-15-2011 HTML5 Design

170

<form><p><label>Appointment Date and Time <input type="datetime"name="dateAndTime"></label></p></form>

Page 171: 12-15-2011 HTML5 Design

171

Page 172: 12-15-2011 HTML5 Design

172

<form><fieldset><legend>Appointment Request</legend><p><label>Date <input type="date" name="date"></label></p><p><label>Time <input type="time" name="time"></label></p></fieldset><p><button type="submit">Submit</button></p></form>

Support in Chrome 10+, Safari 4+, Opera 9+, iOS, Android

Page 173: 12-15-2011 HTML5 Design

173

Page 174: 12-15-2011 HTML5 Design

174

<form><p><label>Quantity <input type="number" name="quantity"></label></p><p><button type="submit">Submit</button></p></form>

Support in Chrome 10+, Safari 4+, Opera 9+, iOS, Android

Page 175: 12-15-2011 HTML5 Design

175

Page 176: 12-15-2011 HTML5 Design

176

<form><p><label>Quantity (must order in pairs of 2) <input type="number"name="quantity" min="2" max="20" step="2"></label></p><p><button type="submit">Submit</button></p></form>

Page 177: 12-15-2011 HTML5 Design

177

Page 178: 12-15-2011 HTML5 Design

178

<form><p><label>Volume <input type="range" name="volume" min="0" max="10" step=".5" value="5"></label></p></form>

Page 179: 12-15-2011 HTML5 Design

179

Page 180: 12-15-2011 HTML5 Design

180

<form><p><label>Background color <input type="color" name="bg"></label></p><p><label>Foreground color <input type="color" name="fg"></label></p><p><button type="submit">Submit</button></p></form>

Page 181: 12-15-2011 HTML5 Design

181

Page 182: 12-15-2011 HTML5 Design

182

<form><p><label>Donation amount <input type="text" name="donation"list="donations"></label></p><datalist id="donations"><option value="10.00">10.00</option><option value="25.00">25.00</option><option value="50.00">50.00</option></datalist><p><button type="submit">Submit</button></p></form> Support in Firefox 4+, Opera 10+

Page 183: 12-15-2011 HTML5 Design

183

Page 184: 12-15-2011 HTML5 Design

184

<form><p><label for="donation">Donation amount</label><datalist id="donations"><select name="donation"><option></option><option value="10.00">10.00</option><option value="25.00">25.00</option><option value="50.00">50.00</option><option>Other</option></select>If other, please specify:</datalist><input type="text" id="donation" name="donation" list="donations"></p><p><button type="submit">Submit</button></p></form> 184

http://adactio.com/journal/4272/

Page 185: 12-15-2011 HTML5 Design

185

Page 186: 12-15-2011 HTML5 Design

186

<form><fieldset><legend>Login</legend><p><label>Username <input type="text" name="username" required></label></p><p><label>Password <input type="password" name="pwd" required></label></p></fieldset><p><button type="submit">Submit</button></p></form>

186

IE 10+, FF 4+, Chrome 10+, Safari 5+, Opera 10+, iOS, Andriod

Page 187: 12-15-2011 HTML5 Design

187

Page 188: 12-15-2011 HTML5 Design

188

<p><label>E-mail address <input type="email" name="email"placeholder="[email protected]"></label></p><p><label>Web site <input type="url" name="website" placeholder="http://www.domain.com/"></label></p><p><label>Telephone number <input type="tel" name="phone"placeholder="123-123-1234"></label></p>

Page 189: 12-15-2011 HTML5 Design

189

<form><p><label>Search <input type="search" name="query" autofocus></label></p><p><button type="submit">Submit</button></p></form>

Page 190: 12-15-2011 HTML5 Design

190

<form><fieldset><legend>Login</legend><p><label>Username <input type="text" name="username"></label></p><p><label>Password <input type="password" name="pwd"autocomplete="off"></label></p></fieldset><p><button type="submit">Submit</button></p></form>

Page 191: 12-15-2011 HTML5 Design

191

Page 192: 12-15-2011 HTML5 Design

192

<form><p><label>Telephone number <input type="tel" name="phone"pattern="[2-9][0-9]{2}-[0-9]{3}-[0-9]{4}"title="North American format: XXX-XXX-XXXX"></label></p><p><button type="submit">Submit</button></p></form>

Page 193: 12-15-2011 HTML5 Design

193

HTML5 Canvas

Page 194: 12-15-2011 HTML5 Design

194

<canvas id="myCanvas" width="300" height="150"> Fallback content, in case the browser does not support Canvas.</canvas>

Page 195: 12-15-2011 HTML5 Design

195

<script type="text/javascript"><!--window.addEventListener('load', function () { // Get the canvas element. var elem = document.getElementById('myCanvas'); if (!elem || !elem.getContext) { return; }

// Get the canvas 2d context. var context = elem.getContext('2d'); if (!context) { return; }

// Now you are done! Let's draw a blue rectangle. context.fillStyle = '#00f'; context.fillRect(0, 0, 150, 100);}, false);// --></script>

Page 196: 12-15-2011 HTML5 Design

196196

Page 197: 12-15-2011 HTML5 Design

197

// Get the canvas element. var elem = document.getElementById('myCanvas'); if (!elem || !elem.getContext) { return; }

// Get the canvas 2d context. var context = elem.getContext('2d'); if (!context) { return; }

context.fillStyle = '#00f'; context.strokeStyle = '#f00'; context.lineWidth = 4;

// Draw a right triangle. context.beginPath(); context.moveTo(10, 10); context.lineTo(100, 10); context.lineTo(10, 100); context.lineTo(10, 10); context.fill(); context.stroke(); context.closePath();}, false);

Page 198: 12-15-2011 HTML5 Design

198198

Page 199: 12-15-2011 HTML5 Design

199

// Get the canvas element. var elem = document.getElementById('myCanvas'); if (!elem || !elem.getContext) { return; }

// Get the canvas 2d context. var context = elem.getContext('2d'); if (!context) { return; }

context.fillStyle = '#00f'; context.strokeStyle = '#f00'; context.lineWidth = 4;

// Draw a right triangle. context.beginPath(); context.moveTo(10, 10); context.lineTo(100, 10); context.lineTo(10, 100); context.lineTo(10, 10); context.fill(); context.stroke(); context.closePath();}, false);

Page 200: 12-15-2011 HTML5 Design

200http://flickr.com/photos/dunstan/3099313036/

200

Page 201: 12-15-2011 HTML5 Design

201

BUT IS IT ACCESSIBLE?

Page 202: 12-15-2011 HTML5 Design

202

ACCESSIBLE CANVAS ISSUES

• Setting user interface elements in canvas

• Setting images in canvas

• Setting text in canvas

http://www.paciellogroup.com/blog/?p=362

Page 203: 12-15-2011 HTML5 Design

203

Progressive Enhancement& Canvas

“Progressive enhancement is a strategy for web design that emphasizes accessibility, semantic HTML markup, and external

style sheet and scripting technologies.”http://en.wikipedia.org/wiki/Progressive_enhancement

Page 204: 12-15-2011 HTML5 Design

204

https://github.com/mezzoblue/PaintbrushJS

Page 205: 12-15-2011 HTML5 Design

205

http://csssummit.com/

Page 206: 12-15-2011 HTML5 Design

206

•Take mugshot

•Make it black and white

•Compress with ImagOptim

http://imageoptim.pornel.net/

Page 207: 12-15-2011 HTML5 Design

207

<img class="mugshot filter-tint" data-pb-tint-opacity="0.2" data-pb-tint-colour="#517777" src="filename.png" />

Page 208: 12-15-2011 HTML5 Design

208

box-shadow: 1px 1px 4px #fff, 2px 2px 4px #fff, 3px 3px 2px #333;border-radius: 300px;

Page 209: 12-15-2011 HTML5 Design

209

http://www.filamentgroup.com/lab/jquery_visualize_plugin_accessible_charts_graphs_from_tables_html5_canvas/

Page 210: 12-15-2011 HTML5 Design

210http://www.filamentgroup.com/lab/jquery_visualize_plugin_accessible_charts_graphs_from_tables_html5_canvas/

210

Page 211: 12-15-2011 HTML5 Design

211

<th>W</th> <th>Th</th> <th>F</th> <th>Sa</th></tr> </thead> <tbody><tr> <th>Chris</th> <td>56</td> <td>30</td> <td>50</td> <td>0</td> <td>45</td> <td>120</td> <td>0</td></tr> </tbody></table>

Page 212: 12-15-2011 HTML5 Design

212212

Page 213: 12-15-2011 HTML5 Design

213

<link type="text/css" rel="stylesheet" href="visualize.jQuery.css"><script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script><!--[if IE]><script type="text/javascript" src="excanvas.compiled.js"></script><![endif]--><script type="text/javascript" src="visualize.jQuery.js"></script><script type="text/javascript">$(function(){ $('table').addClass('accessHide'); $('table').visualize({type: 'line', colors: ['#fff']});});</script>

Page 214: 12-15-2011 HTML5 Design

214

<link type="text/css" rel="stylesheet" href="visualize.jQuery.css"/><script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script><!--[if IE]><script type="text/javascript" src="excanvas.compiled.js"></script><![endif]--><script type="text/javascript" src="visualize.jQuery.js"></script><script type="text/javascript">$(function(){ $('table').addClass('accessHide'); $('table').visualize({type: 'line', colors: ['#fff']});});</script>

Page 215: 12-15-2011 HTML5 Design

215

<link type="text/css" rel="stylesheet" href="visualize.jQuery.css"/><script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script><!--[if IE]><script type="text/javascript" src="excanvas.compiled.js"></script><![endif]--><script type="text/javascript" src="visualize.jQuery.js"></script><script type="text/javascript">$(function(){ $('table').addClass('accessHide'); $('table').visualize({type: 'line', colors: ['#fff']});});</script>

Page 216: 12-15-2011 HTML5 Design

216

http://msdn.microsoft.com/en-us/library/bb250524(VS.85).aspx216

Page 217: 12-15-2011 HTML5 Design

217

<link type="text/css" rel="stylesheet" href="visualize.jQuery.css"/><script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script><!--[if IE]><script type="text/javascript" src="excanvas.compiled.js"></script><![endif]--><script type="text/javascript" src="visualize.jQuery.js"></script><script type="text/javascript">$(function(){ $('table').addClass('accessHide'); $('table').visualize({type: 'line', colors: ['#fff']});});</script>

Page 218: 12-15-2011 HTML5 Design

218

<link type="text/css" rel="stylesheet" href="visualize.jQuery.css"/><script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script><!--[if IE]><script type="text/javascript" src="excanvas.compiled.js"></script><![endif]--><script type="text/javascript" src="visualize.jQuery.js"></script><script type="text/javascript">$(function(){ $('table').addClass('accessHide'); $('table').visualize({type: 'line', colors: ['#fff']}); });</script>

Page 219: 12-15-2011 HTML5 Design

219

table.accessHide { position: absolute; left: -999999px; }table { height: 100px; width: 250px;}

Page 220: 12-15-2011 HTML5 Design

220

<link type="text/css" rel="stylesheet" href="visualize.jQuery.css"/><script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script><!--[if IE]><script type="text/javascript" src="excanvas.compiled.js"></script><![endif]--><script type="text/javascript" src="visualize.jQuery.js"></script><script type="text/javascript">$(function(){ $('table').addClass('accessHide'); $('table').visualize({type: 'line', colors: ['#fff']}); });</script>

Page 221: 12-15-2011 HTML5 Design

221

Page 222: 12-15-2011 HTML5 Design

222http://flickr.com/photos/dunstan/3099313036/

222

Page 223: 12-15-2011 HTML5 Design

223

XHTML, ...I THINK I WANT TO SEE ANOTHER MARKUP SPEC.

Page 224: 12-15-2011 HTML5 Design

224

RECOMMENDED• Universal Design for Web Applications by Matt May and Wendy Chisholm

• Bulletproof Ajax by Jeremy Keith

• Designing with Progressive Enhancement by Filament Group

• Microformats Made Simple by Emily Lewis

• How Buildings Learn by Stewart Brand

• HTML5 Cookbook by a whole bunch of people!

Page 225: 12-15-2011 HTML5 Design

225

upcoming EVENTS

• AIGA In Control Conference on Feb. 20-21st.

• 2 days, 1 track

• HTML5, CSS3, jQuery, Mobile Design, Content Strategy, and much more

• Orlando, FL

• http://2012.incontrolconference.com/

Page 226: 12-15-2011 HTML5 Design

226

THANK YOU!Christopher Schmitt

[email protected]

http://twitter.com/teleject