+ All Categories

Html 5

Date post: 10-May-2015
Category:
Upload: nguyen-quang
View: 1,713 times
Download: 0 times
Share this document with a friend
Popular Tags:
40
…for the future Web
Transcript
Page 1: Html 5

…for the future Web

Page 2: Html 5

Content

PART I – Introdution to HTML5PART II – New FeaturesPART III - References

Page 3: Html 5

Part I - Introduction to HTML5

• Introduction to HTML5• Rules for HTML5• Upgrading to HTML5• HTML5 – Overview to new features• Browser Support for HTML5• New Elements in HTML5

Page 4: Html 5

Introduction to HTML5

Page 5: Html 5

Rules for HTML5

• New features should be based on HTML, CSS, DOM, and JavaScript

• Reduce the need for external plugins (like Flash)• More markup to replace scripting• HTML5 should be device independent• The development process should be visible to the

public

Page 6: Html 5

Upgrading to HTML5

• Just <!DOCTYPE html>

Page 7: Html 5

HTML5 – Overview to new features

Page 8: Html 5

Browser Support for HTML5

• HTML5 is not yet an official standard, and no browsers have full HTML5 support.

• But all major browsers (Safari, Chrome, Firefox, Opera, Internet Explorer) continue to add new HTML5 features to their latest versions.

Page 9: Html 5

New Elements in HTML5

Page 10: Html 5

New Elements in HTML5

Page 11: Html 5

New Elements in HTML5 (cont.)

Page 12: Html 5

New Elements in HTML5 (cont.)• New Semantic/Structural Elements

Tag Description

<article> Defines an article

<aside> Defines content aside from the page content

<bdi> Isolates a part of text that might be formatted in a different direction from other text outside it

<command> Defines a command button that a user can invoke

<details> Defines additional details that the user can view or hide

<summary> Defines a visible heading for a <details> element

<figure> Specifies self-contained content, like illustrations, diagrams, photos, code listings, etc.

<figcaption> Defines a caption for a <figure> element

<footer> Defines a footer for a document or section

<header> Defines a header for a document or section

<hgroup> Groups a set of <h1> to <h6> elements when a heading has multiple levels

<mark> Defines marked/highlighted text

<meter> Defines a scalar measurement within a known range (a gauge)

<nav> Defines navigation links

<progress> Represents the progress of a task

<ruby> Defines a ruby annotation (for East Asian typography)

<rt> Defines an explanation/pronunciation of characters (for East Asian typography)

<rp> Defines what to show in browsers that do not support ruby annotations

<section> Defines a section in a document

<time> Defines a date/time

<wbr> Defines a possible line-break

Page 13: Html 5

New Elements in HTML5 (cont.)

• New Media Elements

• The new <canvas> Element

Tag Description

<audio> Defines sound content

<video> Defines a video or movie

<source> Defines multiple media resources for <video> and <audio>

<embed> Defines a container for an external application or interactive content (a plug-in)

<track> Defines text tracks for <video> and <audio>

Tag Description

<canvas> Used to draw graphics, on the fly, via scripting (usually JavaScript)

Page 14: Html 5

New Elements in HTML5 (cont.)

• New Form Elements

Tag Description

<datalist> Specifies a list of pre-defined options for input controls

<keygen> Defines a key-pair generator field (for forms)

<output> Defines the result of a calculation

Page 15: Html 5

Removed Elements• The following HTML 4.01 elements are removed from HTML5:• <acronym>• <applet>• <basefont>• <big>• <center>• <dir>• <font>• <frame>• <frameset>• <noframes>• <strike>• <tt>

Page 16: Html 5

PART II – New Features

• Video/Audio on the Web• HTML5 Drag and Drop• HTML5 Canvas• HTML5 Inline SVG• HTML5 Geolocation• HTML5 Web Storage• HTML5 Application Cache• HTML5 Web Workers• HTML Server-Sent Events• HTML5 Form Elements

Page 17: Html 5

Video/Audio on the Web

• <video> • <audio>

Page 18: Html 5

Video on the Web

• Browsers support: • HTML5 video demo• Currently, there are 3 supported video formats for

the <video> element: MP4, WebM, and Ogg:

Browser MP4 WebM Ogg

Internet Explorer 9 YES NO NO

Firefox 4.0 NO YES YES

Google Chrome 6 YES YES YES

Apple Safari 5 YES NO NO

Opera 10.6 NO YES YES

Page 19: Html 5

HTML5 <video> - Methods, Properties, and Events

Methods Properties Events

play() currentSrc play

pause() currentTime pause

load() videoWidth progress

canPlayType videoHeight error

duration timeupdate

ended ended

error abort

paused empty

muted emptied

seeking waiting

volume loadedmetadata

height

width

Page 20: Html 5

Audio on the Web

• Browsers support: • HTML5 audio• Currently, there are 3 supported file formats for the

<audio> element: MP3, Wav, and Ogg:

Browser MP3 Wav Ogg

Internet Explorer 9 YES NO NO

Firefox 4.0 NO YES YES

Google Chrome 6 YES YES YES

Apple Safari 5 YES YES NO

Opera 10.6 NO YES YES

Page 21: Html 5

HTML5 Drag and Drop

• Browsers support: • Note: Drag and drop does not work in Safari 5.1.2.

• Drag and Drop Demo• Desktop drag in, drag out (only available in Chrome)

Page 22: Html 5

HTML5 Canvas

• Browsers support:

Page 23: Html 5

HTML5 Canvas

• Create a Canvas– A canvas is specified with the <canvas> element.– Specify the id, width, and height of the <canvas> element:

<canvas id="myCanvas" width="200" height="100"></canvas>

• Draw With JavaScript– The <canvas> element has no drawing abilities of its own.– All drawing must be done inside a JavaScript:

<script type="text/javascript"> var c=document.getElementById("myCanvas"); var ctx=c.getContext("2d"); ctx.fillStyle="#FF0000"; ctx.fillRect(0,0,150,75); </script>

• Canvas demo

Page 24: Html 5

HTML5 Inline SVG

• SVG stands for Scalable Vector Graphics.• SVG is used to define vector-based graphics for the

Web.• SVG defines the graphics in XML format.• SVG graphics do NOT lose any quality if they are

zoomed or resized.• Every element and every attribute in SVG files can be

animated• Browsers support: • SVG Demo

Page 25: Html 5

HTML5 Geolocation

• Browsers Support:• Note: Geolocation is much more accurate for devices with GPS, like

iPhone.• Geolocation demo

Page 26: Html 5

HTML5 Web Storage

• Browsers support:• Note: Internet Explorer 7 and earlier versions, do not support web

storage.

Page 27: Html 5

localStorage

• ExamplelocalStorage.lastname="Smith";document.getElementById("result").innerHTML="Last name: "+localStorage.lastname;

• Local storage demo

Page 28: Html 5

sessionStorage

• Example sessionStorage.lastname="Smith"; document.getElementById("result").innerHTML="Last name: "+sessionStorage.lastname;

• SessionStorage Demo

Page 29: Html 5

HTML5 Application Cache

– Offline browsing– Speed – Reduced server load

• Browser Support:• App cache demo• Note: Browsers may have different size limits for cached data (some

browsers have a 5MB limit per site).

Page 30: Html 5

Application cache (cont.)

• To enable application cache, include the manifest attribute in the document's <html> tag:

CACHE MANIFEST# 2012-02-21 v1.0.0/theme.css/logo.gif/main.js

NETWORK:login.asp

FALLBACK:/html5/ /offline.html

Page 31: Html 5

HTML5 Web Workers

• Browsers support:

Page 32: Html 5

Web worker (cont.)• Check Web Worker Support

if(typeof(Worker)!=="undefined"){ // Yes! Web worker support! } else { // Sorry! No Web Worker support.. }

• Create a Web Worker Filevar i=0;function timedCount() { i=i+1; postMessage(i); setTimeout("timedCount()",500);}timedCount();

• Create a Web Worker Objectw=new Worker("demo_workers.js");w.onmessage=function(event){document.getElementById("result").innerHTML=event.data;};

• Terminate a Web Worker w.terminate();

• Web worker demo

Page 33: Html 5

HTML5 Server-Sent Events

• A server-sent event is when a web page automatically gets updates from a server.

• This was also possible before, but the web page would have to ask if any updates were available.

• Browsers Support:

Page 34: Html 5

Server-Sent Events (cont.)• Receive Server-Sent Event Notifications

var source=new EventSource("demo_sse.php");source.onmessage=function(event){

document.getElementById("result").innerHTML+=event.data + "<br />"; };

• Check Server-Sent Events Supportif(typeof(EventSource)!=="undefined"){

// Yes! Server-sent events support! }else{ // Sorry! No server-sent events support.. }

• Server-Side Code<?phpheader('Content-Type: text/event-stream');header('Cache-Control: no-cache');$time = date('r');echo "data: The server time is: {$time}\n\n";flush();?>

Note: Output data Always start with "data: “ Set the "Content-Type" header to "text/event-stream“

• SSE Demo

Page 35: Html 5

HTML5 Form Elements• <input type="color" name="favcolor" />

• <input type="date" name="bday" />

Page 36: Html 5

HTML5 Form Elements• <input type="datetime" name="bdaytime" />

• <input type="email" name="usremail" />

Page 37: Html 5

HTML5 Form Elements• <input type="month" name="bdaymonth" />

• <input type="text" x-webkit-speech />

• <input type="number" name="quantity" min="1" max="5" />

Page 38: Html 5

HTML5 Form Elements• <input type="range" name="points" min="1" max="10" />

• <input type="search" name="googlesearch" />

• <input type="time" name="usr_time" />

• <meter value="2" min="0" max="10">2 out of 10</meter><meter value="0.6">60%</meter>

Page 39: Html 5

HTML5 Form Elements• <progress value="22" max="100"></progress>

• <input type="url" name="homepage" />

• <input type="week" name="year_week" />

Page 40: Html 5

PART III - References

• http://slides.html5rocks.com• http://w3schools.com/html5• http://html5demos.com/• http://diveintohtml5.info


Recommended