• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content
Html5 tutorial
 

Html5 tutorial

on

  • 1,742 views

 

Statistics

Views

Total Views
1,742
Views on SlideShare
1,469
Embed Views
273

Actions

Likes
3
Downloads
128
Comments
0

6 Embeds 273

http://sclipcious.com 172
http://madhavmishra.com 84
http://blogs.madhavmishra.com 12
http://www.copyscape.com 2
http://copyscape.com 2
http://verious 1

Accessibility

Categories

Upload Details

Uploaded via as Microsoft PowerPoint

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

    Html5 tutorial Html5 tutorial Presentation Transcript

    • HTML5 will be the new standard for HTML. The previous version of HTML,HTML 4.01, came in 1999. The web has changed a lot since then. HTML5 is still awork in progress. However, the major browsers support many of the new HTML5elements and APIs Some rules for HTML5 were established: 1. New features should be based on HTML, CSS, DOM, and JavaScript 2. Reduce the need for external plugins (like Flash) 3. Better error handling 4. More markup to replace scripting 5. HTML5 is device independent
    • <!DOCTYPE html><html><head><title>Title of the document</title> Newly added Doc-type</head> element. But Not a DTD Declaration.<body>The content of the document......</body></html>
    • HTML 4.01 Strict<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">HTML 4.01 Transitional<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">HTML 4.01 Frameset<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN" "http://www.w3.org/TR/html4/frameset.dtd">XHTML 1.0 Strict<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">XHTML 1.0 Transitional<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">XHTML 1.0 Frameset<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">XHTML 1.1<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
    • 1. The <canvas> element for 2D drawing2. The <video> and <audio> elements for media playback3. Support for local storage4. New content-specific elements, like <article>, <footer>, <header>, <nav>, <section>5. New form controls, like calendar, date, time, email, url, search
    • Tag Description <article> Defines an article <aside> Defines content aside from the page content Isolates a part of text that might be formatted in a different direction from other <bdi> text outside it<command> Defines a command button that a user can invoke <details> Defines additional details that the user can view or hide<summary> Defines a visible heading for a <details> element Specifies self-contained content, like illustrations, diagrams, photos, code listings, <figure> etc.<figcaption> Defines a caption for a <figure> element <footer> Defines a footer for a document or section <header> Defines a header for a document or section <hgroup> Groups a set of <h1> to <h6> elements when a heading has multiple levels <mark> Defines marked/highlighted text <meter> Defines a scalar measurement within a known range (a gauge) <nav> Defines navigation links
    • <progress> Represents the progress of a task <ruby> Defines a ruby annotation (for East Asian typography) <rt> Defines an explanation/pronunciation of characters (for East Asian typography) <rp> Defines what to show in browsers that do not support ruby annotations<section> Defines a section in a document <time> Defines a date/time <wbr> Defines a possible line-break
    • New Media ElementsTag Description<audio> Defines sound content<video> Defines a video or movie<source> Defines multiple media resources for <video> and <audio><embed> Defines a container for an external application or interactive content (a plug-in)<track> Defines text tracks for <video> and <audio>New Form ElementsTag Description<datalist> Specifies a list of pre-defined options for input controls<keygen> Defines a key-pair generator field (for forms)<output> Defines the result of a calculationCanvas ElementsTag Description<canvas> Used to draw graphics, on the fly, via scripting (usually JavaScript
    • 1. <acronym>2. <applet>3. <basefont>4. <big>5. <center>6. <dir>7. <font>8. <frame>9. <frameset>10. <noframes>11. <strike>12. <tt>13. <u>
    • 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, differentbrowsers may have different plug-ins.HTML5 defines a new element which specifies a standard way to embed avideo/movie on a web page: the <video> element. Example <!DOCTYPE html /> <html> <body> <video width="320" height="240" controls="controls"> <source src="2.mp4" type="video/mp4" /> </video> <br> <video width="320" height="240" controls="controls"> <source src="1.wmv" type="video/wmv" /> Your browser does not support the video tag. </video> </body> </html>
    • Video Formats and Browser SupportBrowser MP4 WebM OggInternet Explorer 9 YES NO NOFirefox 4.0 NO YES YESGoogle Chrome 6 YES YES YESApple Safari 5 YES NO NOOpera 10.6 NO YES YES
    • 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, differentbrowsers may have different plug-ins.HTML5 defines a new element which specifies a standard way to embed an audio fileon a web page: the <audio> element.Example<!DOCTYPE html><html><body><audio controls="controls"> <source src="audio.mp3" type="audio/mpeg" />Your browser does not support the audio element.</audio></body></html>Note : You should also insert text content between the <audio> and </audio> tags for browsers that do notsupport the <audio> element.
    • Audio Formats and Browser SupportBrowser MP3 Wav OggInternet Explorer 9 YES NO NOFirefox 4.0 NO YES YESGoogle Chrome 6 YES YES YESApple Safari 5 YES YES NOOpera 10.6 NO YES YES
    • The meter element defines a scalar measurement within a known range, similar towhat might be represented by a gauge.The progress element, which defines completion progress for some task.Commonly, this element might represent the percentage from 0 percent to 100percent of a task, such as loading to be completed:<!DOCTYPE html><html><body><p>Progress: <progress id="progressBar" max="100.00" value="33.1">33.1%</progress></p><br><p>Warp Drive Output: <meter min="0" max="10" low="3" optimum="7" high="9"value="9.5" title="Captain she cant take much more of this!"></meter></p><input type="submit" /></form></body></html>
    • HTML5 has added following 3 Form Elements1. <datalist>2. <keygen>3. <output>
    • 1. The <datalist> element specifies a list of pre-defined options for an <input> element.2. 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.3. Use the <input> elements list attribute to bind it together with a <datalist> element. <!DOCTYPE html> <html> <body> <form action="demo_form.asp" method="get"> <input list="browsers" name="browser" /> <datalist id="browsers"> <option value="Internet Explorer"> <option value="Firefox"> <option value="Chrome"> <option value="Opera"> <option value="Safari"> </datalist> <input type="submit" /> </form> </body> </html>
    • 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 keycould be used to generate a client certificate to authenticate the user in the future. <!DOCTYPE html> <html> <body> <form action="demo_keygen.asp" method="get"> Username: <input type="text" name="usr_name" /> Encryption: <keygen name="security" /> <input type="submit" /> </form> </body> </html>
    • The <output> element represents the result of a calculation (like one performed by ascript).<!DOCTYPE html><html><body><form oninput="x.value=parseInt(a.value)+parseInt(b.value)">0<input type="range" name="a" value="50" />100+<input type="number" name="b" value="50" />=<output name="x" for="a b"></output></form></body></html>
    • Traditionally, the HTML input element is used to define most form fields. The particulartype of form field of interest is defined with the type attribute, which is set to text,password, hidden, checkbox, radio, submit, reset, image, or button. HTML5 adds quitea number of other values, which we will briefly explore here.
    • <p><label>color:<input type="color" name="favColor"></label></p>As of the time of this edition’s writing, no implementation existed for this control, but itmight look something like this:
    • A variety of date controls can now be directly created by setting the type attribute todate, datetime, datetime-local, month, week, or time.<p><label>date:<input type="date" name="date"></label></p><p><label>datetime:<input type="datetime" name="datetime"></label></p><p><label>datetime-local:<input type="datetime-local" name="datetime2"></label></p><p><label>time:<input type="time" name="time"></label></p><p><label>month:<input type="month" name="month"></label></p><p><label>week:<input type="week" name="week"></label></p>
    • <!DOCTYPE html><html><body><form action="http://www.google.com"><p><label>number:<input type="number" name="number"></label></p><input type="number" name="number2" min="-5" max="25" step="5"></form></body></html>
    • <!DOCTYPE html><html><body><form action="http://www.google.com"><input type="range" name="range" max="100" min="1" step="5"><p><label>range (1-100 step 5): <input type="range" name="range" max="100" min="1" step="5"></label></p><p><label>range (-1000-1000 step 100):<input type="range" name="range" max="1000" min="-1000" step="100"></label></p><p><label>range (-.25 to 3.0)<input id="slider3" type ="range" min ="-2.5" max="3.0"step ="0.1"/></form></body></html>
    • The new details element is supposed to represent some form of extra details, such as atooltip or revealed region that may be shown to a user <details onclick="this.open=open"> <dt>Help?</dt> <dd>This could give you help with HTML5 but we need more implementations to prove how things will work.</dd> </details>
    • <!DOCTYPE html><html><body><label>Text area: (spellcheck on) <textarea name="comments"spellcheck="true">There is a tyyypooo here. Did the browser spot it?</textarea></label></body></html>
    • 1. <input type="color" name="favcolor" />2. <input type="date" name="bday" />3. <input type="datetime" name="bdaytime" />4. <input type="datetime-local" name="bdaytime" />5. <input type="email" name="usremail" />6. <input type="month" name="bdaymonth" />7. <input type="number" name="quantity" min="1" max="5" />8. <input type="range" name="points" min="1" max="10" />9. <input type="tel" name="usrtel" />10. <input type="time" name="usr_time" />11. <input type="url" name="homepage" />12. <input type="week" name="week_year" />
    • <!DOCTYPE html><html><body><p contenteditable="true">This paragraph of text is editable. Click it and you will see.Of course there is no sense of saving it with code to transmit the information to theserver. This paragraph of text is editable. Click it and you will see. Of course there is nosense of saving it with code to transmit the information to the server.</p></body></html>
    • <!DOCTYPE html><html><body><label for="phonenum" class="required">Phone Number:</label><input type="text" name="phonenum" id="phonenum"required pattern="^(d{3}) d{3}-d{4}$"title="Phone number of form (xxx) xxx-xxxx required"><input type="submit" value="go to goole "/></form></body></html>
    • The pattern attribute specifies a regular expression that the <input> elements value ischecked against.Note: The pattern attribute works with the following input types: text, search, url, tel,email, and password.<!DOCTYPE html><html><body><form action="demo_form.asp"> Country code: <input type="text" name="country_code"pattern="[A-Za-z]{3}" title="Three letter country code" /> <input type="submit" /></form></body></html>
    • The required attribute is a boolean attribute. When present, it specifies that an inputfield must be filled out before submitting the form.Note: The required attribute works with the following input types: text, search, url,tel, email, password, date pickers, number, checkbox, radio, and file.<!DOCTYPE html><html><body><form action="demo_form.asp"> Username: <input type="text" name="username" required="required" /> <input type="submit" /></form></body></html>
    • The placeholder attribute specifies a short hint that describes the expected value of aninput fieldNote: The placeholder attribute works with the following input types: text, search, url,tel, email, and password.<!DOCTYPE html><html><body><form action="demo_form.asp"> <input type="text" name="fname" placeholder="First name" /><br /> <input type="text" name="lname" placeholder="Last name" /><br /> <input type="submit" value="Submit" /></form></body></html>
    • The email type is used for input fields that should contain an e-mail address. <!DOCTYPE html> <html> <body> <form action="demo_form.asp"> E-mail: <input type="email" name="usremail" /><br /> <input type="submit" /> </form> </body> </html>
    • The novalidate attribute is a boolean attribute. When present, it specifies that theform-data (input) should not be validated when submitted.<!DOCTYPE html><html><body><form action="demo_form.asp" novalidate>E-mail: <input type="email" name="useremail" required/><input type="submit" /></form></body></html>
    • The autofocus attribute is a boolean attribute. When present, it specifies that an<input> element should automatically get focus when the page loads. <!DOCTYPE html> <html> <body> <form action="demo_form.asp"> First name:<input type="text" name="fname" autofocus="autofocus" /><br /> Last name: <input type="text" name="lname" /><br /> <input type="submit" /> </form> </body> </html>
    • The form attribute specifies one or more forms an <input> element belongs to. Tip: To refer to more than one form, use a space-separated list of form ids.<!DOCTYPE html><html><body><form action="demo_form.asp" id="form1">First name: <input type="text" name="fname" /><br /><input type="submit" value="Submit" /></form><p>The "Last name" field below is outside the form element, but still part of the form.</p>Last name: <input type="text" name="lname" form="form1" /></body></html>
    • The formaction attribute specifies the URL of a file that will process the input control when the form is submitted. The formaction attribute overrides the action attribute of the <form> element<!DOCTYPE html><html><body><form action="demo_form.asp"> First name: <input type="text" name="fname" /><br /> Last name: <input type="text" name="lname" /><br /> <input type="submit" value="Submit" /><br /> <input type="submit" formaction=“Page2.aspx" value="Submit as admin" /></form></body></html>
    • The formmethod attribute defines the HTTP method for sending form-data to theaction URL. The formmethod attribute overrides the method attribute of the <form>element.<!DOCTYPE html><html><body><form action="demo_form.asp" method="get"> First name: <input type="text" name="fname" /><br /> Last name: <input type="text" name="lname" /><br /> <input type="submit" value="Submit" /> <input type="submit" formmethod="post" formaction="demo_post.asp" value="Submitusing POST" /></form></body></html>
    • The novalidate attribute is a boolean attribute. When present, it specifies that the<input> element should not be validated when submitted. The formnovalidate attributeoverrides the novalidate attribute of the <form> element <!DOCTYPE html> <html> <body> <form action="demo_form.asp"> E-mail: <input type="email" name="userid" /><br /> <input type="submit" value="Submit" /><br /> <input type="submit" formnovalidate="formnovalidate" value="Submit without validation" /> </form> </body> </html>
    • Value Description _blank The response is displayed in a new window or tab _self The response is displayed in the same frame (this is default) _parent The response is displayed in the parent frame _top The response is displayed in the full body of the window framename The response is displayed in a named iframe<!DOCTYPE html> <html> <body><form action="demo_form.asp"> First name: <input type="text" name="fname" /><br /> Last name: <input type="text" name="lname" /><br /> <input type="submit" value="Submit as normal" /> <input type="submit" formtarget="_blank" value="Submit to a new window/tab" /></form></body></html>
    • HTML5 defines a standard way to include developer-defined data attributes in tags,often for the consumption by scripts. The general idea is to use the prefix data- andthen pick a variable name to include some non-visual data on a tag.<p id="p1" data-author="Thomas A. Powell">This is a data-X example</p>Reading meta data using Standard Dom<form><input type="button" value="Show Author" onclick="alert(document.getElementById(p1).getAttribute(data-author)); "></form>HTML5 DOM objects and properties<form><input type="button" value="Show Author" onclick="alert(document.getElementById(p1).dataset.author);"></form>
    • 1. The HTML5 <canvas> element is used to draw graphics, on the fly, via scripting (usually JavaScript).2. The <canvas> element is only a container for graphics, you must use a script to actually draw the graphics.3. A canvas is a drawable region defined in HTML code with height and width attributes.4. Canvas has several methods for drawing paths, boxes, circles, characters, and adding images.<canvas id="myCanvas" width="200" height="100"></canvas>Note : The <canvas> element has no drawing abilities of its own. All drawing mustbe done inside a JavaScript:
    • <!DOCTYPE html><html><body><canvas id="myCanvas" width="200" height="100" style="border:1px solid #c3c3c3;">Your browser does not support the canvas element.</canvas><script type="text/javascript“>var c=document.getElementById("myCanvas");var ctx=c.getContext("2d");ctx.fillStyle="#FF0000";ctx.fillRect(0,0,150,75);</script></body></html>
    • The HTML5 Geolocation API is used to get the geographical position of a user. Since thiscan compromise user privacy, the position is not available unless the user approves it.1. It usages Use the getCurrentPosition() method to get the users positionThe getCurrentPosition() Method return following informationProperty Descriptioncoords.latitude The latitude as a decimal numbercoords.longitude The longitude as a decimal numbercoords.accuracy The accuracy of positioncoords.altitude The altitude in meters above the mean sea levelcoords.altitudeAccuracy The altitude accuracy of positioncoords.heading The heading as degrees clockwise from Northcoords.speed The speed in meters per secondtimestamp The date/time of the response
    • <!DOCTYPE html><html><body><p id="demo">Click the button to get your coordinates:</p><button onclick="getLocation()">Try It</button><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></body></html>http://abkeya.com/blog/2011/02/using-navigator-geolocation-getcurrentposition-to-display-user%E2%80%99s-current-location-on-google-map-and-getting-user-input/
    • 1. With HTML5, web pages can store data locally within the users browser.2. Earlier, this was done with cookies.3. Web Storage is more secure and faster. The data is not included with every server request, but used ONLY when asked for.4. It is also possible to store large amounts of data, without affecting the websites performance.5. The data is stored in key/value pairs, and a web page can only access data stored by itselfThere are two new objects for storing data on the client:1. localStorage - stores data with no expiration date2. sessionStorage - stores data for one session
    • The localStorage object stores the data with no expiration date. The data will not bedeleted when the browser is closed, and will be available the next day, week, or year.<!DOCTYPE html><html><body><div id="result"></div><script>if(typeof(Storage)!=="undefined") { localStorage.lastname="Smith"; document.getElementById("result").innerHTML="Last name: " + localStorage.lastname; }else { document.getElementById("result").innerHTML="Sorry, your browser does not support web storage..."; }</script></body></html>
    • The sessionStorage object is equal to the localStorage object, except that it stores thedata for only one session. The data is deleted when the user closes the browser window
    • <!DOCTYPE html><html> <head> <script>function clickCounter(){if(typeof(Storage)!=="undefined") { 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 thissession."; }else { document.getElementById("result").innerHTML="Sorry, your browser does not support web storage..."; }}</script> </head> <body> <p><button onclick="clickCounter()" type="button">Click me!</button></p><div id="result"></div> <p>Click the button to see the counter increase.</p><p>Close the browser tab (or window), and try again, and the counter is reset.</p> </body></html>
    • 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:1. Offline browsing - users can use the application when theyre offline2. Speed - cached resources load faster3. Reduced server load - the browser will only download updated/changed resources from the server
    • 1. To enable application cache, include the manifest attribute in the documents <html> tag:2. Every page with the manifest attribute specified will be cached when the user visits it.3. If the manifest attribute is not specified, the page will not be cached (unless the page is specified directly in the manifest file).4. The recommended file extension for manifest files is: ".appcache”5. A manifest file needs to be served with the correct MIME-type, which is "text/cache-manifest". Must be configured on the web server.
    • The manifest file is a simple text file, which tells the browser what to cache. The manifest file has three sections: 1. CACHE MANIFEST - Files listed under this header will be cached after they are downloaded for the first time 2. NETWORK - Files listed under this header require a connection to the server, and will never be cached 3. FALLBACK - Files listed under this header specifies fallback pages if a page is inaccessibleabc.appcacheCACHE MANIFEST <!DOCTYPE html># 2012-02-21 v1.0.0 <html lang="en" manifest="/abc.appcache">/theme.css/logo.gif // your html document/main.js </html>NETWORK:login.aspFALLBACK:/html5/ /offline.html
    • Cache Expires on any of the following cases.1. The user clears the browsers cache2. The manifest file is modified (see tip below)3. The application cache is programmatically updated
    • HTML5 Replacement of Flashhttp://www.techrepublic.com/blog/webmaster/how-to-replace-flash-and-silverlight-with-html5/995HTML5 for Mobilehttp://www.engineyard.com/blog/2011/mobile-development-with-html5/http://www.mobilehtml5.com/HTML5 for Storagehttp://diveintohtml5.info/storage.htmlhttp://php-html.net/tutorials/html5-local-storage-guide/HTML Cachehttp://html5doctor.com/go-offline-with-application-cache/