HTML Advanced: HTML 5: N.Nalini AP (SR) Scope VIT
HTML Advanced: HTML 5: N.Nalini AP (SR) Scope VIT
HTML Advanced: HTML 5: N.Nalini AP (SR) Scope VIT
N.Nalini
AP(Sr)
SCOPE
VIT
HTML5: Ground Rules
<!DOCTYPE html>
HTML5: What's New
HTML 5 Form
Form Enhancements
• Placeholder text
• Specific text input: email, URL, number, search
• Slider
• Date picker
• User Agent validation
HTML5: Input - e-mail
The url type is used for input fields that should contain a
URL address.
The search type is used for search fields like a site search or Google
search.
The color type is used for input fields that should contain a color.
This input type will allow you to select a color from a color picker:
> datalist
> keygen
> output
HTML5: Form elements
novalidate Applies only to the <form> element, and prevents a form from being validated
before submitted.
pattern Declaring what pattern should be used for validating a field’s value, in the form
of a regular expression.
placeholder Meant to be able to display a hint to the end user what to input.
Tag Description
<track> Defines text tracks for media elements (<video> and <audio>)
<!DOCTYPE HTML>
<html>
<body>
</body>
</html>
HTML5: Video
<!DOCTYPE HTML>
<html>
<body>
</body>
</html>
HTML5: Audio
<audio controls="controls">
<source src="song.ogg" type="audio/ogg" />
<source src="song.mp3" type="audio/mpeg" />
Your browser does not support the audio element.
</audio>
HTML5: Audio
HTML5: Figure
<figure>
<img src="/media/examples/elephant-660-480.jpg"
alt="Elephant at sunset">
<figcaption>An elephant at sunset</figcaption>
</figure>
HTML5: Canvas
The canvas element has several methods for drawing paths, boxes,
circles, characters, and adding images.
HTML5: Canvas
<script type="text/javascript">
var c=document.getElementById("myCanvas");
var cxt=c.getContext("2d");
cxt.fillStyle="#FF0000";
cxt.fillRect(0,0,150,75);
</script>
HTML5 SVG
<!DOCTYPE html>
<html>
<head>
<title>Title name will go here</title>
</head>
<body>
</body>
</html>
HTML5 CANVAS vs HTML5 SVG
✔ It is created with the help of Java Script ✔ It is created in XML format
✔ It has no support for event handling ✔ It has support for even handling
✔ It has low text rendering capabilities ✔ It has high text rendering capabilities
✔ Best suited for graphical intensive games ✔ Not suited for games application
HTML web storage provides two objects for storing data on the client:
Before using web storage, check browser support for localStorage and
sessionStorage:
if (typeof(Storage) !== "undefined") {
// Code for localStorage/sessionStorage.
} else {
// Sorry! No Web Storage support..
}
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.
Example
• // Store
localStorage.setItem("lastname", "Smith");
• // Retrieve
document.getElementById("result").innerHTML =
localStorage.getItem("lastname");
• //remove
localStorage.removeItem("lastname");
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 specific browser tab.
The following example counts the number of times a user has clicked a
button, in the current session:
Example
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.";