getting started with html5 in tech com (stc 2012)
DESCRIPTION
Peter Lubbers' session about getting started with HTML5 for technical communicators, presented at the May 2012 STC Summit in Chicago.TRANSCRIPT
1 © 2011 – Kaazing Corporation
@peterlubbersKaazing
#stc12
Getting Started with HTML5Illustration by Will Phillips Jr. | HTML5 Logo attributed W3C
2 © 2011 – Kaazing Corporation
Your host: @peterlubbers
3 © 2011 – Kaazing Corporation
Image @rdclark
4 © 2011 – Kaazing Corporation
Image: @jeffreypalermo
5 © 2011 – Kaazing Corporation
Agenda
• HTML5—What and Why?• HTML5 Features• Your HTML5 Toolkit• Q&A
#stc12@peterlubbers
6 © 2011 – Kaazing Corporation
Word on the Street…
"The world is moving to HTML5"—Steve Jobs, Apple
"The Web has not seen this level of transformation, this level of acceleration, in the past ten years… we're betting big on HTML5"—Vic Gundotra, VP of Engineering, Google
“If you want to do something universal, there is no question, the world is going HTML5. That is clear...The world is just pushing down this HTML5 path and so are we.—Steve Ballmer, CEO Microsoft
"I had no idea there was so much HTML5 already in play"—Tim O'Reilly
"HTML5’s impact on Tech Com will be bigger than DITA"—Peter Lubbers
7 © 2011 – Kaazing Corporation
HTML5 and DITA
• Continue to author in DITA, but output to HTML5 and CSS3
• Replacement of tri-pane layouts of DITA OT with style-based layouts
“Users of DITA … see some clear associations of these HTML5 elements with structures in both DITA topics and DITA maps.”—Don Day
http://learningbywrote.com/blog/2011/08/html-5-in-the-world-of-dita/
8 © 2011 – Kaazing Corporation
#1 Job Trend 2011
“HTML5" is the #1 job trend - the fastest growing keyword found in online job postings”—indeed.com (http://goo.gl/xXZVm)
9 © 2011 – Kaazing Corporation
• The new major milestone for HTML
• Focused on Web Applications
• Web apps are rapidly becoming first class apps, on par with desktopand native apps
• Different definitions
What is HTML5?
CSSJavaScript
HTML
NEWT?
10 © 2011 – Kaazing Corporation
HTML5 Feature Areas
11 © 2011 – Kaazing Corporation
HTML5 At a Glance
12 © 2011 – Kaazing Corporation
Why HTML5?
5 Reasons why you should care!
13 © 2011 – Kaazing Corporation
1) HTML5 Paves the Cow Paths
• Because HTML5 takes a pragmatic approach, fixing common real-world problems
14 © 2011 – Kaazing Corporation
Paved Cow Path
HTML4
<form> <input name="email" type="text">
HTML5
<input type=email required>
crapload of validation codeor extra js lib
(?:[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*|"(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21\x23-\x5b\x5d-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])*")@(?:(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?|\[(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?|[a-z0-9-]*[a-z0-9]:(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21-\x5a\x53-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])+)\])
15 © 2011 – Kaazing Corporation
2) HTML5 Simplifies
Because HTML5 is, well, simpler
16 © 2011 – Kaazing Corporation
Simplified Doctype
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
HTML5
<!DOCTYPE html>
HTML4/XHTML• HTML 4.01 Strict• HTML 4.01 Transitional• HTML 4.01 Frameset• XHTML 1.0 Strict• XHTML 1.0 Transitional• XHTML 1.0 Frameset• XHTML 1.1
17 © 2011 – Kaazing Corporation
Simplified Character Set
HTML4
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
HTML5
<meta charset=utf-8>
18 © 2011 – Kaazing Corporation
Simplified Markup
HTML5
<!DOCTYPE html> <meta charset=utf-8> <title>HTML5</title> <h1>HTML5!</h1>
DOM
70 characters!
19 © 2011 – Kaazing Corporation
Simplified Markup
Two HTML5 pages in one tweet!
20 © 2011 – Kaazing Corporation
3) HTML5 is Universal
• Because HTML5 works in all languages and accessibility is built in from the ground up
21 © 2011 – Kaazing Corporation
Universal Access
• Support for all world languages• For example, the new <ruby> element
• Accessibility • Semantic markup• WebVTT
<video controls preload="metadata"> <source src="rocpoc.mp4"> <track label="English" kind="subtitles" src="subtitles_en.vtt”></video>
WEBVTT
100:00:01,000 --> 00:00:03,050What do I think about HTML 5?...
200:00:04,000 --> 00:00:07,100It’s pretty sweet. I just hope that people use the new features thoughtfully.
http://html5videoguide.net/presentations/WebVTT
22 © 2011 – Kaazing Corporation
4) HTML5 Means Less Plugins
• Because HTML5 provides native support for many features that were possible only with plugins or complex hacks (audio/video, drawing, sockets)
23 © 2011 – Kaazing Corporation
Plugins are on the way out
• Built-in is better than bolt-on —@brucel• Plugins may not be installed (for long)• Plugins can be an attack vector (Proxy poisoning)• “Whenever a Mac crashes, more often that not is
because of Flash” —Steve Jobs
http://www.infoq.com/news/2011/09/Metro-Plug-ins http://goo.gl/mzFjM
24 © 2011 – Kaazing Corporation
5) HTML5 is Secure by Default
• HTML5 uses origin-based security• Defines secure cross-origin sharing• Issues in HTML5 are fixed quickly
http://enable-cors.org/
25 © 2011 – Kaazing Corporation
Semantic Markup & Microdata
26 © 2011 – Kaazing Corporation
New HTML5 Elements
Layout (semantics) Multimedia Other
article section audio, video command, menu*
aside nav source embed
figure figcaption
header footer Graphics Forms
details summary canvas datalist
wbr hgroup svg progress
time mark output
meter ruby, rp, rt keygen
* menu redefined from HTML 4
dev.w3.org/html5/markup/elements.html
27 © 2011 – Kaazing Corporation
Obsolete Elements
Presentational Frames Other
basefont frame acronym
big frameset applet
center noframes isindex
font
strike
tt
http://www.w3.org/TR/html5-diff/#obsolete-elements
28 © 2011 – Kaazing Corporation
Semantic Markup Benefits
• Based on research (Opera, Google studies on commonly used div class and id names)
• Cleaner, less verbose markup (replace div and span elements with meaningful elements)
• Machine readable:• Search engines• Syndication
• Linking and sharing
29 © 2011 – Kaazing Corporation
Semantic Markup
30 © 2011 – Kaazing Corporation
Moving to Structural/Semantic Markup
1. Identify functional areas /use structural tags
2. Separate content from presentation• Move styles to CSS file• Use a reset stylesheet• Consider a grid system
for layout
3. Consider alternate layouts (e.g. mobile)
nav
footer + nav
article
section
31 © 2011 – Kaazing Corporation
HTML
<!-- Progressive Information Disclosure --><details> <summary>What are my download options?</summary> <ul> <li><strong>Base:</strong> Contains a minimal
download...</li> <li><strong>Full:</strong> Contains the Base
download plus documentation and demos.</li></ul>
</details>
Details Element
32 © 2011 – Kaazing Corporation
Progressive Info. Disclosure
http://tech.kaazing.com/documentation/html5/3.3/setup-guide.html
33 © 2011 – Kaazing Corporation
Valid HTML vs. Valid XHTML
• So you created XHTML…
• But did you know that:• Over 90% of XHTML is delivered with the text/html• Delivering XHTML as application/xhtml+xml is
risky (not supported in old IE)
• Instead, use HTML5 and create valid HTML• http://html5.validator.nu/ and http://validator.w3.org
• HTML5 allows XML syntax from XHTML 1.0 for backward compatibility
34 © 2011 – Kaazing Corporation
Microdata
• Emphasis on machine readability• SEO advantages• Use Microdata embed machine-readable data in
HTML documents • Easy-to-write syntax (add to any element)• Compatible with other data formats such as
RDF and JSON• Use microdata vocabularies:
http://data-vocabulary.org
35 © 2011 – Kaazing Corporation
<section itemscope> <article id="html5-fast-track" itemtype="http://data-vocabulary.org/Product"> <header> <h1 itemprop="name”>HTML5 Fast Track</h1> </header> <p itemprop="description">The HTML5 Fast Track training course is a two day experience... </p> </article></section>
HTML
HTML5 Microdata Example
36 © 2011 – Kaazing Corporation
Microdata Testing
http://www.google.com/webmasters/tools/richsnippets
37 © 2011 – Kaazing Corporation
HTML5 Forms
• New form functionality:• No JavaScript required• Native date and color pickers• Search, e-mail, web address• Client side validation• Spin boxes and sliders
• Features degrade gracefully (unknown input types are treated as text)
• Benefits:• Virtual keyboard support• Native widgets and error messages are internationalized
38 © 2011 – Kaazing Corporation
<form> <p><label for="phone">Telephone number:</label> <input type=tel placeholder="(xxx) xxx-xxx" required></p> <p><label for="emailaddress">E-mail address:</label> <input id="emailaddress" name="emailaddress" type=email required></p> <p><label for="dob">DOB:</label><input id="dob” name="dob” type=date value=1944-06-06 max=1992-05-01></p> <p><label for="color">Shirt Color:</label> <input id="color" name="color" type="color"></p>
HTML
Example HTML5 Form
39 © 2011 – Kaazing Corporation
New Input Types
Date picker
Color picker
40 © 2011 – Kaazing Corporation
CSS3
41 © 2011 – Kaazing Corporation
CSS Level 3
• Modularized for easier browser uptake• Almost 50 modules (readiness varies)• Use browser-specific prefixes until finalized• Dramatically improves performance• Examples:
• Border radius (rounded corners) without images
• Gradients• Multi-column layout• Transformations and transitions• Web Fonts• Media Queries
42 © 2011 – Kaazing Corporation
Rounded corners
a:hover img {border-radius: 10px;border: 2px solid #F47D31;-webkit-transform: scale(1.05);
}
CSS
43 © 2011 – Kaazing Corporation
<html><head> <link rel="stylesheet" type="text/css" href="http://fonts.googleapis.com/css?family=Tangerine"> <style> h1 { font-family: 'Tangerine', serif; font-size: 48px; } </style></head><body><h1>Making the Web Beautiful!</h1></body>
HTML
Web Fonts
http://code.google.com/apis/webfonts/docs/getting_started.html#Quick_Start
44 © 2011 – Kaazing Corporation
Media Queries
/* Media-specific sections of stylesheet */
@media all and (orientation:landscape) { /* e.g. rotated smartphone */ }
@media screen and (max-device-width: 480px) { /* small screen */ }
@media print { /* drop navigation elements that make no sense on paper */ nav { visibility:hidden; }}
CSS
45 © 2011 – Kaazing Corporation
Responsive Web Design
http://www.boston.com/bostonglobe/features/
46 © 2011 – Kaazing Corporation
Multimedia
47 © 2011 – Kaazing Corporation
HTML5 Audio and Video
• New HTML5 media elements• <audio> and <video>
• Native audio and video (no plugins required)• Programmable with JavaScript• Style with CSS
• Add videos and audio as if it was an image• Codec support varies, but multiple
source elements and fallback content can be used
• Complete JavaScript API available
48 © 2011 – Kaazing Corporation
HTML
//Basic Video<video controls src=”goldrush.mp4"> A movie about HTML5</video>
// Video with additional attributes<video id="movies" controls preload="metadata" width="400px" height="300px" poster="html5.png" > <source src="goldrush.webm"> <source src="goldrush.mp4"> <track label="English" kind="subtitles" srclang="en" src="subtitles_en.vtt"> A movie by Rocky Lubbers</video>
HTML5 Video Example
49 © 2011 – Kaazing Corporation
<!—Multiple videos with alternate Flash content--><video controls> <source src=”goldrush.webm"> <source src=”goldrush.mp4”> <track label="English" kind="subtitles" srclang="en" src="subtitles_en.vtt"> <object data="videoplayer.swf" type="application/x-shockwave-flash"> <param name="movie" value="rocpoc.swf"/> A movie by Rocky Lubbers </object> </video>
HTML
Flash Video Fallback
50 © 2011 – Kaazing Corporation
WebVTT
WEBVTT
100:00:01,000 --> 00:00:03,050What do I think about HTML 5?...
200:00:04,000 --> 00:00:07,100It’s the next big thing! I just hope that people use the new features thoughtfully.
WebVTT (Video Accessibility)
51 © 2011 – Kaazing Corporation
Video API
http://www.w3.org/2010/05/video/mediaevents.html
52 © 2011 – Kaazing Corporation
Graphics and 3D
53 © 2011 – Kaazing Corporation
HTML5 Canvas and SVG
• Provide native drawing functionality• Previously possible only with plugins
(Flash, Silverlight)
• Completely integrated into HTML5 documents (part of DOM)• Can be styled with CSS• Can be controlled with JavaScript
• Use for animation, charts, images,pixel manipulation, and so on
• Canvas supports 2D and 3D (WebGL)• Will impact animated graphics and
diagrams soon (use libraries)
54 © 2011 – Kaazing Corporation
Canvas Animation
Demo courtesy Gary Davis, AniWorx
55 © 2011 – Kaazing Corporation
SVG
"Scalable" Vector Graphics (not bitmaps)
http://www.croczilla.com/bits_and_pieces/svg/samples/tiger/tiger.svg
56 © 2011 – Kaazing Corporation
SVG Libraries
http://mbostock.github.com/d3/
57 © 2011 – Kaazing Corporation
Device Access
58 © 2011 – Kaazing Corporation
Speech Input
http://slides.html5rocks.com/#speech-input
59 © 2011 – Kaazing Corporation
Accelerometer/WebSocket
http://demo.kaazing.com/racer/
60 © 2011 – Kaazing Corporation
Device Orientation
Demo: http://slides.html5rocks.com/#slide-orientation
Image: http://idisk.mac.com/han.solo-Public/Canvas/SteelSeries/Radial.html
61 © 2011 – Kaazing Corporation
Offline and Storage
62 © 2011 – Kaazing Corporation
Offline Web Applications
• Use complete web sites (documentation sets) in offline mode
• Cache pages that have not been visited yet• Browsers cache data in an Application Cache• HTML5 allows online and offline detection• Allows prefetching of
site resources (can speed up pages)
• Simple manifest mechanism
63 © 2011 – Kaazing Corporation
CACHE MANIFEST# manifest version 1.0.1 # Files to cacheindex.htmlcache.htmlhtml5.cssimage1.jpgimg/foo.gifhttp://www.example.com/styles.css
# Use from network if availableNETWORK:network.html
# Fallback contentFALLBACK:/ fallback.html
appcache File
Example appcache File
64 © 2011 – Kaazing Corporation
<!DOCTYPE html><html manifest="offline.appcache"> <head> <title>HTML5 Application Cache Rocks!</title>
HTML
• Reference the manifest file:• Use .appcache extension (*.manifest also allowed)• Add as attribute to HTML element
Example manifest Attribute
http://appcachefacts.info/
65 © 2011 – Kaazing Corporation
The 2012 HTML5 Toolbox
66 © 2011 – Kaazing Corporation
Browser Support
http://paulirish.com/2010/high-res-browser-icons
• Modern browsers (incl. mobile) already support a lot of features, :• http://html5test.com
• Support varies widely for different features• IE 6,7 and 8: minimal support• Use support matrices:• http://caniuse.com• http://mobilehtml5.org
67 © 2011 – Kaazing Corporation
Browser Built-In Tool Mac Shortcut Windows Shortcut
Chrome Developer Tools Command + Option + J
CTRL + Shift + J
Firefox Firebug F12 F12
Opera Dragonfly Command + Option + I
CTRL + Shift + I
Safari Web Inspector Command + Option + I
CTRL + Alt + I
Internet Explorer Developer Tools F12
Browser Developer Tools
68 © 2011 – Kaazing Corporation
HTML5 Boilerplate
• The best way to get started
http://html5boilerplate.com
69 © 2011 – Kaazing Corporation
Modernizr
• Part of H5BP• Download or create a
custom build• Use Modernizr.load
to test for feature support
Javascript
Modernizr.load({ test: Modernizr.websocket, yep : ’websocket.js', nope: ’kz-websocket-polyfill.js'});
http://www.sfhtml5.org/events/28458331
70 © 2011 – Kaazing Corporation
Polyfills and Emulation
• Feature detect with Modernizr (part of H5BP):http://www.modernizr.com
• Complete polyfill list: https://github.com/Modernizr/Modernizr/wiki/HTML5-Cross-browser-Polyfills
71 © 2011 – Kaazing Corporation
Chrome Frame
• The Ultimate polyfill• Embed Chrome in IE• No admin privileges
needed to install
HTML
<!-- Always force latest IE rendering engine (even in intranet) & Chrome Frame
<meta http-equiv="X-UA-Compatible“ content="IE=edge,chrome=1”>
http://code.google.com/chrome/chromeframe/
72 © 2011 – Kaazing Corporation
Mobile Boilerplate
http://html5boilerplate.com/mobile/
73 © 2011 – Kaazing Corporation
320 and up
http://stuffandnonsense.co.uk/projects/320andup
74 © 2011 – Kaazing Corporation
Opera Mobile Emulator
http://www.opera.com/developer/tools/mobile/
75 © 2011 – Kaazing Corporation
Ripple Mobile Emulator
http://ripple.tinyhippos.com/download
76 © 2011 – Kaazing Corporation
Questions?
• Now or Later• E-mail: [email protected]• Twitter: @peterlubbers• LinkedIn: Peter Lubbers
77 © 2011 – Kaazing Corporation
Buy the Book!
• Pro HTML5 Programming (Apress, 2011)• 50% off e-book coupon code:
HTL528http://goo.gl/4RmFk
78 © 2011 – Kaazing Corporation
Get Trained!
• Proven, practical worldwide HTML5 Training (training from experts, not just trainers):• E-mail us: [email protected]• Web site: http://kaazing.com/training/
79 © 2011 – Kaazing Corporation
SF HTML5 User Group
• Free• Great monthly events with
top speakers• Video-taped• Twitter: @sfhtml5• Sign up today:
www.sfhtml5.org
The HTML5 logo is attributed to the W3C. http://www.w3.org/html/logo/
80 © 2011 – Kaazing Corporation
Other Great Resources
• HTML5 Weekly (weekly newsletter):http://html5weekly.com/
• The Web Ahead (5x5 Podcast):http://5by5.tv/webahead/
81 © 2011 – Kaazing Corporation
Elements Overview
http://html5doctor.com/element-index/
82 © 2011 – Kaazing Corporation
Who is Developing HTML5?
• Web Hypertext Application Technology Working Group (WHATWG)http://www.whatwg.org/specs/web-apps/current-work/
• World Wide Web Consortium (W3C)http://dev.w3.org/html5/spec/Overview.html
• Internet Engineering Task Force (IETF)http://tools.ietf.org/html/draft-hixie-thewebsocketprotocol
83 © 2011 – Kaazing Corporation