SlideShare ist ein Scribd-Unternehmen logo
1 von 64
HTML5
Jamshid Hashimi
Trainer, Cresco Solution
http://www.jamshidhashimi.com
jamshid@netlinks.af
@jamshidhashimi
ajamshidhashimi
Afghanistan Workforce
Development Program
Agenda
• HTML5 Introduction
• HTML5 New Elements
• HTML5 Canvas
• HTML5 SVG
• HTML5 Drag/Drop
• HTML5 Geolocation
• HTML5 Video
• HTML5 Audio
• HTML5 Input Types
Agenda
• HTML5 Form Elements
• HTML5 Form Attributes
• HTML5 Semantic Elements
• HMTL5 Web Storage
• HMTL5 Application Cache
• HMTL5 Web Workers
HTML5 Introduction
• What is HTML5?
– HTML5 will be the standard for HTML
– HTML 4.01 came in 1999. Web changed a lot!
– HTML5 is still work in progress
– Major browsers support HTML5 elements & API
• How Did HTML5 Get Started?
– Cooperation between World Wide Web
Consortium (W3C) and Web Hypertext Application
Technology Working Group (WHATWG)
HTML5 Introduction
• The HTML5 <!DOCTYPE>
– There is only one <!DOCTYPE> declaration. Simple
<!DOCTYPE html>
HTML5 Introduction
• Minimum HTML5 Document
<!DOCTYPE html>
<html>
<head>
<title>Title of the document</title>
</head>
<body>
The content of the document......
</body>
</html>
HTML5 Introduction
• HTML5 New Features
– The <canvas> element for 2D drawing
– The <video> and <audio> elements for media
playback
– Support for local storage
– New content-specific elements, like <article>,
<footer>, <header>, <nav>, <section>
– New form controls, like calendar, date, time,
email, url, search
HTML5 Introduction
• Browser Support for HTML5
– Not full standard!
– No browser has full support
– In a continuous development
(Chrome, Safari, Internet Explorer, Firefox, Opera)
HTML5 New Elements
• Use of internet changed a lot since HTML 4.01
(1999)
• Several HTML 4.01 elements are obsolete, never
used or never used the way they were intended
• To better handle todays internet, HTML5 brings
new changes: New elements for drawing
graphics, adding media content, better page
structure, better form handling, and several APIs
to drag/drop elements, find Geolocation, include
web storage, application cache, web workers, etc.
HTML5 New Elements
HTML5 New Elements
HTML5 New Elements
HTML5 New Elements
HTML5 New Elements
HTML5 New Elements
• Removed Elements
– <acronym>
– <applet>
– <basefont>
– <big>
– <center>
– <dir>
– <font>
– <frame>
– <frameset>
– <noframes>
– <strike>
– <tt>
HTML5 Canvas
• The <canvas> element is used to draw graphics,
on the fly, on a web page.
• What is Canvas?
– The HTML5 <canvas> element is used to draw
graphics, on the fly, via scripting (usually JavaScript).
– The <canvas> element is only a container for graphics.
You must use a script to actually draw the graphics.
– Canvas has several methods for drawing paths, boxes,
circles, characters, and adding images.
HTML5 Canvas
• Browser Support
– Internet Explorer 9+, Firefox, Opera, Chrome, and
Safari support the <canvas> element.
– Note: Internet Explorer 8 and earlier versions, do
not support the <canvas> element.
• Creating a Canvas
<canvas id="myCanvas" width="200"
height="100"></canvas>
HTML5 Canvas
• Tip: You can have multiple <canvas> elements
on one HTML page.
• Canvas example:
<canvas id="myCanvas" width="200"
height="100"
style="border:1px solid #000000;">
</canvas>
HTML5 Canvas
• Draw Onto The Canvas With Javascript
<script>
var c=document.getElementById("myCanvas");
var ctx=c.getContext("2d");
ctx.fillStyle="#FF0000";
ctx.fillRect(0,0,150,75);
</script>
HTML5 Canvas
• Canvas Coordinates
• This means: Start at the upper-left corner (0,0)
and draw a 150x75 pixels rectangle.
HTML5 Canvas
• Canvas Paths
– To draw straight lines on a canvas, we will use the
following two methods:
• moveTo(x,y) defines the starting point of the line
• lineTo(x,y) defines the ending point of the line
– To actually draw the line, we must use one of the
"ink" methods, like stroke().
var c=document.getElementById("myCanvas");
var ctx=c.getContext("2d");
ctx.moveTo(0,0);
ctx.lineTo(200,100);
ctx.stroke();
HTML5 Canvas
• To draw a circle on a canvas, we will use the
following method:
– arc(x,y,r,start,stop)
• To actually draw the circle, we must use one
of the "ink" methods, like stroke() or fill().
var c=document.getElementById("myCanvas");
var ctx=c.getContext("2d");
ctx.beginPath();
ctx.arc(95,50,40,0,2*Math.PI);
ctx.stroke();
HTML5 Canvas
• To draw text on a canvas, the most important
property and methods are:
– font - defines the font properties for text
– fillText(text,x,y) - Draws "filled" text on the canvas
– strokeText(text,x,y) - Draws text on the canvas (no
fill)
Using fillText():
var c=document.getElementById("myCanvas");
var ctx=c.getContext("2d");
ctx.font="30px Arial";
ctx.fillText("Hello World",10,50);
HTML5 Canvas
Using strokeText():
var c=document.getElementById("myCanvas");
var ctx=c.getContext("2d");
ctx.font="30px Arial";
ctx.strokeText("Hello World",10,50);
HTML5 SVG
• HTML5 has support for inline SVG.
• What is 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
– SVG is a W3C recommendation
HTML5 SVG
• Advantages of using SVG over other image
formats (like JPEG and GIF) are:
– SVG images can be created and edited with any text
editor
– SVG images can be searched, indexed, scripted, and
compressed
– SVG images are scalable
– SVG images can be printed with high quality at any
resolution
– SVG images are zoomable (and the image can be
zoomed without degradation)
HTML5 SVG
• Internet Explorer
9+, Firefox, Opera, Chrome, and Safari support
inline SVG.
• Embed SVG Directly Into HTML Pages<!DOCTYPE html>
<html>
<body>
<svg xmlns="http://www.w3.org/2000/svg"
version="1.1" height="190">
<polygon points="100,10 40,180 190,60
10,60 160,180"
style="fill:lime;stroke:purple;stroke-
width:5;fill-rule:evenodd;">
</svg>
</body>
</html>
HTML5 SVG
• Differences Between SVG and Canvas
– SVG is a language for describing 2D graphics in XML.
– Canvas draws 2D graphics, on the fly (with a JavaScript).
– SVG is XML based, which means that every element is available
within the SVG DOM. You can attach JavaScript event handlers
for an element.
– In SVG, each drawn shape is remembered as an object. If
attributes of an SVG object are changed, the browser can
automatically re-render the shape.
– Canvas is rendered pixel by pixel. In canvas, once the graphic is
drawn, it is forgotten by the browser. If its position should be
changed, the entire scene needs to be redrawn, including any
objects that might have been covered by the graphic.
HTML5 Canvas
HTML5 Drag & Drop
• Drag and drop is a part of the HTML5
standard.
• Drag and drop is a very common feature. It is
when you "grab" an object and drag it to a
different location.
• In HTML5, drag and drop is part of the
standard, and any element can be draggable.
• Internet Explorer 9+, Firefox, Opera, Chrome,
and Safari support drag and drop.
HTML5 Drag & Drop
<!DOCTYPE HTML>
<html>
<head>
<script>
function allowDrop(ev)
{
ev.preventDefault();
}
function drag(ev)
{
ev.dataTransfer.setData("Text",ev.target.id);
}
function drop(ev)
{
ev.preventDefault();
var data=ev.dataTransfer.getData("Text");
ev.target.appendChild(document.getElementById(data));
}
</script>
</head>
<body>
<div id="div1" ondrop="drop(event)"
ondragover="allowDrop(event)"></div>
<img id="drag1" src="img_logo.gif" draggable="true"
ondragstart="drag(event)" width="336" height="69”>
</body>
</html>
HTML5 Geolocation
• HTML5 Geolocation is used to locate a user's position.
• The HTML5 Geolocation API is used to get the
geographical position of a user.
• Since this can compromise user privacy, the position is
not available unless the user approves it.
• Browser Support
– Internet Explorer 9+, Firefox, Chrome, Safari and Opera
support Geolocation.
– Note: Geolocation is much more accurate for devices with
GPS, like iPhone.
HTML5 Geolocation
<script>
var x=document.getElementById("demo");
function getLocation()
{
if (navigator.geolocation)
{
navigator.geolocation.getCurrentPosition(showPosition);
}
else
{
x.innerHTML="Geolocation is not supported by this
browser.";
}
}
function showPosition(position)
{
x.innerHTML="Latitude: " + position.coords.latitude +
"<br>Longitude: " + position.coords.longitude;
}
</script>
HTML5 Geolocation
function showError(error)
{
switch(error.code)
{
case error.PERMISSION_DENIED:
x.innerHTML="User denied the request for Geolocation."
break;
case error.POSITION_UNAVAILABLE:
x.innerHTML="Location information is unavailable."
break;
case error.TIMEOUT:
x.innerHTML="The request to get user location timed out."
break;
case error.UNKNOWN_ERROR:
x.innerHTML="An unknown error occurred."
break;
}
}
HTML5 Geolocation
• Displaying the result in a map
function showPosition(position)
{
var
latlon=position.coords.latitude+","+position.coords.lon
gitude;
var
img_url="http://maps.googleapis.com/maps/api/staticmap?
center="
+latlon+"&zoom=14&size=400x300&sensor=false";
document.getElementById("mapholder").innerHTML="<im
g src='"+img_url+"'>";
}
HTML5 Video
• Many modern websites show videos. HTML5 provides a
standard for showing them.
• Until now, there has not been a standard for showing a
video/movie on a web page.
• Today, most videos are shown through a plug-in (like flash).
However, different browsers may have different plug-ins.
• HTML5 defines a new element which specifies a standard
way to embed a video/movie on a web page: the <video>
element.
• Internet Explorer 9+, Firefox, Opera, Chrome, and Safari
support the <video> element.
– Note: Internet Explorer 8 and earlier versions, do not support
the <video> element.
HTML5 Video
<video width="320" height="240" controls>
<source src="movie.mp4" type="video/mp4">
<source src="movie.ogg" type="video/ogg">
Your browser does not support the video tag.
</video>
HTML5 Video
<!DOCTYPE html>
<html>
<body>
<script>
var myVideo=document.getElementById("video1");
function playPause()
{
if (myVideo.paused)
myVideo.play();
else
myVideo.pause();
}
function makeBig()
{
myVideo.width=560;
}
function makeSmall()
{
myVideo.width=320;
}
function makeNormal()
{
myVideo.width=420;
}
</script>
</body>
</html>
HTML5 Audio
• HTML5 provides a standard for playing audio files.
• Until now, there has not been a standard for playing audio
files on a web page.
• Today, most audio files are played through a plug-in (like
flash). However, different browsers may have different
plug-ins.
• HTML5 defines a new element which specifies a standard
way to embed an audio file on a web page: the <audio>
element.
• Internet Explorer 9+, Firefox, Opera, Chrome, and Safari
support the <audio> element.
– Note: Internet Explorer 8 and earlier versions, do not support
the <audio> element.
HTML5 Audio
• HTML5 Audio – How it Works
<audio controls>
<source src="horse.ogg" type="audio/ogg">
<source src="horse.mp3"
type="audio/mpeg">
Your browser does not support the audio
element.
</audio>
HTML5 Audio
HTML5 Input Types
• HTML5 has several new input types for forms. These new features allow better
input control and validation.
– color
– date
– datetime
– datetime-local
– email
– month
– number
– range
– search
– tel
– time
– url
– week
• Note: Not all major browsers support all the new input types. However, you can
already start using them; If they are not supported, they will behave as regular text
fields.
HTML5 Form Elements
• HTML5 has the following new form elements:
– <datalist>
– <keygen>
– <output>
• Note: Not all major browsers support all the
new form elements. However, you can already
start using them; If they are not supported,
they will behave as regular text fields.
HTML5 Form Elements
• <datalist>
– HTML5 <datalist> Element
– The <datalist> element specifies a list of pre-
defined options for an <input> element.
– The <datalist> element is used to provide an
"autocomplete" feature on <input> elements.
Users will see a drop-down list of pre-defined
options as they input data.
– Use the <input> element's list attribute to bind it
together with a <datalist> element.
HTML5 Form Elements
<input list="browsers">
<datalist id="browsers">
<option value="Internet Explorer">
<option value="Firefox">
<option value="Chrome">
<option value="Opera">
<option value="Safari">
</datalist>
HTML5 Form Elements
• <keygen>
– The purpose of the <keygen> element is to provide a
secure way to authenticate users.
– The <keygen> tag specifies a key-pair generator field
in a form.
– When the form is submitted, two keys are generated,
one private and one public.
– The private key is stored locally, and the public key is
sent to the server. The public key could be used to
generate a client certificate to authenticate the user in
the future.
HTML5 Form Elements
<form action="demo_keygen.asp" method="get">
Username: <input type="text" name="usr_name">
Encryption: <keygen name="security">
<input type="submit">
</form>
HTML5 Form Elements
• <output>
– The <output> element represents the result of a
calculation (like one performed by a script).
<form
oninput="x.value=parseInt(a.value)+parseInt
(b.value)">0
<input type="range" id="a" value="50">100 +
<input type="number" id="b" value="50">=
<output name="x" for="a b"></output>
</form>
HTML5 New Form Elements
• HTML5 has several new attributes for <form> and <input>.
• New attributes for <form>:
– autocomplete
– Novalidate
• New attributes for <input>:
– autocomplete
– autofocus
– form
– formaction
– formenctype
– formmethod
– formnovalidate
– formtarget
– height and width
– list
– min and max
– multiple
– pattern (regexp)
– placeholder
– required
– step
HTML5 Semantic Elements
• What Are Semantic Elements?
– A semantic element clearly describes its meaning
to both the browser and the developer.
– Examples of non-semantic elements: <div> and
<span> - Tells nothing about its content.
– Examples of semantic elements: <form>, <table>,
and <img> - Clearly defines its content.
– Internet Explorer 9+, Firefox, Chrome, Safari and
Opera supports the semantic elements described
in this chapter.
HTML5 Semantic Elements
HTML5 Web Storage
• What is HTML5 Web Storage?
– With HTML5, web pages can store data locally within the
user's browser.
– Earlier, this was done with cookies. However, Web Storage
is more secure and faster. The data is not included with
every server request, but used ONLY when asked for. It is
also possible to store large amounts of data, without
affecting the website's performance.
– The data is stored in key/value pairs, and a web page can
only access data stored by itself.
– Web storage is supported in Internet Explorer 8+, Firefox,
Opera, Chrome, and Safari.
HTML5 Web Storage
• localStorage and sessionStorage
– There are two new objects for storing data on the
client:
• localStorage - stores data with no expiration date
• sessionStorage - stores data for one session
– Before using web storage, check browser support
for localStorage and sessionStorage:
if(typeof(Storage)!=="undefined")
{
// Yes! localStorage and sessionStorage support!
// Some code.....
}
else
{
// Sorry! No web storage support..
}
HTML5 Web Storage
• The localStorage Object
– The localStorage object stores the data with no
expiration date. The data will not be deleted when
the browser is closed, and will be available the
next day, week, or year.
localStorage.lastname="Smith";
document.getElementById("result").innerHTML
="Last name: "
+ localStorage.lastname;
HTML5 Web Storage
• The sessionStorage Object
– The sessionStorage object is equal to the
localStorage object, except that it stores the data
for only one session. The data is deleted when the
user closes the browser window.
if (sessionStorage.clickcount)
{
sessionStorage.clickcount=Number(sessionStorage.clickcount)+1;
}
else
{
sessionStorage.clickcount=1;
}
document.getElementById("result").innerHTML="You have clicked
the button " + sessionStorage.clickcount + " time(s) in this
session.";
HTML5 Application Cache
• With HTML5 it is easy to make an offline version of a
web application, by creating a cache manifest file.
• HTML5 introduces application cache, which means that
a web application is cached, and accessible without an
internet connection.
• Application cache gives an application three
advantages:
– Offline browsing - users can use the application when
they're offline
– Speed - cached resources load faster
– Reduced server load - the browser will only download
updated/changed resources from the server
HTML5 Application Cache
<!DOCTYPE HTML>
<html manifest="demo.appcache">
<body>
The content of the document......
</body>
</html>
CACHE MANIFEST
/theme.css
/logo.gif
/main.js
CACHE MANIFEST
/theme.css
/logo.gif
/main.js
FALLBACK:
/html/ /offline.html
HTML5 Web Workers
• A web worker is a JavaScript running in the
background, without affecting the performance of the
page.
• When executing scripts in an HTML page, the page
becomes unresponsive until the script is finished.
• A web worker is a JavaScript that runs in the
background, independently of other scripts, without
affecting the performance of the page. You can
continue to do whatever you want: clicking, selecting
things, etc., while the web worker runs in the
background.
HTML5 Web Workers
<p>Count numbers: <output id="result"></output></p>
<button onclick="startWorker()">Start Worker</button>
<button onclick="stopWorker()">Stop Worker</button>
<br><br>
<script>
var w;
function startWorker()
{
if(typeof(Worker)!=="undefined")
{
if(typeof(w)=="undefined")
{
w=new Worker("demo_workers.js");
}
w.onmessage = function (event) {
document.getElementById("result").innerHTML=event.data;
};
}
else
{
document.getElementById("result").innerHTML="Sorry, your browser does not
support Web Workers...";
}
}
function stopWorker()
{
w.terminate();
}
</script>
HTML5 Web Workers
var i=0;
function timedCount()
{
i=i+1;
postMessage(i);
setTimeout("timedCount()",500);
}
timedCount();
Demo_workers.js
QUESTIONS?

Weitere ähnliche Inhalte

Was ist angesagt?

Lab #2: Introduction to Javascript
Lab #2: Introduction to JavascriptLab #2: Introduction to Javascript
Lab #2: Introduction to JavascriptWalid Ashraf
 
Html 5 New Features
Html 5 New FeaturesHtml 5 New Features
Html 5 New FeaturesAta Ebrahimi
 
Complete Lecture on Css presentation
Complete Lecture on Css presentation Complete Lecture on Css presentation
Complete Lecture on Css presentation Salman Memon
 
javascript objects
javascript objectsjavascript objects
javascript objectsVijay Kalyan
 
jQuery Tutorial For Beginners | Developing User Interface (UI) Using jQuery |...
jQuery Tutorial For Beginners | Developing User Interface (UI) Using jQuery |...jQuery Tutorial For Beginners | Developing User Interface (UI) Using jQuery |...
jQuery Tutorial For Beginners | Developing User Interface (UI) Using jQuery |...Edureka!
 
HTML CSS & Javascript
HTML CSS & JavascriptHTML CSS & Javascript
HTML CSS & JavascriptDavid Lindkvist
 
JavaScript - Chapter 11 - Events
 JavaScript - Chapter 11 - Events  JavaScript - Chapter 11 - Events
JavaScript - Chapter 11 - Events WebStackAcademy
 
JavaScript - Chapter 8 - Objects
 JavaScript - Chapter 8 - Objects JavaScript - Chapter 8 - Objects
JavaScript - Chapter 8 - ObjectsWebStackAcademy
 
JavaScript & Dom Manipulation
JavaScript & Dom ManipulationJavaScript & Dom Manipulation
JavaScript & Dom ManipulationMohammed Arif
 
Loops PHP 04
Loops PHP 04Loops PHP 04
Loops PHP 04Spy Seat
 

Was ist angesagt? (20)

Css3
Css3Css3
Css3
 
Lab #2: Introduction to Javascript
Lab #2: Introduction to JavascriptLab #2: Introduction to Javascript
Lab #2: Introduction to Javascript
 
Html 5 New Features
Html 5 New FeaturesHtml 5 New Features
Html 5 New Features
 
html-css
html-csshtml-css
html-css
 
Complete Lecture on Css presentation
Complete Lecture on Css presentation Complete Lecture on Css presentation
Complete Lecture on Css presentation
 
javascript objects
javascript objectsjavascript objects
javascript objects
 
jQuery Tutorial For Beginners | Developing User Interface (UI) Using jQuery |...
jQuery Tutorial For Beginners | Developing User Interface (UI) Using jQuery |...jQuery Tutorial For Beginners | Developing User Interface (UI) Using jQuery |...
jQuery Tutorial For Beginners | Developing User Interface (UI) Using jQuery |...
 
Css ppt
Css pptCss ppt
Css ppt
 
Java script
Java scriptJava script
Java script
 
HTML CSS & Javascript
HTML CSS & JavascriptHTML CSS & Javascript
HTML CSS & Javascript
 
jQuery for beginners
jQuery for beginnersjQuery for beginners
jQuery for beginners
 
JavaScript - Chapter 11 - Events
 JavaScript - Chapter 11 - Events  JavaScript - Chapter 11 - Events
JavaScript - Chapter 11 - Events
 
Css Ppt
Css PptCss Ppt
Css Ppt
 
jQuery
jQueryjQuery
jQuery
 
Css box-model
Css box-modelCss box-model
Css box-model
 
JavaScript - Chapter 8 - Objects
 JavaScript - Chapter 8 - Objects JavaScript - Chapter 8 - Objects
JavaScript - Chapter 8 - Objects
 
jQuery
jQueryjQuery
jQuery
 
JavaScript & Dom Manipulation
JavaScript & Dom ManipulationJavaScript & Dom Manipulation
JavaScript & Dom Manipulation
 
JQuery introduction
JQuery introductionJQuery introduction
JQuery introduction
 
Loops PHP 04
Loops PHP 04Loops PHP 04
Loops PHP 04
 

Ähnlich wie New Elements & Features in HTML5

HTML5: An Introduction To Next Generation Web Development
HTML5: An Introduction To Next Generation Web DevelopmentHTML5: An Introduction To Next Generation Web Development
HTML5: An Introduction To Next Generation Web DevelopmentTilak Joshi
 
WHAT IS HTML5? (at CSS Nite Osaka)
WHAT IS HTML5? (at CSS Nite Osaka)WHAT IS HTML5? (at CSS Nite Osaka)
WHAT IS HTML5? (at CSS Nite Osaka)Shumpei Shiraishi
 
HTML 5 - Overview
HTML 5 - OverviewHTML 5 - Overview
HTML 5 - OverviewMarcelio Leal
 
HTML5 & CSS3 refresher for mobile apps
HTML5 & CSS3 refresher for mobile appsHTML5 & CSS3 refresher for mobile apps
HTML5 & CSS3 refresher for mobile appsIvano Malavolta
 
JavaONE 2012 Using Java with HTML5 and CSS3
JavaONE 2012 Using Java with HTML5 and CSS3JavaONE 2012 Using Java with HTML5 and CSS3
JavaONE 2012 Using Java with HTML5 and CSS3Helder da Rocha
 
Jsf2 html5-jazoon
Jsf2 html5-jazoonJsf2 html5-jazoon
Jsf2 html5-jazoonRoger Kitain
 
About Best friends - HTML, CSS and JS
About Best friends - HTML, CSS and JSAbout Best friends - HTML, CSS and JS
About Best friends - HTML, CSS and JSNaga Harish M
 
Html5 on Mobile(For Developer)
Html5 on Mobile(For Developer)Html5 on Mobile(For Developer)
Html5 on Mobile(For Developer)Adam Lu
 
Familiar HTML5 - 事例とサンプルコードから学ぶ 身近で普通に使わているHTML5
Familiar HTML5 - 事例とサンプルコードから学ぶ 身近で普通に使わているHTML5Familiar HTML5 - 事例とサンプルコードから学ぶ 身近で普通に使わているHTML5
Familiar HTML5 - 事例とサンプルコードから学ぶ 身近で普通に使わているHTML5Sadaaki HIRAI
 
Html5 CSS3 jQuery Basic
Html5 CSS3 jQuery BasicHtml5 CSS3 jQuery Basic
Html5 CSS3 jQuery BasicRavi Yelluripati
 

Ähnlich wie New Elements & Features in HTML5 (20)

Html5
Html5Html5
Html5
 
Html5
Html5Html5
Html5
 
Html5
Html5Html5
Html5
 
HTML5: An Introduction To Next Generation Web Development
HTML5: An Introduction To Next Generation Web DevelopmentHTML5: An Introduction To Next Generation Web Development
HTML5: An Introduction To Next Generation Web Development
 
Html5 - Novas Tags na PrĂĄtica!
Html5 - Novas Tags na PrĂĄtica!Html5 - Novas Tags na PrĂĄtica!
Html5 - Novas Tags na PrĂĄtica!
 
Html5
Html5Html5
Html5
 
WHAT IS HTML5? (at CSS Nite Osaka)
WHAT IS HTML5? (at CSS Nite Osaka)WHAT IS HTML5? (at CSS Nite Osaka)
WHAT IS HTML5? (at CSS Nite Osaka)
 
What is HTML5
What is HTML5What is HTML5
What is HTML5
 
Html5
Html5Html5
Html5
 
HTML 5 - Overview
HTML 5 - OverviewHTML 5 - Overview
HTML 5 - Overview
 
HTML5 & CSS3 refresher for mobile apps
HTML5 & CSS3 refresher for mobile appsHTML5 & CSS3 refresher for mobile apps
HTML5 & CSS3 refresher for mobile apps
 
JavaONE 2012 Using Java with HTML5 and CSS3
JavaONE 2012 Using Java with HTML5 and CSS3JavaONE 2012 Using Java with HTML5 and CSS3
JavaONE 2012 Using Java with HTML5 and CSS3
 
Jsf2 html5-jazoon
Jsf2 html5-jazoonJsf2 html5-jazoon
Jsf2 html5-jazoon
 
About Best friends - HTML, CSS and JS
About Best friends - HTML, CSS and JSAbout Best friends - HTML, CSS and JS
About Best friends - HTML, CSS and JS
 
Html5 on Mobile(For Developer)
Html5 on Mobile(For Developer)Html5 on Mobile(For Developer)
Html5 on Mobile(For Developer)
 
Html5 more than just html5 v final
Html5  more than just html5 v finalHtml5  more than just html5 v final
Html5 more than just html5 v final
 
Html5
Html5Html5
Html5
 
Familiar HTML5 - 事例とサンプルコードから学ぶ 身近で普通に使わているHTML5
Familiar HTML5 - 事例とサンプルコードから学ぶ 身近で普通に使わているHTML5Familiar HTML5 - 事例とサンプルコードから学ぶ 身近で普通に使わているHTML5
Familiar HTML5 - 事例とサンプルコードから学ぶ 身近で普通に使わているHTML5
 
Html 5
Html 5Html 5
Html 5
 
Html5 CSS3 jQuery Basic
Html5 CSS3 jQuery BasicHtml5 CSS3 jQuery Basic
Html5 CSS3 jQuery Basic
 

Mehr von Jamshid Hashimi

Week 2: Getting Your Hands Dirty – Part 2
Week 2: Getting Your Hands Dirty – Part 2Week 2: Getting Your Hands Dirty – Part 2
Week 2: Getting Your Hands Dirty – Part 2Jamshid Hashimi
 
Week 1: Getting Your Hands Dirty - Part 1
Week 1: Getting Your Hands Dirty - Part 1Week 1: Getting Your Hands Dirty - Part 1
Week 1: Getting Your Hands Dirty - Part 1Jamshid Hashimi
 
Introduction to C# - Week 0
Introduction to C# - Week 0Introduction to C# - Week 0
Introduction to C# - Week 0Jamshid Hashimi
 
RIST - Research Institute for Science and Technology
RIST - Research Institute for Science and TechnologyRIST - Research Institute for Science and Technology
RIST - Research Institute for Science and TechnologyJamshid Hashimi
 
How Coding Can Make Your Life Better
How Coding Can Make Your Life BetterHow Coding Can Make Your Life Better
How Coding Can Make Your Life BetterJamshid Hashimi
 
Tips for Writing Better Code
Tips for Writing Better CodeTips for Writing Better Code
Tips for Writing Better CodeJamshid Hashimi
 
Launch Your Local Blog & Social Media Integration
Launch Your Local Blog & Social Media IntegrationLaunch Your Local Blog & Social Media Integration
Launch Your Local Blog & Social Media IntegrationJamshid Hashimi
 
Customizing Your Blog 2
Customizing Your Blog 2Customizing Your Blog 2
Customizing Your Blog 2Jamshid Hashimi
 
Customizing Your Blog 1
Customizing Your Blog 1Customizing Your Blog 1
Customizing Your Blog 1Jamshid Hashimi
 
Introduction to Blogging
Introduction to BloggingIntroduction to Blogging
Introduction to BloggingJamshid Hashimi
 
Introduction to Wordpress
Introduction to WordpressIntroduction to Wordpress
Introduction to WordpressJamshid Hashimi
 
CodeIgniter Helper Functions
CodeIgniter Helper FunctionsCodeIgniter Helper Functions
CodeIgniter Helper FunctionsJamshid Hashimi
 
CodeIgniter Class Reference
CodeIgniter Class ReferenceCodeIgniter Class Reference
CodeIgniter Class ReferenceJamshid Hashimi
 
Managing Applications in CodeIgniter
Managing Applications in CodeIgniterManaging Applications in CodeIgniter
Managing Applications in CodeIgniterJamshid Hashimi
 
CodeIgniter Practice
CodeIgniter PracticeCodeIgniter Practice
CodeIgniter PracticeJamshid Hashimi
 
PHP Frameworks & Introduction to CodeIgniter
PHP Frameworks & Introduction to CodeIgniterPHP Frameworks & Introduction to CodeIgniter
PHP Frameworks & Introduction to CodeIgniterJamshid Hashimi
 
Exception & Database
Exception & DatabaseException & Database
Exception & DatabaseJamshid Hashimi
 
MySQL Record Operations
MySQL Record OperationsMySQL Record Operations
MySQL Record OperationsJamshid Hashimi
 

Mehr von Jamshid Hashimi (20)

Week 2: Getting Your Hands Dirty – Part 2
Week 2: Getting Your Hands Dirty – Part 2Week 2: Getting Your Hands Dirty – Part 2
Week 2: Getting Your Hands Dirty – Part 2
 
Week 1: Getting Your Hands Dirty - Part 1
Week 1: Getting Your Hands Dirty - Part 1Week 1: Getting Your Hands Dirty - Part 1
Week 1: Getting Your Hands Dirty - Part 1
 
Introduction to C# - Week 0
Introduction to C# - Week 0Introduction to C# - Week 0
Introduction to C# - Week 0
 
RIST - Research Institute for Science and Technology
RIST - Research Institute for Science and TechnologyRIST - Research Institute for Science and Technology
RIST - Research Institute for Science and Technology
 
How Coding Can Make Your Life Better
How Coding Can Make Your Life BetterHow Coding Can Make Your Life Better
How Coding Can Make Your Life Better
 
Mobile Vision
Mobile VisionMobile Vision
Mobile Vision
 
Tips for Writing Better Code
Tips for Writing Better CodeTips for Writing Better Code
Tips for Writing Better Code
 
Launch Your Local Blog & Social Media Integration
Launch Your Local Blog & Social Media IntegrationLaunch Your Local Blog & Social Media Integration
Launch Your Local Blog & Social Media Integration
 
Customizing Your Blog 2
Customizing Your Blog 2Customizing Your Blog 2
Customizing Your Blog 2
 
Customizing Your Blog 1
Customizing Your Blog 1Customizing Your Blog 1
Customizing Your Blog 1
 
Introduction to Blogging
Introduction to BloggingIntroduction to Blogging
Introduction to Blogging
 
Introduction to Wordpress
Introduction to WordpressIntroduction to Wordpress
Introduction to Wordpress
 
CodeIgniter Helper Functions
CodeIgniter Helper FunctionsCodeIgniter Helper Functions
CodeIgniter Helper Functions
 
CodeIgniter Class Reference
CodeIgniter Class ReferenceCodeIgniter Class Reference
CodeIgniter Class Reference
 
Managing Applications in CodeIgniter
Managing Applications in CodeIgniterManaging Applications in CodeIgniter
Managing Applications in CodeIgniter
 
CodeIgniter Practice
CodeIgniter PracticeCodeIgniter Practice
CodeIgniter Practice
 
CodeIgniter & MVC
CodeIgniter & MVCCodeIgniter & MVC
CodeIgniter & MVC
 
PHP Frameworks & Introduction to CodeIgniter
PHP Frameworks & Introduction to CodeIgniterPHP Frameworks & Introduction to CodeIgniter
PHP Frameworks & Introduction to CodeIgniter
 
Exception & Database
Exception & DatabaseException & Database
Exception & Database
 
MySQL Record Operations
MySQL Record OperationsMySQL Record Operations
MySQL Record Operations
 

KĂźrzlich hochgeladen

Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel AraĂşjo
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessPixlogix Infotech
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxKatpro Technologies
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Enterprise Knowledge
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)wesley chun
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?Igalia
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 

KĂźrzlich hochgeladen (20)

Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your Business
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 

New Elements & Features in HTML5

  • 1. HTML5 Jamshid Hashimi Trainer, Cresco Solution http://www.jamshidhashimi.com jamshid@netlinks.af @jamshidhashimi ajamshidhashimi Afghanistan Workforce Development Program
  • 2.
  • 3. Agenda • HTML5 Introduction • HTML5 New Elements • HTML5 Canvas • HTML5 SVG • HTML5 Drag/Drop • HTML5 Geolocation • HTML5 Video • HTML5 Audio • HTML5 Input Types
  • 4. Agenda • HTML5 Form Elements • HTML5 Form Attributes • HTML5 Semantic Elements • HMTL5 Web Storage • HMTL5 Application Cache • HMTL5 Web Workers
  • 5. HTML5 Introduction • What is HTML5? – HTML5 will be the standard for HTML – HTML 4.01 came in 1999. Web changed a lot! – HTML5 is still work in progress – Major browsers support HTML5 elements & API • How Did HTML5 Get Started? – Cooperation between World Wide Web Consortium (W3C) and Web Hypertext Application Technology Working Group (WHATWG)
  • 6. HTML5 Introduction • The HTML5 <!DOCTYPE> – There is only one <!DOCTYPE> declaration. Simple <!DOCTYPE html>
  • 7. HTML5 Introduction • Minimum HTML5 Document <!DOCTYPE html> <html> <head> <title>Title of the document</title> </head> <body> The content of the document...... </body> </html>
  • 8. HTML5 Introduction • HTML5 New Features – The <canvas> element for 2D drawing – The <video> and <audio> elements for media playback – Support for local storage – New content-specific elements, like <article>, <footer>, <header>, <nav>, <section> – New form controls, like calendar, date, time, email, url, search
  • 9. HTML5 Introduction • Browser Support for HTML5 – Not full standard! – No browser has full support – In a continuous development (Chrome, Safari, Internet Explorer, Firefox, Opera)
  • 10.
  • 11. HTML5 New Elements • Use of internet changed a lot since HTML 4.01 (1999) • Several HTML 4.01 elements are obsolete, never used or never used the way they were intended • To better handle todays internet, HTML5 brings new changes: New elements for drawing graphics, adding media content, better page structure, better form handling, and several APIs to drag/drop elements, find Geolocation, include web storage, application cache, web workers, etc.
  • 17. HTML5 New Elements • Removed Elements – <acronym> – <applet> – <basefont> – <big> – <center> – <dir> – <font> – <frame> – <frameset> – <noframes> – <strike> – <tt>
  • 18. HTML5 Canvas • The <canvas> element is used to draw graphics, on the fly, on a web page. • What is Canvas? – The HTML5 <canvas> element is used to draw graphics, on the fly, via scripting (usually JavaScript). – The <canvas> element is only a container for graphics. You must use a script to actually draw the graphics. – Canvas has several methods for drawing paths, boxes, circles, characters, and adding images.
  • 19. HTML5 Canvas • Browser Support – Internet Explorer 9+, Firefox, Opera, Chrome, and Safari support the <canvas> element. – Note: Internet Explorer 8 and earlier versions, do not support the <canvas> element. • Creating a Canvas <canvas id="myCanvas" width="200" height="100"></canvas>
  • 20. HTML5 Canvas • Tip: You can have multiple <canvas> elements on one HTML page. • Canvas example: <canvas id="myCanvas" width="200" height="100" style="border:1px solid #000000;"> </canvas>
  • 21. HTML5 Canvas • Draw Onto The Canvas With Javascript <script> var c=document.getElementById("myCanvas"); var ctx=c.getContext("2d"); ctx.fillStyle="#FF0000"; ctx.fillRect(0,0,150,75); </script>
  • 22. HTML5 Canvas • Canvas Coordinates • This means: Start at the upper-left corner (0,0) and draw a 150x75 pixels rectangle.
  • 23. HTML5 Canvas • Canvas Paths – To draw straight lines on a canvas, we will use the following two methods: • moveTo(x,y) defines the starting point of the line • lineTo(x,y) defines the ending point of the line – To actually draw the line, we must use one of the "ink" methods, like stroke(). var c=document.getElementById("myCanvas"); var ctx=c.getContext("2d"); ctx.moveTo(0,0); ctx.lineTo(200,100); ctx.stroke();
  • 24. HTML5 Canvas • To draw a circle on a canvas, we will use the following method: – arc(x,y,r,start,stop) • To actually draw the circle, we must use one of the "ink" methods, like stroke() or fill(). var c=document.getElementById("myCanvas"); var ctx=c.getContext("2d"); ctx.beginPath(); ctx.arc(95,50,40,0,2*Math.PI); ctx.stroke();
  • 25. HTML5 Canvas • To draw text on a canvas, the most important property and methods are: – font - defines the font properties for text – fillText(text,x,y) - Draws "filled" text on the canvas – strokeText(text,x,y) - Draws text on the canvas (no fill) Using fillText(): var c=document.getElementById("myCanvas"); var ctx=c.getContext("2d"); ctx.font="30px Arial"; ctx.fillText("Hello World",10,50);
  • 26. HTML5 Canvas Using strokeText(): var c=document.getElementById("myCanvas"); var ctx=c.getContext("2d"); ctx.font="30px Arial"; ctx.strokeText("Hello World",10,50);
  • 27. HTML5 SVG • HTML5 has support for inline SVG. • What is 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 – SVG is a W3C recommendation
  • 28. HTML5 SVG • Advantages of using SVG over other image formats (like JPEG and GIF) are: – SVG images can be created and edited with any text editor – SVG images can be searched, indexed, scripted, and compressed – SVG images are scalable – SVG images can be printed with high quality at any resolution – SVG images are zoomable (and the image can be zoomed without degradation)
  • 29. HTML5 SVG • Internet Explorer 9+, Firefox, Opera, Chrome, and Safari support inline SVG. • Embed SVG Directly Into HTML Pages<!DOCTYPE html> <html> <body> <svg xmlns="http://www.w3.org/2000/svg" version="1.1" height="190"> <polygon points="100,10 40,180 190,60 10,60 160,180" style="fill:lime;stroke:purple;stroke- width:5;fill-rule:evenodd;"> </svg> </body> </html>
  • 30. HTML5 SVG • Differences Between SVG and Canvas – SVG is a language for describing 2D graphics in XML. – Canvas draws 2D graphics, on the fly (with a JavaScript). – SVG is XML based, which means that every element is available within the SVG DOM. You can attach JavaScript event handlers for an element. – In SVG, each drawn shape is remembered as an object. If attributes of an SVG object are changed, the browser can automatically re-render the shape. – Canvas is rendered pixel by pixel. In canvas, once the graphic is drawn, it is forgotten by the browser. If its position should be changed, the entire scene needs to be redrawn, including any objects that might have been covered by the graphic.
  • 32. HTML5 Drag & Drop • Drag and drop is a part of the HTML5 standard. • Drag and drop is a very common feature. It is when you "grab" an object and drag it to a different location. • In HTML5, drag and drop is part of the standard, and any element can be draggable. • Internet Explorer 9+, Firefox, Opera, Chrome, and Safari support drag and drop.
  • 33. HTML5 Drag & Drop <!DOCTYPE HTML> <html> <head> <script> function allowDrop(ev) { ev.preventDefault(); } function drag(ev) { ev.dataTransfer.setData("Text",ev.target.id); } function drop(ev) { ev.preventDefault(); var data=ev.dataTransfer.getData("Text"); ev.target.appendChild(document.getElementById(data)); } </script> </head> <body> <div id="div1" ondrop="drop(event)" ondragover="allowDrop(event)"></div> <img id="drag1" src="img_logo.gif" draggable="true" ondragstart="drag(event)" width="336" height="69”> </body> </html>
  • 34. HTML5 Geolocation • HTML5 Geolocation is used to locate a user's position. • The HTML5 Geolocation API is used to get the geographical position of a user. • Since this can compromise user privacy, the position is not available unless the user approves it. • Browser Support – Internet Explorer 9+, Firefox, Chrome, Safari and Opera support Geolocation. – Note: Geolocation is much more accurate for devices with GPS, like iPhone.
  • 35. HTML5 Geolocation <script> var x=document.getElementById("demo"); function getLocation() { if (navigator.geolocation) { navigator.geolocation.getCurrentPosition(showPosition); } else { x.innerHTML="Geolocation is not supported by this browser."; } } function showPosition(position) { x.innerHTML="Latitude: " + position.coords.latitude + "<br>Longitude: " + position.coords.longitude; } </script>
  • 36. HTML5 Geolocation function showError(error) { switch(error.code) { case error.PERMISSION_DENIED: x.innerHTML="User denied the request for Geolocation." break; case error.POSITION_UNAVAILABLE: x.innerHTML="Location information is unavailable." break; case error.TIMEOUT: x.innerHTML="The request to get user location timed out." break; case error.UNKNOWN_ERROR: x.innerHTML="An unknown error occurred." break; } }
  • 37. HTML5 Geolocation • Displaying the result in a map function showPosition(position) { var latlon=position.coords.latitude+","+position.coords.lon gitude; var img_url="http://maps.googleapis.com/maps/api/staticmap? center=" +latlon+"&zoom=14&size=400x300&sensor=false"; document.getElementById("mapholder").innerHTML="<im g src='"+img_url+"'>"; }
  • 38. HTML5 Video • Many modern websites show videos. HTML5 provides a standard for showing them. • Until now, there has not been a standard for showing a video/movie on a web page. • Today, most videos are shown through a plug-in (like flash). However, different browsers may have different plug-ins. • HTML5 defines a new element which specifies a standard way to embed a video/movie on a web page: the <video> element. • Internet Explorer 9+, Firefox, Opera, Chrome, and Safari support the <video> element. – Note: Internet Explorer 8 and earlier versions, do not support the <video> element.
  • 39. HTML5 Video <video width="320" height="240" controls> <source src="movie.mp4" type="video/mp4"> <source src="movie.ogg" type="video/ogg"> Your browser does not support the video tag. </video>
  • 40. HTML5 Video <!DOCTYPE html> <html> <body> <script> var myVideo=document.getElementById("video1"); function playPause() { if (myVideo.paused) myVideo.play(); else myVideo.pause(); } function makeBig() { myVideo.width=560; } function makeSmall() { myVideo.width=320; } function makeNormal() { myVideo.width=420; } </script> </body> </html>
  • 41. HTML5 Audio • HTML5 provides a standard for playing audio files. • Until now, there has not been a standard for playing audio files on a web page. • Today, most audio files are played through a plug-in (like flash). However, different browsers may have different plug-ins. • HTML5 defines a new element which specifies a standard way to embed an audio file on a web page: the <audio> element. • Internet Explorer 9+, Firefox, Opera, Chrome, and Safari support the <audio> element. – Note: Internet Explorer 8 and earlier versions, do not support the <audio> element.
  • 42. HTML5 Audio • HTML5 Audio – How it Works <audio controls> <source src="horse.ogg" type="audio/ogg"> <source src="horse.mp3" type="audio/mpeg"> Your browser does not support the audio element. </audio>
  • 44. HTML5 Input Types • HTML5 has several new input types for forms. These new features allow better input control and validation. – color – date – datetime – datetime-local – email – month – number – range – search – tel – time – url – week • Note: Not all major browsers support all the new input types. However, you can already start using them; If they are not supported, they will behave as regular text fields.
  • 45. HTML5 Form Elements • HTML5 has the following new form elements: – <datalist> – <keygen> – <output> • Note: Not all major browsers support all the new form elements. However, you can already start using them; If they are not supported, they will behave as regular text fields.
  • 46. HTML5 Form Elements • <datalist> – HTML5 <datalist> Element – The <datalist> element specifies a list of pre- defined options for an <input> element. – The <datalist> element is used to provide an "autocomplete" feature on <input> elements. Users will see a drop-down list of pre-defined options as they input data. – Use the <input> element's list attribute to bind it together with a <datalist> element.
  • 47. HTML5 Form Elements <input list="browsers"> <datalist id="browsers"> <option value="Internet Explorer"> <option value="Firefox"> <option value="Chrome"> <option value="Opera"> <option value="Safari"> </datalist>
  • 48. HTML5 Form Elements • <keygen> – The purpose of the <keygen> element is to provide a secure way to authenticate users. – The <keygen> tag specifies a key-pair generator field in a form. – When the form is submitted, two keys are generated, one private and one public. – The private key is stored locally, and the public key is sent to the server. The public key could be used to generate a client certificate to authenticate the user in the future.
  • 49. HTML5 Form Elements <form action="demo_keygen.asp" method="get"> Username: <input type="text" name="usr_name"> Encryption: <keygen name="security"> <input type="submit"> </form>
  • 50. HTML5 Form Elements • <output> – The <output> element represents the result of a calculation (like one performed by a script). <form oninput="x.value=parseInt(a.value)+parseInt (b.value)">0 <input type="range" id="a" value="50">100 + <input type="number" id="b" value="50">= <output name="x" for="a b"></output> </form>
  • 51. HTML5 New Form Elements • HTML5 has several new attributes for <form> and <input>. • New attributes for <form>: – autocomplete – Novalidate • New attributes for <input>: – autocomplete – autofocus – form – formaction – formenctype – formmethod – formnovalidate – formtarget – height and width – list – min and max – multiple – pattern (regexp) – placeholder – required – step
  • 52. HTML5 Semantic Elements • What Are Semantic Elements? – A semantic element clearly describes its meaning to both the browser and the developer. – Examples of non-semantic elements: <div> and <span> - Tells nothing about its content. – Examples of semantic elements: <form>, <table>, and <img> - Clearly defines its content. – Internet Explorer 9+, Firefox, Chrome, Safari and Opera supports the semantic elements described in this chapter.
  • 54. HTML5 Web Storage • What is HTML5 Web Storage? – With HTML5, web pages can store data locally within the user's browser. – Earlier, this was done with cookies. However, Web Storage is more secure and faster. The data is not included with every server request, but used ONLY when asked for. It is also possible to store large amounts of data, without affecting the website's performance. – The data is stored in key/value pairs, and a web page can only access data stored by itself. – Web storage is supported in Internet Explorer 8+, Firefox, Opera, Chrome, and Safari.
  • 55. HTML5 Web Storage • localStorage and sessionStorage – There are two new objects for storing data on the client: • localStorage - stores data with no expiration date • sessionStorage - stores data for one session – Before using web storage, check browser support for localStorage and sessionStorage: if(typeof(Storage)!=="undefined") { // Yes! localStorage and sessionStorage support! // Some code..... } else { // Sorry! No web storage support.. }
  • 56. HTML5 Web Storage • The localStorage Object – The localStorage object stores the data with no expiration date. The data will not be deleted when the browser is closed, and will be available the next day, week, or year. localStorage.lastname="Smith"; document.getElementById("result").innerHTML ="Last name: " + localStorage.lastname;
  • 57. HTML5 Web Storage • The sessionStorage Object – The sessionStorage object is equal to the localStorage object, except that it stores the data for only one session. The data is deleted when the user closes the browser window. if (sessionStorage.clickcount) { sessionStorage.clickcount=Number(sessionStorage.clickcount)+1; } else { sessionStorage.clickcount=1; } document.getElementById("result").innerHTML="You have clicked the button " + sessionStorage.clickcount + " time(s) in this session.";
  • 58. HTML5 Application Cache • With HTML5 it is easy to make an offline version of a web application, by creating a cache manifest file. • HTML5 introduces application cache, which means that a web application is cached, and accessible without an internet connection. • Application cache gives an application three advantages: – Offline browsing - users can use the application when they're offline – Speed - cached resources load faster – Reduced server load - the browser will only download updated/changed resources from the server
  • 59. HTML5 Application Cache <!DOCTYPE HTML> <html manifest="demo.appcache"> <body> The content of the document...... </body> </html> CACHE MANIFEST /theme.css /logo.gif /main.js CACHE MANIFEST /theme.css /logo.gif /main.js FALLBACK: /html/ /offline.html
  • 60. HTML5 Web Workers • A web worker is a JavaScript running in the background, without affecting the performance of the page. • When executing scripts in an HTML page, the page becomes unresponsive until the script is finished. • A web worker is a JavaScript that runs in the background, independently of other scripts, without affecting the performance of the page. You can continue to do whatever you want: clicking, selecting things, etc., while the web worker runs in the background.
  • 61. HTML5 Web Workers <p>Count numbers: <output id="result"></output></p> <button onclick="startWorker()">Start Worker</button> <button onclick="stopWorker()">Stop Worker</button> <br><br> <script> var w; function startWorker() { if(typeof(Worker)!=="undefined") { if(typeof(w)=="undefined") { w=new Worker("demo_workers.js"); } w.onmessage = function (event) { document.getElementById("result").innerHTML=event.data; }; } else { document.getElementById("result").innerHTML="Sorry, your browser does not support Web Workers..."; } } function stopWorker() { w.terminate(); } </script>
  • 62. HTML5 Web Workers var i=0; function timedCount() { i=i+1; postMessage(i); setTimeout("timedCount()",500); } timedCount(); Demo_workers.js
  • 63.

Hinweis der Redaktion

  1. http://publib.boulder.ibm.com/infocenter/wmqv7/v7r1/index.jsp?topic=%2Fcom.ibm.mq.doc%2Fsy10670_.htm
  2. Note: By default, the &lt;canvas&gt; element has no border and no content.Note: Always specify an id attribute (to be referred to in a script), and a width and height attribute to define the size of the canvas.
  3. Example explained:First, find the &lt;canvas&gt; element:var c=document.getElementById(&quot;myCanvas&quot;);Then, call its getContext() method (you must pass the string &quot;2d&quot; to the getContext() method):varctx=c.getContext(&quot;2d&quot;);The getContext(&quot;2d&quot;) object is a built-in HTML5 object, with many properties and methods for drawing paths, boxes, circles, text, images, and more.The next two lines draw a red rectangle:ctx.fillStyle=&quot;#FF0000&quot;;ctx.fillRect(0,0,150,75);The fillStyle property can be a CSS color, a gradient, or a pattern. The default fillStyle is #000000 (black).The fillRect(x,y,width,height) method draws a rectangle filled with the current fill style.
  4. The canvas is a two-dimensional grid.The upper-left corner of the canvas has coordinate (0,0)So, the fillRect() method above had the parameters (0,0,150,75).This means: Start at the upper-left corner (0,0) and draw a 150x75 pixels rectangle.
  5. arc(x,y,r,start,stop)
  6. Make an Element Draggable----------------------------------------First of all: To make an element draggable, set the draggable attribute to true:&lt;imgdraggable=&quot;true&quot;&gt;What to Drag - ondragstart and setData()-------------------------------------------------------Then, specify what should happen when the element is dragged.In the example above, the ondragstart attribute calls a function, drag(event), that specifies what data to be dragged.The dataTransfer.setData() method sets the data type and the value of the dragged data:function drag(ev){ev.dataTransfer.setData(&quot;Text&quot;,ev.target.id);}In this case, the data type is &quot;Text&quot; and the value is the id of the draggable element (&quot;drag1&quot;).Where to Drop – ondragover---------------------------------------The ondragover event specifies where the dragged data can be dropped.By default, data/elements cannot be dropped in other elements. To allow a drop, we must prevent the default handling of the element.This is done by calling the event.preventDefault() method for the ondragover event:event.preventDefault()Do the Drop – ondrop------------------------------When the dragged data is dropped, a drop event occurs.In the example above, the ondrop attribute calls a function, drop(event):function drop(ev){ev.preventDefault();var data=ev.dataTransfer.getData(&quot;Text&quot;);ev.target.appendChild(document.getElementById(data));}Code explained:-----------------------Call preventDefault() to prevent the browser default handling of the data (default is open as link on drop)Get the dragged data with the dataTransfer.getData(&quot;Text&quot;) method. This method will return any data that was set to the same type in the setData() methodThe dragged data is the id of the dragged element (&quot;drag1&quot;)Append the dragged element into the drop element
  7. Code Explained:Check if Geolocation is supportedIf supported, run the getCurrentPosition() method. If not, display a message to the userIf the getCurrentPosition() method is successful, it returns a coordinates object to the function specified in the parameter ( showPosition )The showPosition() function gets the displays the Latitude and Longitude
  8. The second parameter of the getCurrentPosition() method is used to handle errors. It specifies a function to run if it fails to get the user&apos;s location:
  9. Homework!