1. history, vision & future of html5 1.1 what is html5? successor of html 4.01 and xhtml 1.1 it...
TRANSCRIPT
1. History, Vision & Future of HTML5
1.1 What Is HTML5?
Successor of HTML 4.01 and XHTML 1.1 It comes with new tags, features and APIs Below is a non exhaustive list of features that tend to be labelled as
"HTML5" in the medias: New structural elements (<header>, <footer>, <nav> and more) Forms 2.0 and client-side validation Native browser support for audio and video (<video>, <audio>) Canvas API and SVG Web storage Offline applications Geolocation Drag & Drop Web Workers New communications API (Server Sent Events, Web Sockets, …)
1. History, Vision & Future of HTML5
1.2 History of HTML5?
December 1997: HTML 4.0 is published by the W3C
February - March 1998: XML 1.0 is published
December 1999 - January 2000: ECMAScript 3rd Edition, XHTML 1.0 (Basically HTML tags reformulated in XML) and, HTML 4.01 recommendations are published
May 2001: XHTML 1.1 recommendation is published
August 2002: XHTML 2.0 first working draft is released.
December 2002: XHTML 2.0 second working draft published.
January 2008: First W3C working draft of HTML5 is published!!
1. History, Vision & Future of HTML5
1.3 Future of HTML5
84% of Developers Plan to Adopt Key HTML5 Features
The key to understanding HTML5 is that it is not one, but a group of technologies. Within HTML5, developers have a tremendous amount of choice regarding what they use and what they don’t use
The power of HTML5 being ready for prime-time can be seen in Microsoft’s choice to utilize it in Windows 8
Still on the fence with adopting HTML5 in your next project?
2. Getting started with HTML5
Wondering what it takes to get it started?
Any Text editor such as Notepad++, Editplus, Textmate, Dream weaver
Modern browsers such as Firefox 3.5 +, IE9, chrome, safari
Prior knowledge of HTML 4
3. Structure of Web page
3.1. New and Updated HTML5 Elements
HTML5 introduces 28 new elements:
<section>, <article>, <aside>, <hgroup>, <header>,<footer>, <nav>, <figure>, <figcaption>, <video>, <audio>, <source>, <embed>, <mark>,<progress>, <meter>, <time>, <ruby>, <rt>, <rp>,<wbr>, <canvas>, <command>, <details>,<summ
ary>, <datalist>, <keygen> and <output> An HTML page first starts with the DOCTYPE declaration
HTML5 also update some of the previous existing elements to better reflect how they are used on the Web or to make them more useful such as:
The <a> element can now also contain flow content instead of just phrasing content The <hr> element is now representing a paragraph-level thematic break The <cite> element only represent the title of a work The <strong> element is now representing importance rather than strong emphasis
3. Structure of Web page
3.2. First HTML5 webpage
<!DOCTYPE html><html><head><title>Title of the document</title></head>
<body> That’s all I need to create my first HTML5 page</body>
</html>
Output: Click here
3. Structure of Web page
3.3. New Semantic Elements <nav>: Represents a major navigation block. It groups links to other pages or to parts of the current page.
<nav> does not have to be used in every place you can find links. For instance, footers often contains links to terms of service, copyright page and
such, the <footer> element would be sufficient in that case
3. Structure of Web page
3.3. New Semantic Elements <Header>: tag specifies a header for a document or section.
However, we mustn't think that "header" is only for masthead of a website. "header" can be use as a heading of an blog entry or news article as every article has its title and published date and time
3. Structure of Web page
3.3. New Semantic Elements <article>: The web today contains a ocean of news articles and blog entries. That gives W3C a good reason to define an element for article instead of <div class="article">.
We should use article for content that we think it can be distributable. Just like news or blog entry can we can share in RSS feed
"article" element can be nested in another "article" element.
An article element doesn't just mean article content. You can have header andfooter element in an article. In fact, it is very common to have header as each article
should have a title.
3. Structure of Web page
3.3. New Semantic Elements <aside>: The "aside" element is a section that somehow related to main content,
but it can be separate from that content
3. Structure of Web page
3.3. New Semantic Elements <footer>: Similarly to "header" element, "footer" element is often referred to the footer of a web page. Well, most of the time, footer can be used as what we thought.
Please don't think you can only have one footer per web document, you can have a
footer in every section, or every article.
3. Structure of Web page
3.3. New Semantic Elements <Progress>: The new "progress" element appears to be very similar to the "meter" element. It is created to indicate progress of a specific task.
The progress can be either determinate OR interderminate. Which means, you can use "progress" element to indicate a progress that you do not even know how much more work is to be done yet.
Progress of Task A : <progress value="60" max="100">60%</progress>
3. Structure of Web page
3.3. New Semantic Elements <meter>: "Meter" is a new element in HTML5 which represenet value of a known range as a gauge. The keyword here is "known range". That means, you are only allowed to use it when you are clearly aware of its minimum value and maximum value.
One example is score of rating. I would rate this movie <meter min="0" max="10"
value="8">8 of 10</meter>.
3. Structure of Web page
3.3. New Semantic Elements <mark>: The mark <mark> element represents a run of text in one document marked or highlighted for reference purposes, due to its relevance in another context.
Basically, it is used to bring the reader's attention to a part of the text that might not have been
3. Structure of Web page
3.3. New Semantic Elements <figure>: The <figure> tag specifies self-contained content, like illustrations, diagrams, photos, code listings, etc.
While the content of the <figure> element is related to the main flow, its position is independent of the main flow, and if removed it should not affect the flow of the document
3. Structure of Web page
3.3. Lets put altogether
3. Structure of Web page
3.3. Designing blog with html5
IE layoutThere’s one gotcha about styling HTML 5 pages in IE: it doesn’t work. You can force it to quite easily with a JavaScript hack document.createElement('element name').
HTML 5 enabling script which I use in the header to conjure all the missing elements into existence all at once.
3. Structure of Web page
3.3. why so much fuss for semantics in html5
Well, they add semantics to the page. The browser now knows which area of your site is the header or the footer because there are header and footer elements, whereas div might be called “branding
The first is for search engine use; it’s easy to imagine Messrs Google or Yahoo! giving lower weighting to content in footer elements, or extra weight to content in the header.
site navigable for people with disabilities. People with learning difficulties might instruct their browser always to put the articles before the navigation
Form AttributsForm Attributs
• HTML5 has several new elements and attributes for forms. New form attributes :
• autocomplete• novalidate
• New input attributes :• autocomplete• autofocus• form• form overrides (formaction, formenctype, formmethod,
formnovalidate, formtarget)• height and width• list• min, max and step• multiple• pattern (regexp)• placeholder• required
New Form New Form AttributesAttributes
• Browser support for the new input type :
Browser SupportBrowser Support
Input Type IE Firefox Opera Chrome Safari
autocomplete 8.0 3.5 9.5 3.0 4.0
autofocus No 4.0 10.0 3.0 4.0
form No 4.0 9.5 10.0 No
form overrides No 4.0 10.5 10.0 No
height and width
8.0 3.5 9.5 3.0 4.0
list No 4.0 9.5 No No
min, max and step
No No 9.5 3.0 No
multiple No 3.5 11.0 3.0 4.0
novalidate No 4.0 11.0 10.0 No
pattern No 4.0 9.5 3.0 No
placeholder No 4.0 11.0 3.0 3.0
required No 4.0 9.5 3.0 No
• The autocomplete attribute specifies that the form or input field should have an autocomplete function.
• Note: The autocomplete attribute works with <form>, and the following <input> types: text, search, url, telephone, email, password, datepickers, range, and color.
• When the user starts to type in an autocomplete field, the browser should display options to fill in the field :
<form action="demo_form.asp" method="get" autocomplete="on">First name: <input type="text" name="fname" /><br />Last name: <input type="text" name="lname" /><br />E-mail: <input type="email" name="email" autocomplete="off" /><br /><input type="submit" /></form>
• In some browsers you may need to activate the autocomplete function for this to work.
autocomplete autocomplete AttributeAttribute
• The autofocus attribute specifies that a field should automatically get focus when a page is loaded.
• Note: The autofocus attribute works with all <input> types.
User name: <input type="text" name="user_name" autofocus="autofocus" />
autofocus autofocus AttributeAttribute
• The form attribute specifies one or more forms the input field belongs to.
• Note: The form attribute works with all <input> types.
• To refer to more than one form, use a space-separated list.
• The form attribute must refer to the id of the form it belongs to:
<form action="demo_form.asp" method="get" id="user_form">First name:<input type="text" name="fname" /><input type="submit" /></form>Last name: <input type="text" name="lname" form="user_form" />
form Attributeform Attribute
• The form override attributes allow you to override some of the attributes set for the form element.
• The form override attributes are :• formaction - Overrides the form action attribute• formenctype - Overrides the form enctype attribute• formmethod - Overrides the form method attribute• formnovalidate - Overrides the form novalidate attribute• formtarget - Overrides the form target attribute
• Note: The form override attributes works with the following <input> types: submit and image.
Form Override Form Override AttributeAttribute
• Example :
<form action="demo_form.asp" method="get" id="user_form">E-mail: <input type="email" name="userid" /><br /><input type="submit" value="Submit" /><br /><input type="submit" formaction="demo_admin.asp" value="Submit as admin" /><br /><input type="submit" formnovalidate="true"value="Submit without validation" /><br /></form>
• These attributes are helpful for creating different submit buttons.
Form Override Form Override AttributeAttribute
• The height and width attributes specifies the height and width of the image used for the input type image.
• The height and width attributes only works with <input> type: image.
<input type="image" src="img_submit.gif" width="24" height="24" />
height and width height and width AttributeAttribute
• The list attribute specifies a datalist for an input field. A datalist is a list of options for an input field.
• The list attribute works with the following <input> types : text, search, url, telephone, email, date pickers, number, range, and color.
Webpage: <input type="url" list="url_list" name="link" /><datalist id="url_list"><option label="W3Schools" value="http://www.w3schools.com" /><option label="Google" value="http://www.google.com" /><option label="Microsoft" value="http://www.microsoft.com" /></datalist>
list Attributelist Attribute
• The min, max and step attributes are used to specify restrictions for input types containing numbers or dates.
• The max attribute specifies the maximum value allowed for the input field.
• The min attribute specifies the minimum value allowed for the input field.
• The step attribute specifies the legal number intervals for the input field (if step="3", legal numbers could be -3,0,3,6, etc).
min, max and step min, max and step AttributeAttribute
• The min, max, and step attributes works with the following <input> types: date pickers, number, and range.
• The example below shows a numeric field that accepts values between 0 and 10, with a step of 3 (legal numbers are 0, 3, 6 and 9):
Points: <input type="number" name="points" min="0" max="10" step="3" />
min, max and step min, max and step AttributeAttribute
• The multiple attribute specifies that multiple values can be selected for an input field.
• The multiple attribute works with the following <input> types: email, and file.
• Example :
Select images: <input type="file" name="img" multiple="multiple" />
multiplemultiple AttributeAttribute
• The novalidate attribute specifies that the form or input field should not be validated when submitted.
• If this attribute is present the form will not validate form input.
• The novalidate attribute works with: <form> and the following <input> types: text, search, url, telephone, email, password, date pickers, range, and color.
• Example :
<form action="demo_form.asp" novalidate="novalidate">E-mail: <input type="email" name="user_email" /><input type="submit" /></form>
novalidate novalidate AttributeAttribute
• The pattern attribute specifies a pattern used to validate an input field.
• The pattern is a regular expression. • The pattern attribute works with the
following <input> types: text, search, url, telephone, email, and password
• The example below shows a text field that can only contain three letters (no numbers or special characters) :
Country code: <input type="text" name="country_code"pattern="[A-z]{3}" title="Three letter country code" />
pattern Attributepattern Attribute
• The placeholder attribute provides a hint that describes the expected value of an input field.
• The placeholder attribute works with the following <input> types: text, search, url, telephone, email, and password
• The hint is displayed in the input field when it is empty, and disappears when the field gets focus.
• Example :
<input type="search" name="user_search" placeholder="Search W3Schools" />
placeholderplaceholder AttributeAttribute
• The required attribute specifies that an input field must be filled out before submitting.
• The required attribute works with the following <input> types: text, search, url, telephone, email, password, date pickers, number, checkbox, radio, and file.
• Example :
Name: <input type="text" name="usr_name" required="required" />
required Attributerequired Attribute
Input TypeInput Type
• HTML5 has several new input types for forms. These new features allow for better input control and validation.
• New input types :• email• url• number• range• Date pickers (date, month, week, time, datetime,
datetime-local)• search• color
New Input TypeNew Input Type
• Browser support for the new input type :
Browser SupportBrowser Support
Input Type
IE Firefox Opera Chrome Safari
email No 4.0 9.0 10.0 No
url No 4.0 9.0 10.0 No
number No No 9.0 7.0 No
range No No 9.0 4.0 4.0
Date pickers
No No 9.0 10.0 No
search No 4.0 11.0 10.0 No
color No No 11.0 No No
• The email type is used for input fields that should contain an e-mail address.
• The value of the email field is automatically validated when the form is submitted.
• Basic syntax :
E-mail: <input type="email" name="user_email" />
Input Type - emailInput Type - email
• The url type is used for input fields that should contain a URL address.
• The value of the url field is automatically validated when the form is submitted.
• Basic syntax :
Homepage: <input type="url" name="user_url" />
Input Type - urlInput Type - url
• The number type is used for input fields that should contain a numeric value.
• You can also set restrictions on what numbers are accepted
• Example :
Points: <input type="number" name="points" min="1" max="10" />
Input Type - Input Type - numbernumber
• Use the following attributes to specify restrictions for the number type:
Input Type - Input Type - numbernumber
Attribute
Value Description
max number Specifies the maximum value allowed
min number Specifies the minimum value allowed
step numberSpecifies legal number intervals (if step="3", legal numbers could be -3,0,3,6, etc)
value number Specifies the default value
• The range type is used for input fields that should contain a value from a range of numbers.
• The range type is displayed as a slider bar.
• You can also set restrictions on what numbers are accepted
• Example:
<input type="range" name="points" min="1" max="10" />
Input Type - rangeInput Type - range
• Use the following attributes to specify restrictions for the range type:
Input Type - rangeInput Type - range
Attribute
Value Description
max number Specifies the maximum value allowed
min number Specifies the minimum value allowed
step numberSpecifies legal number intervals (if step="3", legal numbers could be -3,0,3,6, etc)
value number Specifies the default value
• HTML5 has several new input types for selecting date and time:
• date - Selects date, month and year• month - Selects month and year• week - Selects week and year• time - Selects time (hour and minute)• datetime - Selects time, date, month and year
(UTC time)• datetime-local - Selects time, date, month and
year (local time)
• Example:
Date: <input type="date" name="user_date" />
Input Type – Date Input Type – Date PickersPickers
• The search type is used for search fields, like a site search, or Google search.
• The search field behaves like a regular text field.
Input Type – searchInput Type – 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 :
Color: <input type="color" name="user_color" />
Input Type – colorInput Type – color
AudioAudio
• The HTML 5.0 specification allows us playing sound using the <audio> element.
• The <audio> element can play sound files or an audio stream.
• The HTML 5.0 specification aims at supporting the following sounds formats: MP3, WAV and Ogg Vorbis.
AudioAudio
• Until now, there has never been a standard for playing audio on a web page. Today, most audio are played through a plugin (like flash). However, not all browsers have the same plugins.
• Currently, there are 3 supported audio formats for the audio element:
FormatFormat
Format Firefox 3.5
Opera 10.5
Chrome 3.0
IE 9 Safari 3.0
Ogg Vorbis
Yes Yes Yes No No
MP3 No No Yes Yes Yes
Wav Yes Yes No No Yes
Basic Syntax to Embed Video :
<audio src="music.ogg" controls="controls">*Content we place in between the tags will be displayed when the browser doesn't support playing audio
</audio>
•The control attribute is for adding the play, pause and volume controls
Basic SyntaxBasic Syntax
• The audio element allows multiple source elements. Source elements can link to different audio files.
• We can add the <source> child elements in between the audio element tags. The browser will use the first supported format.
<audio controls="controls">
<source src="mymusic.ogg" type="audio/ogg">
<source src="mymusic.mp3" type="audio/mpeg">
browser does not support html 5.0
</audio>
Basic SyntaxBasic Syntax
• The HTML 5.0 supports the following attributes :
AttributeAttribute
Attribute
Value Description
autoplay autoplaySpecifies that the audio will start playing as soon as it is ready.
controls controlsSpecifies that controls will be displayed, such as a play button.
loop loopSpecifies that the audio will start playing again (looping) when it reaches the end
preload preloadSpecifies that the audio will be loaded at page load, and ready to run. Ignored if autoplay is present.
src urlSpecifies the URL of the audio to play
VideoVideo
• HTML 5.0 provides a standard for showing video. Using the <video> element we can easily embed video within our web page.
• The video formats the <video> element supports include the following :
• MPG4 (with H.264 video codec and AAC audio codec)
• OGG (with Thedora video codec and Vorbis audio codec)
VideoVideo
• Until now, there has never been a standard for showing video on a web page. Today, most videos are shown through a plugin (like flash). However, not all browsers have the same plugins. HTML5 specifies a standard way to include video, with the video element.
• Currently, there are 2 supported video formats for the video element:
FormatFormat
Format Firefox 3.5
Opera 10.5
Chrome 3.0
IE 8 Safari 3.0
Ogg Yes Yes Yes No No
MPEG 4 No No Yes No Yes
Basic Syntax to Embed Video :
<video src="movie.ogg" controls="controls">*Content we place in between the tags will be displayed when the browser doesn't support displaying video
</video>
•We can use the width and height attributes in order to specify the size•The control attribute is for adding the play, pause and volume controls
Basic SyntaxBasic Syntax
Example :
<h1>HTML 5 Playing Video Sample</h1>
<video
src="http://example.com/video/example_video.ogg"
controls="controls"
width=“600"
height=“280">
Browser does not support HTML 5.0
</video>
Basic SyntaxBasic Syntax
• The video element allows multiple source elements. Source elements can link to different video files. The browser will use the first recognized format :
<video width="320" height="240" controls="controls"> <source src="movie.ogg" type="video/ogg" /> <source src="movie.mp4" type="video/mp4" /> <source src="movie.webm" type="video/webm" />Your browser does not support the video tag.</video>
Basic SyntaxBasic Syntax
• The HTML 5.0 supports the following attributes :
AttributeAttribute
Attribute Value Description
audio muted Defining the default state of the the audio. Currently, only "muted" is allowed
autoplayautoplay
If present, then the video will start playing as soon as it is ready
controlscontrols
If present, controls will be displayed, such as a play button
height pixels Sets the height of the video player
loop loop If present, the video will start over again, every time it is finished
poster url Specifies the URL of an image representing the video
preloadpreload
If present, the video will be loaded at page load, and ready to run. Ignored if "autoplay" is present
src url The URL of the video to play
width pixels Sets the width of the video player