introduccion a html5

55
INTRODUCCIÓN A Pablo Garaizar Sagarminaga UniEncounter 2011, Eibar/Ermua

Upload: pablo-garaizar

Post on 26-Jan-2015

10.189 views

Category:

Technology


1 download

DESCRIPTION

Introducción rápida a HTML5, repasando brevemente la historia de HTML, qué APIs se añaden a HTML5, y qué avances en HTML, CSS y JavaScript rodean a este estándar.

TRANSCRIPT

Page 1: Introduccion a HTML5

INTRODUCCIÓN A

Pablo Garaizar SagarminagaUniEncounter 2011, Eibar/Ermua

Page 2: Introduccion a HTML5

Agenda● Breve historia de HTML5.● ¿Qué es y qué no es HTML5?● Novedades en...

● HTML● CSS● JS

● Soporte actual de HTML5

Page 3: Introduccion a HTML5

Breve historia...

Page 4: Introduccion a HTML5

Source: David P. Heitmeyer, CSCI E-12 (Spring 2011), Harvard University

Page 5: Introduccion a HTML5

¿Qué es...

Page 6: Introduccion a HTML5

Timed media

playback

Cross-document messaging

Microdata

Web Storage

Drag& drop

Document editing

Canvas 2D API

Browser history

MIME type and protocol

handler registration

Page 7: Introduccion a HTML5

...y qué no es?

Page 8: Introduccion a HTML5

Web SQL

Database

The Indexed Database

API

File API

Websockets

Geolocation

WebWorkers

SVG CSS3WebGL

Page 9: Introduccion a HTML5

A pesar de esto...

Page 10: Introduccion a HTML5

CSS3JS

APIsHTML5

Page 11: Introduccion a HTML5

Novedades

Page 12: Introduccion a HTML5

En HTML

Page 13: Introduccion a HTML5

Declaración simplificada

<!DOCTYPE HTML PUBLIC "­//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> 

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

<!DOCTYPE html>

Page 14: Introduccion a HTML5

Nueva estructura de documento

Page 15: Introduccion a HTML5

Nueva cabecera

<html><html lang="en">

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

<meta charset="utf­8" />

<link><link rel=”stylesheet|alternate|icon|license|prefetch|nofollow|noreferrer|pingback|search|sidebar|tag”>

Page 16: Introduccion a HTML5

Etiquetas semánticas

<time><time datetime="2011­03­17T17:59:37+01:00" pubdate>  March 17, 2011 5:37pm GMT+1</time>

<mark><p>This is <m>really important</m> to understand HTML5</p>

Page 17: Introduccion a HTML5

Etiquetas semánticas

<meter><p>G­force is<meter value="9.2" min="0" max="19.6" low="9.5" high="10.3" optimum="9.8">9.2</meter>.</p>

<progress><p>Downloaded:   <progress value="1534602" max="4603807">33%</progress></p>

Page 18: Introduccion a HTML5

Multimedia

<audio><audio src="music.mp3"    autoplay loop="3" controls preload />

<video><video width="320" height="240" controls>  <source src="pr6.mp4"  type='video/mp4; codecs="avc1.42E01E, mp4a.40.2"'>  <source src="pr6.webm" type='video/webm; codecs="vp8, vorbis"'>  <source src="pr6.ogv"  type='video/ogg; codecs="theora, vorbis"'></video>

Page 19: Introduccion a HTML5

Canvas

<canvas><canvas id=”area” width=”320” height=”240”></canvas>

<script>function draw() {  var area = document.getElementById("area");  var ctx = area.getContext("2d");  ctx.fillRect(50, 25, 150, 100);}</script>

Se pueden hacer muchas cosas: rectángulos, círculos, elipses, caminos, texto, imágenes, gradientes, transformaciones.

Page 20: Introduccion a HTML5

SVG

<svg><svg id="flag" height="200" xmlns="http://www.w3.org/2000/svg">  <circle id="redcircle" cx="50" cy="50" r="50" fill="red" />  <rect id="redrect" width="300" height="100" fill="white" />  <line x1="0" y1="0" x2="200" y2="100"          style="stroke:red;stroke­width:2"/>  <ellipse cx="100" cy="50" rx="100" ry="50" fill="red" />  <polygon  points="20,10 300,20, 170,50" fill="white" />  <polyline points="0,0 0,20 20,20 20,40 40,40 40,60" fill="red" /></svg>

Page 21: Introduccion a HTML5

Formularios

<input><input  type="search" search box  type="number" spinbox  type="range" slider  type="color" color picker  type="tel" telephone number  type="url" web address  type="email" email address  type="date|time|month|week|datetime"  required autofocus placeholder=”Type here...”/>

Page 22: Introduccion a HTML5

Formularios

<datalist><input type=”text” list="cars" /><datalist id="cars">  <option value="BMW">  <option value="Ford">  <option value="Volvo"></datalist>

<keygen><form action="signup.asp" method="post">  user: <input type="text" name="username" />  encryption: <keygen name="security" />  <input type="submit" /></form>

Page 23: Introduccion a HTML5

Etiquetas interactivas

<menu> + <command><menu>  <command onclick="alert('first!')" label="Do 1st Command"/>  <command onclick="alert('second!')" label="Do 2nd Command"/>  <command onclick="alert('third!')" label="Do 3rd Command"/></menu>

<datagrid><datagrid>  <table ...></datagrid>

Page 24: Introduccion a HTML5

Etiquetas interactivas

<details>Dive into HTML5 <details open>  <legend>Pilgrim, M. (2011)</legend>  <p>    Mark Pilgrim, Dive into HTML5,     <a href=”http://diveintohtml5.org”>updated!</a>.  </p>    </details>

Page 25: Introduccion a HTML5

Otras etiquetas

<figure> + <figcaption><figure>  <img src=”fig1.jpg” title=”Graphic” />  <figcaption>Figure 1. Overall scores.</figcaption></figure>

<wbr><p>You can break the line here<wbr> or here<wbr>, or even here<wbr>.</p>

Page 26: Introduccion a HTML5

En CSS

Page 27: Introduccion a HTML5

Nuevos selectoreshttp://www.456bereastreet.com/archive/200601/css_3_selectors_explained/

E[att^=”val”]E[att$=”val”]E[att*=”val”]

E:rootE:nth­child(n)E:nth­last­child(n)E:nth­of­type(n)E:nth­last­of­type(n)E:last­child

E:first­of­typeE:last­of­typeE:only­childE:only­of­type

E:emptyE:targetE:enabledE:disabledE:checkedE:selection

E:not(selector)E ~ F

Page 28: Introduccion a HTML5

Bordes redondeados

border­radiusborder­top­left­radiusborder­top­right­radiusborder­bottom­right­radiusborder­bottom­left­radius

­webkit­border­radius­webkit­border­top­left­radius­webkit­border­top­right­radius­webkit­border­bottom­right­radius­webkit­border­bottom­left­radius

­moz­border­radius­moz­border­radius­topleft­moz­border­radius­topright­moz­border­radius­bottomright­moz­border­radius­bottomleft

Page 29: Introduccion a HTML5

Transformacioneshttp://css3.bradshawenterprises.com/

#skew {transform:skew(35deg);

}#scale {

transform:scale(1,0.5);}#rotate {

transform:rotate(45deg);}#translate {

transform:translate(10px, 20px);}

#rotate­skew­scale­translate {transform:skew(30deg) scale(1.1,1.1) rotate(40deg) 

translate(10px, 20px);}

Page 30: Introduccion a HTML5

Transiciones

#id {­webkit­transition: all 1s ease­in­out;­moz­transition: all 1s ease­in­out;­o­transition: all 1s ease­in­out;transition: all 1s ease­in­out;

}

Page 31: Introduccion a HTML5

@font-facehttp://www.font-face.com

@font­face {  font­family: <a­remote­font­name>;  src: <source> [,<source>]*;  [font­weight: <weight>];  [font­style: <style>];}

@font­face {  font­family: "Bitstream Vera Serif Bold";  src: url("http://server.com/VeraSeBd.ttf");}   body { font­family: "Bitstream Vera Serif Bold", serif }

Page 32: Introduccion a HTML5

En JS

Page 33: Introduccion a HTML5

Geolocalización

function get_location() {  navigator.geolocation.getCurrentPosition(show_location);}

function show_location(position) {  var latitude = position.coords.latitude;  var longitude = position.coords.longitude;  alert('You are here: ('+latitude+','+longitude+')');}

Page 34: Introduccion a HTML5

Offline / online

function show_status() {  var status = navigator.onLine ? 'Online' : 'Offline';  alert('You are '+status);}

Eventos nuevos:

window.ononlinewindow.onoffline

Page 35: Introduccion a HTML5

Local Storage

var foo = localStorage.getItem("bar");// ...localStorage.setItem("bar", foo);

var foo = localStorage["bar"];// ...localStorage["bar"] = foo;

Algunos navegadores soportan Web SQL Database (WebDB), pero no está estandarizado.

Page 36: Introduccion a HTML5

Web History

history.pushState(json, title, url);

addEvent(window, 'popstate', function (event) {  var data = event.state;  //...});

Page 37: Introduccion a HTML5

Todo esto, ¿para cuándo?

Page 38: Introduccion a HTML5

En teoría, HTML5 no será un estándar hasta 2022

Page 39: Introduccion a HTML5

En la práctica, soportadas muchas cosashttp://www.findmebyip.com/litmus

Page 40: Introduccion a HTML5

Buena práctica: detectar funcionalidades soportadas

Page 41: Introduccion a HTML5

Detección de funcionalidades

function supports_canvas() {  return !!document.createElement('canvas').getContext;  //return Modernizr.canvas;}

function supports_video() {  return !!document.createElement('video').canPlayType;  //return Modernizr.video;}

function supports_ogg_theora_video() {  if (!supports_video()) { return false; }  var v = document.createElement("video");  return v.canPlayType('video/ogg; codecs="theora, vorbis"');  //return Modernizr.video.ogg;}

Page 42: Introduccion a HTML5

Modernizrhttp://www.modernizr.com

Page 43: Introduccion a HTML5

¿Y si no hay soporte?Polyfills

Page 44: Introduccion a HTML5

¿Polyqué? Polyfills ;-)

<!­­[if lt IE 9]><script>  var e = ("abbr,article,aside,audio,canvas,datalist," +    "details,figure,footer,header,hgroup,mark,menu,meter," +    "nav,output,progress,section,time,video").split(',');  for (var i = 0; i < e.length; i++) {    document.createElement(e[i]);  }</script><![endif]­­>

Page 45: Introduccion a HTML5

Polyfillshttps://github.com/Modernizr/Modernizr/wiki/HTML5-Cross-browser-Polyfills

Page 46: Introduccion a HTML5

Para saber más...

Page 47: Introduccion a HTML5

W3Chttp://dev.w3.org/html5/spec/Overview.html

Page 48: Introduccion a HTML5

WHATWGhttp://whatwg.org/html

Page 49: Introduccion a HTML5

Dive into HTML5http://diveintohtml5.org/

Page 50: Introduccion a HTML5

HTML5 Rockshttp://www.html5rocks.com

Page 51: Introduccion a HTML5

Improving the Performance of your HTML5 Apphttp://www.html5rocks.com/tutorials/speed/html5/

Page 52: Introduccion a HTML5

HTML 5 Demos and Exampleshttp://html5demos.com

Page 53: Introduccion a HTML5

Muchas gracias ;-)

Page 54: Introduccion a HTML5

Referencias● Dive into HTML5.● W3Schools.● IBM developer networks.● Quackit.● HTML5 Rocks.● HTML5 Demos and Examples.

Page 55: Introduccion a HTML5

All images are property of their own owners*, content is licensed under a Creative Commons by-sa 3.0 license

* W3C, WHATWG, Dive into HTML5, HTML5 Rocks, Modernizr, FindmebyIP