html5 for publishers presentation

67
HTML5 for Publishers Sanders Kleinfeld

Upload: fatullahdonie

Post on 18-Feb-2015

14 views

Category:

Documents


0 download

DESCRIPTION

An introduction to some features of HTML5 you may want to start using in your ePub ebooks

TRANSCRIPT

Page 1: HTML5 for Publishers Presentation

HTML5 for PublishersSanders Kleinfeld

Page 2: HTML5 for Publishers Presentation

My Seven-Year Journey from Traditional Print Production to Ebook

Production…

…in two slides

Page 3: HTML5 for Publishers Presentation

My Desk in 2004(a reenactment)

Page 4: HTML5 for Publishers Presentation

My Desk in 2012(this is progress?)

Page 5: HTML5 for Publishers Presentation

Ebook Production = Developing Content for a Multitude of

Screens…

eInk Color Tablet Desktop Browser

Page 6: HTML5 for Publishers Presentation

…Via many formats, technologies, and software tools

EPUB 2.0.1

EPUB 3

KF8

Mobi

fixed layout

OPF

.iba

NCX

kindlegen

epubcheck

DRMepubpreflight

masochism

sigil

regex

oXygen

XSL

CSS

JS

Page 7: HTML5 for Publishers Presentation

HTML5

Page 8: HTML5 for Publishers Presentation

HTML5: New elements(http://www.w3.org/TR/html5-diff/#new-elements)

Navigation:<article><aside><header><hgroup><footer><figure><figcaption><nav><section>

Multimedia/Interactivity:<audio><canvas><embed><source><track><video>

Page 9: HTML5 for Publishers Presentation

HTML5: New elements (continued)(http://www.w3.org/TR/html5-diff/#new-elements)

New <input> types:colordatedatetimedatetime-localemailmonthnumberrangesearchteltimeurlweek

Miscellaneous:<bdi><command><datalist><details><keygen><mark><meter><output><progress><summary><rp><rt><ruby><time><wbr>

Page 10: HTML5 for Publishers Presentation

What is HTML5, really?

A constellation of technologies

Page 11: HTML5 for Publishers Presentation

Canvas

Geolocation

Audio/Video

CSS3

Page 12: HTML5 for Publishers Presentation

When people say "HTML5," they're usually referring to...

...next-generation web sites that include one or more of the following:

• Embedded audio/video media without resorting to Flash or other plugins 

• Native interactivity/animation/games without resorting to Flash or other plugins

• Geolocation functionality• Sites with local storage that you can download and run

offline• Fancy CSS3: columns, text shadows, animations...• Native support for MathML and SVG• Semantic markup

Page 13: HTML5 for Publishers Presentation

HTML5 in Action on the Web

Page 14: HTML5 for Publishers Presentation

Why should publishers care about HTML5?

Page 15: HTML5 for Publishers Presentation

HTML5 is the Backbone of the EPUB 3 Standard

The EPUB 3.0 specification for ebooks mandates that content documents use XHTML (HTML5) syntax:http://idpf.org/epub/30/spec/epub30-contentdocs.html#sec-xhtml

While most major ereaders do not formally support EPUB 3, many HTML5 features are currently supported by the following platforms:

• iBooks for iPad, iPhone, iPod• NOOK Color/Tablet• Kindle Fire• Kindle Apps (iPhone/iPad/Android/etc.)• Safari Books Online

Page 16: HTML5 for Publishers Presentation

HTML5 in action in ebooks

Page 17: HTML5 for Publishers Presentation

HTML5 Canvas for Publishers

Canvas allows you to embed a dynamic sketchpad in your content:

<canvas id="my_first_canvas" width="200" height="225">The content you put here will show up if your rendering engine doesn't support the &lt;canvas&gt; element.</canvas>

Page 18: HTML5 for Publishers Presentation

You draw on the <canvas> with JavaScript my_canvas.strokeRect(0,0,200,225) // to start, draw a border around the canvas

//draw face

my_canvas.beginPath();

my_canvas.arc(100, 100, 75, (Math.PI/180)*0, (Math.PI/180)*360, false); // circle dimensions

my_canvas.strokeStyle = "black"; // circle outline is black

my_canvas.lineWidth = 3; // outline is three pixels wide

my_canvas.fillStyle = "yellow"; // fill circle with yellow

my_canvas.stroke(); // draw circle

my_canvas.fill(); // fill in circle

my_canvas.closePath();

// now, draw left eye

my_canvas.fillStyle = "black"; // switch to black for the fill

my_canvas.beginPath();

my_canvas.arc(65, 70, 10, (Math.PI/180)*0, (Math.PI/180)*360, false); // circle dimensions

my_canvas.stroke(); // draw circle

my_canvas.fill(); // fill in circle

my_canvas.closePath();

// now, draw right eye

my_canvas.beginPath();

my_canvas.arc(135, 70, 10, (Math.PI/180)*0, (Math.PI/180)*360, false); // circle dimensions

my_canvas.stroke(); // draw circle

my_canvas.fill(); // fill in circle

my_canvas.closePath();

// draw smile

my_canvas.lineWidth = 6; // switch to six pixels wide for outline

my_canvas.beginPath();

my_canvas.arc(99, 120, 35, (Math.PI/180)*0, (Math.PI/180)*-180, false); // semicircle dimensions

my_canvas.stroke();

my_canvas.closePath();

// Smiley Speaks!

my_canvas.fillStyle = "black"; // switch to black for text fill

my_canvas.font = '20px _sans'; // use 20 pixel sans serif font

my_canvas.fillText ("Hello Canvas!", 45, 200); // write text

Page 19: HTML5 for Publishers Presentation

The result...

Page 20: HTML5 for Publishers Presentation

But Canvas is all about interactivity...

You can dynamically update what's displayed on the canvas in real time, and in response to user input, which opens the door to animations, games, and more.

Page 21: HTML5 for Publishers Presentation

Canvas in Action: Graphing Calculatorhttp://bit.ly/canvascalc

Page 22: HTML5 for Publishers Presentation

Canvas in Action II: Finger Paintinghttp://bit.ly/canvasfingerpaint

Page 23: HTML5 for Publishers Presentation

Geolocation for Publishers

The W3C Geolocation API (http://dev.w3.org/geo/api/spec-source.html) provides a simple way of getting a user's latitude/longitude coordinates:

navigator.geolocation.getCurrentPosition(callback_function)

Where callback_function is a function you define to receive and process the latitude/longitude data.

Page 24: HTML5 for Publishers Presentation

Geolocation’s value in ebooks

• Interactive Atlas, Road Maps• Travel/Restaurant guides customized for user’s location• Geolocated fiction• Geolocation-based games (geocaching, scavenger hunt)

Page 25: HTML5 for Publishers Presentation

Geolocation in Action: A Geolocated Tale

http://bit.ly/geolocatedtale

Before...

Page 26: HTML5 for Publishers Presentation

Geolocation in Action: A Geolocated Tale

http://bit.ly/geolocatedtale

After...

Page 27: HTML5 for Publishers Presentation

Audio/Video for Publishers

HTML5 lets you embed audio/video directly in your content without any plugins needed:

<audio id="new_slang"> <source src="new_slang.wav" type="audio/wav"/> <source src="new_slang.mp3" type="audio/mp3"/> <source src="new_slang.ogg" type="audio/ogg"/> <em>(Sorry, &lt;audio&gt; element not supported in your browser/ereader, so you will not be able to listen to this song.)</em> </audio>

<video id="dancing_pony" width="300" height="300"> <source src="dancing_pony.mp4" type="video/mp4"/> <source src="dancing_pony.ogg" type="video/ogg"/> <em>(Sorry, &lt;video&gt; element not supported in your browser/ereader, so you will not be able to watch this video.)</em></video>

Page 28: HTML5 for Publishers Presentation

Audio/Video Compatibility Woes(via Wikipedia)

<audio> support in Browsers (http://en.wikipedia.org/wiki/Html5_audio#Audio_format_support)

<video> support in Browsers (http://en.wikipedia.org/wiki/HTML5_video#Table)

Page 29: HTML5 for Publishers Presentation

Ereader Audio/Video Compatibility Redux

For audio, use MP3. It works on:

• iBooks• NOOK Color/Tablet• Kindle software readers (iPad/iPhone/Android/etc.)

For video, use H.264/MP4. It works on:

• iBooks• NOOK Color/Tablet• Kindle software readers (iPad/iPhone/Android/etc.)

Page 30: HTML5 for Publishers Presentation

Audio in Action: Audio-Enabled Glossaryhttp://bit.ly/miniglossary

Page 31: HTML5 for Publishers Presentation

Video in Action: A Clip About <canvas>

http://bit.ly/ormcanvasvid

Page 32: HTML5 for Publishers Presentation

MathML for Publishers• MathML is an XML vocabulary for representing

mathematical expressions.

• MathML provides both Presentation and Content Markup models.

• Presentation markup tags math expressions based on how

they should be displayed (e.g., “superscripted 2”).

• Content markup tags expressions based on the mathematical operations performed (e.g., “taken to the 2nd power”)

• The HTML5 specification provides native support for MathML in HTML documents

Page 33: HTML5 for Publishers Presentation

MathML Presentation Markup Glossary (abridged edition)

• <math> -- Root element for a mathematical expression• <mrow> -- Element for grouping subexpressions• <mo> -- Math operator (e.g., +, -)• <mi> -- Math identifier (e.g., variable or constant)• <mn> -- Number• <mfrac> -- Fraction• <msqrt> -- Square root• <msup> -- Superscript• <msub> -- Subscript• <mfenced> -- Parentheses or braces

Page 34: HTML5 for Publishers Presentation

Convert a Famous Equation to MathML!http://bit.ly/mathconverter

Page 35: HTML5 for Publishers Presentation

But why write all this markup:

<math xmlns="http://www.w3.org/1998/Math/MathML"> <mstyle displaystyle="true"> <mi> E </mi> <mo> = </mo> <mi> m </mi> <msup> <mrow> <mi> c </mi> </mrow> <mrow> <mn> 2 </mn> </mrow> </msup> </mstyle></math>

When you can just embed the equation as an image?

Page 36: HTML5 for Publishers Presentation

Advantages of Using MathML Instead of Images:

• Equations are resizable, like text

• Equations can be styled with CSS

• Equations can be interacted with using JavaScript

Page 37: HTML5 for Publishers Presentation

MathML in Action: Quadratic Equation Solver

http://bit.ly/mathml

Page 38: HTML5 for Publishers Presentation

CSS3: A Four-Bullet Overview

• CSS3 offers some great new features for styling content, including animations, rounded corners, text shadows, and transitions.

• CSS3 specifications are separate from HTML5, and many features are still in the earliest Working Draft (WD) phase: http://www.w3.org/Style/CSS/current-work

• CSS3 support varies by Web browser

• Many CSS3 properties are supported in browsers only when prepended with proprietary extensions: -webkit- (Google Chrome and Safari), -moz- (Firefox), -o- (Opera), -ms- (Internet Explorer)

Page 39: HTML5 for Publishers Presentation

CSS3: Compatibility Woeshttp://www.w3schools.com/cssref/css3_browsersupport.asp

Page 40: HTML5 for Publishers Presentation

(e)Book Production Pop Quiz(featuring CSS3 Transitions)

Page 41: HTML5 for Publishers Presentation

Take the Quiz Yourselfhttp://bit.ly/pop_quiz

Page 42: HTML5 for Publishers Presentation

OH NOEZ!

MAH EREADR DOESNT SUPPORT CSS3 OR JAVASCRIPT

http://www.flickr.com/photos/eiriknewth/4944889740/

Page 43: HTML5 for Publishers Presentation

When designing interactive content for a diverse ereader ecosystem,

think about implementing fallbacks, especially for the following features:

•<canvas>•<audio>•<video>• MathML• Geolocation• CSS3• JavaScript

Page 44: HTML5 for Publishers Presentation

Fallbacks Part I: CSS and JS“Same ebook file, different instructions”

Adobe Digital Editions: No JS support

iBooks: Full functionality

Page 45: HTML5 for Publishers Presentation

How to Do This:

1. Use @class attributes on HTML elements to designate interactive vs. fallback:

2. Define CSS to suppress “interactive” elements by default:

3. Use JS to toggle “interactive” elements on and “fallback” elements off in browsers that support scripting:

<p class="interactive">Display me in ereaders that support JS</p><p class="fallback">Display me instead if no JS support</p>

1. Use @class attributes on HTML elements to designate interactive vs. fallback:

.interactive { display: none }

function toggleInteractiveContent() { // Select elements with ”fallback” on them, and hide them $(".fallback").css("display", "none"); // Select elements with "interactive”, and delete @class to make them appear $(".interactive").removeClass("interactive");}

Page 46: HTML5 for Publishers Presentation

Semantic Tagging with HTML5

<article><aside><div><header><footer><figure><figcaption><nav><section>

HTML5 offers a set of new tags that provide the ability to mark up the sections of a document more descriptively than you could in HTML 4.01

<div>

HTML 4.01 HTML5

Page 47: HTML5 for Publishers Presentation

Semantic Tagging: Before & After

HTML 4.01 HTML5<html xmlns="http://www.w3.org/1999/xhtml"><head><title>The United States Constitution</title></head><body><h1>THE UNITED STATES CONSTITUTION</h1><div class="section"><h2>Preamble</h2><p>We the People of the United States, in Order to form a more perfect Union...</p></div><div class="article"><h2>Article I</h2><div class="section"><h3>Section 1</h3><p>All legislative Powers herein granted shall be vested in a Congress of the United States, which shall consist of a Senate and House of Representatives.</p></div></div><div class="figure"><img src="bald_eagle.jpg"/><div class="caption">The eagle has landed</div></div></body></html>

<html xmlns="http://www.w3.org/1999/xhtml"><head><title>The United States Constitution</title></head><body><h1>THE UNITED STATES CONSTITUTION</h1><section><h2>Preamble</h2><p>We the People of the United States, in Order to form a more perfect Union...</p></section><article><h2>Article I</h2><section><h3>Section 1</h3><p>All legislative Powers herein granted shall be vested in a Congress of the United States, which shall consist of a Senate and House of Representatives.</p></section></article><figure><img src="bald_eagle.jpg"/><figcaption>The eagle has landed</figcaption></figure></body></html>

Page 48: HTML5 for Publishers Presentation

Semantic Tagging: Before & After

HTML 4.01 HTML5

Page 49: HTML5 for Publishers Presentation

What’s the point of semantic tagging, if the content looks the same?

Page 50: HTML5 for Publishers Presentation

Semantic tagging is for machines, not humans

It provides a universal grammar so that machines can more easily parse

HTML content

✗ ✔

Page 51: HTML5 for Publishers Presentation

It’s Harder for a Machine to parse this HTML…

<p>Web page created on January 18, 2012</p>

…than this HTML

<footer>Web page created on <time pubdate="2012-01-18">January 18, 2012</time></footer>

Page 52: HTML5 for Publishers Presentation

Extending HTML5 Semantics in EPUB 3

EPUB 3 supports “inflection” of HTML5 elements through the epub:type attribute:

<section epub:type="colophon"><p>The animal on the cover of this book is a meerkat…</p></section>

epub:type accepts the book terms defined in the EPUB 3 Structural Semantics Vocabulary:

http://idpf.org/epub/vocab/structure/

These include: “volume”, “chapter”, “epigraph”, “appendix”, “glossary”…

Page 53: HTML5 for Publishers Presentation

HTML5 support in today’s ereaders 

<canvas> Geolocation <audio> <video> MathML

iBooks 1.x YES Sort of* YES YES YES

NOOK Color/Tablet

NO NO YES YES NO

Safari Books Online

YES YES YES YES YES

Kindle Apps NO NO YES YES NO

Kindle Fire NO NO NO NO NO

* iBooks 1.x supports Geolocation API, but does not support calls to related APIs (Google Maps, GeoNames, etc.)

Page 54: HTML5 for Publishers Presentation

HTML5 and Kindle Fire

Some key HTML5 tags supported on Kindle Fire (KF8)*:

* See Amazon’s KF8 HTML5 & CSS feature list: http://amzn.to/kf8_html5_css3

Page 55: HTML5 for Publishers Presentation

CSS and Kindle Fire

Some key CSS properties supported on Kindle Fire (KF8)*:

* See Amazon’s KF8 HTML5 & CSS feature list: http://amzn.to/kf8_html5_css3** CSS3 feature

Page 56: HTML5 for Publishers Presentation

Fallbacks Part II: @media queriesWith Kindlegen 2.3, you can use @media queries to earmark CSS specifically for KF8-enabled devices (Kindle Fire) or classic Mobi devices (Kindle eInk, Kindle for iOS)

Page 57: HTML5 for Publishers Presentation

Fallbacks Part II: @media queries

Kindle eInk Kindle Fire

Page 58: HTML5 for Publishers Presentation

What About iBooks Author?iBooks Author is Apple’s new e-publishing tool that lets you design multimedia (text)book content for iBooks 2.0 for iPad.

Page 59: HTML5 for Publishers Presentation

Five Key Facts About iBooks Author• It’s the best GUI tool available for designing interactive/multimedia

ebooks*

• It supports HTML5 content via Widgets.

• But it’s proprietary. iBooks Author exports to the .ibooks format, which can be read only on iBooks 2.0 for iPad (no iPhone/iPod support).

• You cannot export EPUB from the iBooks Author App.

• You cannot import EPUB into the iBooks Author App (although you can import Word and Pages documents)

• If you want to sell your .ibooks ebook, you can only do so in Apple’s iBookstore. (Free ebooks can be distributed elsewhere)

* Presenter’s personal opinion

Page 60: HTML5 for Publishers Presentation

Learn iBooks Author with this free ebookhttp://oreil.ly/publishiba

Page 61: HTML5 for Publishers Presentation

iBooks Author and HTML5iBooks Author comes with ready-bake Widgets (no coding needed) for the following features:

•Photo Gallery

•Audio/Video Media

•Interactive Review Quizzes

•Keynote Presentations

•“Interactive Images”

•3-D Visualizations

Page 62: HTML5 for Publishers Presentation

Make your own Custom Widgets with Dashcode

If the interactive features you want to add to your ebook aren’t covered by Apple’s prefab Widgets, you can roll your own widget with Dashcode.

Dashcode is a free tool from Apple that is part of the Xcode developer suite. Its primary purpose is to develop OS X Dashboard Widgets using HTML/CSS/JS, but you can also use it to develop webapps for Desktop and Mobile Safari.

Dashcode Widget (.wdgt) files can be dragged directly into iBooks Author.

Page 63: HTML5 for Publishers Presentation

Building the Widget1. Design the UI

2. Add event handlers

3. Add JavaScript code

Page 64: HTML5 for Publishers Presentation

Drag the Widget into iBooks Author

Page 65: HTML5 for Publishers Presentation

Widget Running in iBooks on iPad

Page 66: HTML5 for Publishers Presentation

Download HTML5 for Publishers:

http://bit.ly/html5forpubs

Page 67: HTML5 for Publishers Presentation

Contact Me!Email: [email protected]

Twitter: @sandersk