DevFest Makerere html5 presentation by caesar mukama

80
HTML5 DevFest 2013

description

This presentation explains the relevance of using HTML5 which is one of the Google technologies. It's a basic tutorial designed to encourage students to use HTML5 when developing applications.

Transcript of DevFest Makerere html5 presentation by caesar mukama

Page 1: DevFest Makerere html5 presentation by caesar mukama

HTML5

DevFest 2013

Page 2: DevFest Makerere html5 presentation by caesar mukama

Caesar Mukama

Work as Front End Designer

for MyZiki Ltd.

Contact me at [email protected]

Page 3: DevFest Makerere html5 presentation by caesar mukama
Page 4: DevFest Makerere html5 presentation by caesar mukama

On the menu

● Why HTML5 is important.● Structure● Form Input Types and Tags● 3 New Tags● Features● Error Handling● Summary

Page 5: DevFest Makerere html5 presentation by caesar mukama

What is HTML5?

Page 6: DevFest Makerere html5 presentation by caesar mukama

HTML5 = XHTML + NEW MARKUP + JS APIS

Page 7: DevFest Makerere html5 presentation by caesar mukama

Why is HTML5 important?

Page 8: DevFest Makerere html5 presentation by caesar mukama

New Industry StandardStarting 2014

Page 9: DevFest Makerere html5 presentation by caesar mukama

Reduced DevelopmentTime

Page 10: DevFest Makerere html5 presentation by caesar mukama

Preloaded with someCSS3 Bling

Page 11: DevFest Makerere html5 presentation by caesar mukama

Lots of newFeatures

Page 12: DevFest Makerere html5 presentation by caesar mukama

Mobile Friendly

Page 13: DevFest Makerere html5 presentation by caesar mukama

HTML5 XHTML

Page 14: DevFest Makerere html5 presentation by caesar mukama

HTML5 Structure

Page 15: DevFest Makerere html5 presentation by caesar mukama

XHTML<?xml version="1.0" encoding="utf-8"?>

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

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">

<head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> <title>Page Title</title> <link rel="stylesheet" href="style.css" type="text/css" media="screen" charset="utf-8"/></head>

<body> ...</body>

</html>

Page 16: DevFest Makerere html5 presentation by caesar mukama

… minus XML declaration<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">

<head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> <title>Page Title</title> <link rel="stylesheet" href="style.css" type="text/css" media="screen" charset="utf-8"/></head>

<body> ...</body>

</html>

Page 17: DevFest Makerere html5 presentation by caesar mukama

... minus DOCTYPE attributes<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">

<head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> <title>Page Title</title> <link rel="stylesheet" href="style.css" type="text/css" media="screen" charset="utf-8"/></head>

<body> ...</body>

</html>

Page 18: DevFest Makerere html5 presentation by caesar mukama

… plus short meta content<!DOCTYPE html>

<html>

<head> <meta charset="utf-8"/> <title>Page Title</title> <link rel="stylesheet" href="style.css" type="text/css" media="screen" charset="utf-8"/></head>

<body> ...</body>

</html>

Page 19: DevFest Makerere html5 presentation by caesar mukama

… minus useless definitions<!DOCTYPE html>

<html>

<head> <meta charset="utf-8"/> <title>Page Title</title> <link rel="stylesheet" href="style.css"/></head>

<body> ...</body>

</html>

Page 20: DevFest Makerere html5 presentation by caesar mukama

= HTML5<!DOCTYPE html>

<html>

<head> <meta charset="utf-8"/> <title>Page Title</title> <link rel="stylesheet" href="style.css"/></head>

<body> ...</body>

</html>

Page 21: DevFest Makerere html5 presentation by caesar mukama

That’s why we need HTML5.

Page 22: DevFest Makerere html5 presentation by caesar mukama
Page 23: DevFest Makerere html5 presentation by caesar mukama

28 Tags, 13 Form Input Types

New Tags

article, aside, audio, canvas, command, datalist, details, embed, figcaption, figure, footer, header, hgroup, keygen, mark, meter, nav, output, progress, rp, rt, ruby, section, source, summary, time, video, wbr

New Input Types

color, date, datetime, datetime-local, email, month, number, range, search, tel, time, url, week

Page 24: DevFest Makerere html5 presentation by caesar mukama

Where did they come from?

Page 25: DevFest Makerere html5 presentation by caesar mukama

Source: https://developers.google.com/webmasters/state-of-the-web/2005/classes

Top 20 Class Names

Page 26: DevFest Makerere html5 presentation by caesar mukama

<div class=”header”>

<div class=”header”>

<div class=”section”>

<div class=”article”>

<div class=”footer”>

<div class=”footer”>

<div class=”nav”><div

class=”aside”>

Page 27: DevFest Makerere html5 presentation by caesar mukama

<header>

<header>

<section>

<article>

<footer>

<footer>

<nav><aside>

Page 28: DevFest Makerere html5 presentation by caesar mukama

28 Tags, 13 Form Input Types

New Tags

article, aside, audio, canvas, command, datalist, details, embed, figcaption, figure, footer, header, hgroup, keygen, mark, meter, nav, output, progress, rp, rt, ruby, section, source, summary, time, video, wbr

New Input Types

color, date, datetime, datetime-local, email, month, number, range, search, tel, time, url, week

Page 29: DevFest Makerere html5 presentation by caesar mukama

28 Tags, 13 Form Input Types

New Tags

article, aside, audio, canvas, command, datalist, details, embed, figcaption, figure, footer, header, hgroup, keygen, mark, meter, nav, output, progress, rp, rt, ruby, section, source, summary, time, video, wbr

New Input Types

color, date, datetime, datetime-local, email, month, number, range, search, tel, time, url, week

Page 30: DevFest Makerere html5 presentation by caesar mukama

<input id="event” placeholder="DevFest Makerere"><input id=”firstName” required><input id=”lastName” autofocus pattern=[a-zA-Z]>

Page 31: DevFest Makerere html5 presentation by caesar mukama

<input id="event” placeholder="DevFest Makerere"><input id=”firstName” required><input id=”lastName” autofocus pattern=[a-zA-Z]>

<input type="color" name="favcolor"><input type="date" name="birthday"><input type="datetime" name="bdaytime"><input type="number" name="quantity" min="1" max="5"><input type="range" name="points" min="1" max="10">

Page 32: DevFest Makerere html5 presentation by caesar mukama

<input id="event” placeholder="DevFest Makerere"><input id=”firstName” required><input id=”lastName” autofocus pattern=[a-zA-Z]>

<input type="color" name="favcolor"><input type="date" name="birthday"><input type="datetime" name="bdaytime"><input type="number" name="quantity" min="1" max="5"><input type="range" name="points" min="1" max="10">

… much more.

Page 33: DevFest Makerere html5 presentation by caesar mukama

28 Tags, 13 Form Input Types

New Tags

article, aside, audio, canvas, command, datalist, details, embed, figcaption, figure, footer, header, hgroup, keygen, mark, meter, nav, output, progress, rp, rt, ruby, section, source, summary, time, video, wbr

New Input Types

color, date, datetime, datetime-local, email, month, number, range, search, tel, time, url, week

Page 34: DevFest Makerere html5 presentation by caesar mukama

28 Tags, 13 Form Input Types

New Tags

article, aside, audio, canvas, command, datalist, details, embed, figcaption, figure, footer, header, hgroup, keygen, mark, meter, nav, output, progress, rp, rt, ruby, section, source, summary, time, video, wbr

New Input Types

color, date, datetime, datetime-local, email, month, number, range, search, tel, time, url, week

Page 35: DevFest Makerere html5 presentation by caesar mukama
Page 36: DevFest Makerere html5 presentation by caesar mukama

Why do we need a video and an audio element?

Page 37: DevFest Makerere html5 presentation by caesar mukama

Thousands of audio and video services

Page 38: DevFest Makerere html5 presentation by caesar mukama

was meant for foreign objects

<object> … </object>

Page 39: DevFest Makerere html5 presentation by caesar mukama

was meant for foreign objects

<object> … </object>

but video and audio are NOT foreign

Page 40: DevFest Makerere html5 presentation by caesar mukama
Page 41: DevFest Makerere html5 presentation by caesar mukama
Page 42: DevFest Makerere html5 presentation by caesar mukama

plugins are foreign objects

Page 43: DevFest Makerere html5 presentation by caesar mukama

<video width="320" height="240" controls src="movie.mp4" type="video/mp4" />

Syntax ?

Page 44: DevFest Makerere html5 presentation by caesar mukama

<video width="320" height="240" controls src="movie.mp4" type="video/mp4" />

Syntax ?

Page 45: DevFest Makerere html5 presentation by caesar mukama

<video width="320" height="240" controls src="movie.mp4" type="video/mp4" />

Syntax ?

Page 46: DevFest Makerere html5 presentation by caesar mukama

Correct Syntax

<video width="320" height="240" controls><source src="movie.mp4" type="video/mp4"><source src="movie.ogg" type="video/ogg"><source src="movie.webm" type="video/webm"><object data="movie.mp4" width="320" height="240">

<embed src="movie.swf" width="320" height="240"></object>

</video>

Page 47: DevFest Makerere html5 presentation by caesar mukama

Confused?

Page 48: DevFest Makerere html5 presentation by caesar mukama

Confused?

Page 49: DevFest Makerere html5 presentation by caesar mukama

All browser should have at least 2 new Codes by default:

HTML5 Specifications said...

Page 50: DevFest Makerere html5 presentation by caesar mukama

All browser should have at least 2 new Codes by default:

● Ogg Vorbis for audio● Ogg Theora for video

HTML5 Specifications said...

Page 51: DevFest Makerere html5 presentation by caesar mukama

Google was onboard,Everyone followed

Page 52: DevFest Makerere html5 presentation by caesar mukama

Google was onboard,Everyone followed

BUTApple and Nokia Said No.

Page 53: DevFest Makerere html5 presentation by caesar mukama

MPEG LA

Page 54: DevFest Makerere html5 presentation by caesar mukama

.mp3, .mp4, .m4a, .mpg ...

MPEG LA

Page 55: DevFest Makerere html5 presentation by caesar mukama

● MPEG better quality● Already most widely used● Xiph.com’s BDS license not open source.

Their Suggested alternative● H.264/MPEG most relevant video encoding● MP3, AAC best audio compression and

quality.

Their argument

Page 56: DevFest Makerere html5 presentation by caesar mukama

Audio & video specification is incomplete

Page 57: DevFest Makerere html5 presentation by caesar mukama

What to do ...for now?

● Convert videos to multiple formats● Use multiple sources● Then control with js

Page 58: DevFest Makerere html5 presentation by caesar mukama

FOR NOW!

<video width="320" height="240" controls><source src="movie.mp4" type="video/mp4"><source src="movie.ogg" type="video/ogg"><source src="movie.webm" type="video/webm"><object data="movie.mp4" width="320" height="240">

<embed src="movie.swf" width="320" height="240"></object>

</video>

Page 59: DevFest Makerere html5 presentation by caesar mukama

Canvas

Page 60: DevFest Makerere html5 presentation by caesar mukama

Just like MS Paint...

Page 61: DevFest Makerere html5 presentation by caesar mukama

… in your browser.

Page 62: DevFest Makerere html5 presentation by caesar mukama

Paint with javascript instead of a brush

Page 63: DevFest Makerere html5 presentation by caesar mukama

Paint with javascript instead of a brush<!DOCTYPE html>

<html>

<script>

var c=document.getElementById("myCanvas");

var ctx=c.getContext("2d");

ctx.beginPath();

ctx.arc(95,50,40,0,2*Math.PI);

ctx.stroke();

ctx.fill();

</script>

<body>

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

</body>

</html>

Page 64: DevFest Makerere html5 presentation by caesar mukama

Paint with javascript instead of a brush<!DOCTYPE html>

<html>

<script>

var c=document.getElementById("myCanvas");

var ctx=c.getContext("2d");

ctx.beginPath();

ctx.arc(95,50,40,0,2*Math.PI);

ctx.stroke();

ctx.fill();

</script>

<body>

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

</body>

</html>

Page 65: DevFest Makerere html5 presentation by caesar mukama

What can I do with Canvas?

Besides .

Page 66: DevFest Makerere html5 presentation by caesar mukama

Other 2D Drawings

Page 67: DevFest Makerere html5 presentation by caesar mukama

Rende 3D (via Web GL)

Page 68: DevFest Makerere html5 presentation by caesar mukama

Error Handling( in brief )

Page 69: DevFest Makerere html5 presentation by caesar mukama

“Tag Soup”

Page 70: DevFest Makerere html5 presentation by caesar mukama

● 90% of pages on the web are malformed.● In XHTML, such pages break

“Tag Soup”

Page 71: DevFest Makerere html5 presentation by caesar mukama

● 90% of pages on the web are malformed.● In XHTML, such pages break

● Tag Soup means HTML5 runs malformed pages on purpose then corrects them.

“Tag Soup”

Page 72: DevFest Makerere html5 presentation by caesar mukama

Modernizr.js

Page 73: DevFest Makerere html5 presentation by caesar mukama

Modernizr.js

● a JavaScript library● detects HTML5 and CSS3 features ● in the user’s browser.

Page 74: DevFest Makerere html5 presentation by caesar mukama

Modernizr.js

Plain Javascript

function getSupportedTransform() { var prefixes = 'transform WebkitTransform MozTransform OTransform msTransform'.split(' '); for(var i = 0; i < prefixes.length; i++) { if(document.createElement('div').style[prefixes[i]] !== undefined) { return prefixes[i]; } } return false;}

if ( getSupportedTransform() ) {

// Browser supports CSS3 Transforms

}

Page 75: DevFest Makerere html5 presentation by caesar mukama

Modernizr.js

Plain Javascript

function getSupportedTransform() { var prefixes = 'transform WebkitTransform MozTransform OTransform msTransform'.split(' '); for(var i = 0; i < prefixes.length; i++) { if(document.createElement('div').style[prefixes[i]] !== undefined) { return prefixes[i]; } } return false;}

if ( getSupportedTransform() ) {

// Browser supports CSS3 Transforms

}

With Modernizer

if ( Modernizer. csstransforms ) {

// Browser supports CSS3 Transforms

}

Page 76: DevFest Makerere html5 presentation by caesar mukama

HTML5 is w i d e r

Page 77: DevFest Makerere html5 presentation by caesar mukama

Play Time

Page 78: DevFest Makerere html5 presentation by caesar mukama

Demoslides.html5rocks.com

Page 79: DevFest Makerere html5 presentation by caesar mukama

slides.html5rocks.comdiveintohtml5.com

html5boilerplate.comw3.org

Bookmarks

Page 80: DevFest Makerere html5 presentation by caesar mukama

Caesar Mukama

Contact me at [email protected]

Questions?