Blogroll

photoshop cs6 html 5 css php seo backlinks

adsense

Smarty Template Engine Step by Step Tutorial

Smarty has focused on how to help you make an high-performance, scalability, security and future growth application.

JavaScript was designed to add interactivity to HTML pages

JavaScript’s official name is ECMAScript, which is developed and maintained by the ECMA International organization.

This is default featured slide 3 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.

This is default featured slide 4 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.

This is default featured slide 5 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.

Showing posts with label html 5. Show all posts
Showing posts with label html 5. Show all posts

Thursday, 6 February 2014

Learn HTML 5 Drag and Drop free tutorial

Drag and drop

You can let readers drag and drop objects on your web page from one spot to another. Maybe they are taking a test or quiz (match objects to definitions, for example) or maybe it's a new way of dropping products into an online shopping cart. The one we'll build in this tutorial is just for fun though.
You need code that sets three things:
  • What you can drag: the image has draggable="true" on the event ondragstart and the script includes function drag(ev).
  • Where you can drop the object: event.preventDefault() on the event ondragover.
  • What happens when you drop the object: function drop(ev) on the event ondrop.
Try it yourself by setting draggable="true" on any element in your page (like an image or paragraph) and then try dragging it around. Just setting draggable lets you drag, but you can't drop it anywhere.
Here's the full code for it:
Drag and drop
 
 <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>

   <img id="img1" src="puzzle1.png" ondrop="drop(event)"
   ondragover="allowDrop(event)"></div>

   <img id="img2" src="puzzle2.png" draggable="true"
   ondragstart="drag(event)">

 </body>
 
 
Try the full code by copying/pasting and then changing the src attribute value to point to a graphic you have.
Let's walk through what is going on here. In the first part of the script, we have the code that allows us to drop the object. We have to override the default behaviour, which is to NOT let objects be dropped anywhere.
Allowing an element to be dropped
 
 <head>
   <script>
     function allowDrop(ev)
       {
       ev.preventDefault();
       }
 
 
Next, we have the drag portion of the script which sets the type of information that is being dragged.
Drag
 
 function drag(ev)
   {
   ev.dataTransfer.setData("Text",ev.target.id);
   }
 
 
Next, we have the drop portion of the code, which sets the place where you can drop the object.
Drop
 
   function drop(ev)
     {
     ev.preventDefault();
     var data=ev.dataTransfer.getData("Text");
     ev.target.appendChild(document.getElementById(data));
     }
 </script>
 
 
Next, we have our HTML code that specifies which object is draggable and invokes the JavaScript using the ondrop and ondragover events on the place to drop it and the ondragstart event on the object to drag.
 
 <body>

   <img id="img1" src="puzzle1.png" ondrop="drop(event)"
   ondragover="allowDrop(event)"></div>

   <img id="img2" src="puzzle2.png" draggable="true"
   ondragstart="drag(event)">

 </body>
 
 
Try it out with your own graphic!
If you've made it this far (and I know you have!), you are officially no longer new at HTML5! You have used advanced code to add some pretty awesome features to your web pages. You are now ready to build some pretty great pages and to learn more about CSS and Javascript.

Learn HTML 5 Web Storage free tutorial

Web storage

A cookie is a small text file saved on the user's hard drive in which a website can store different information. But HTML5 lets you store data inside the web page instead of using cookies. This makes the web page faster and more secure. You can actually store quite a bit of data in the web page without making the page slow to load.
Below, we've included code that lets people like a page.
Web storage for "Like this page"
 
 <head>
   <script>
     function clickCounter()
       {
       if(typeof(Storage)!=="undefined")
         {
         if (localStorage.clickcount)
           {
           localStorage.clickcount=Number(localStorage.clickcount)+1;
           }
         else
           {
           localStorage.clickcount=1;
           }
         document.getElementById("result").innerHTML= + localStorage.clickcount + " people have liked this page.";
         }
       else
         {
         document.getElementById("result").innerHTML="Your browser does not support web storage.";
         }
       }
   </script>
 </head>

 <body>
   <p><button onclick="clickCounter()" type="button">Like!</button></p>
   <div id="result"></div>
 </body>
 
 
Let's walk through the details of this script. First we call the function clickCounter, which counts the number of times something is clicked.
  
  <head>
  <script>
  function clickCounter()
  
 
Next, we have a nested if, else, then. It first determines if there's any information already stored in web storage (someone has already click at least once) and then increments that number by 1 each time.
The else is for the circumstance where the click is actually the very first click, so make that number equal to 1.
 
 {
 if(typeof(Storage)!=="undefined")
   {
   if (localStorage.clickcount)
     {
     localStorage.clickcount=Number(localStorage.clickcount)+1;
     }
   else
     {
     localStorage.clickcount=1;
     }
 
 
We then fetch the HTML element by ID and add the number of clicks plus some text. We also handle the circumstance where someone's browser doesn't support web storage at all and give them a little error message: Your browser does not support web storage. We finally end the script.
 
   document.getElementById("result").innerHTML= + localStorage.clickcount + " people have liked this page.";
   }
 else
   {
   document.getElementById("result").innerHTML="Your browser does not support web storage.";
   }
 }
 </script>
 
 
Next, we have the HTML code (the button) that calls this JavaScript. The button has an onclick event that correlates to the name of the function:clickCounter().
 
 <body>
   <p><button onclick="clickCounter()" type="button">Like!</button></p>
 
 
After that, we have a place where the results will be displayed once the button is clicked. Note that the ID in the <div> element correlates to the ID in the script above.
 
   <div id="result"></div>
 </body>
 
 
Copy and paste the entire code above and put it into a new page. This API can run locally, so you don't need to upload the page to the internet unless you want to.
The point that you should take away here is that the number of times someone has clicked the button is stored on the web, not in a cookie or any other location. Although we've demonstrated Local Storage, there is also a different kind called Session Storage, which only lasts until that web browser session is running. When someone closes their browser, it resets.
You could use web storage for a number of different purposes:
  • User preferences
  • Localization (language they use)
  • Saving products in a shopping cart (emptied after a session or remembered the next time they visit?)
  • Creating a to do list
  • Anything else where you want input/choices to persist for a session or forever

Learn HTML 5 Geolocation: You Are Here free tutorial

Geolocation

Geolcation is an API that returns and can display your physical location in the world. It can be displayed as coordinates (latitude and longitude) or using a map. Please notice how your browser will prompt you before allowing trusted sites to run this API. Privacy is always a concern, so you can't force anyone to use this API.
Geolocation is built from two things:
  1. A button that invokes the script to get coordinates.
  2. A script that actually fetches and displays the coordinates (or displays a message if the browser doesn't support it).
The function for geolocation is called getCurrentPosition(). We call the function using getLocation() both in the button element and in the script that follows.
Here's the full code script for a page with simple geolocation. We will then walk through it piece by piece.
HTML:
 
 <p id="html.net">Where are you in the world?</p>
 <button onclick="getLocation()">Get Coordinates</button>
 
 
Javascript:
 
 <script>

   function getLocation()
     {
     if (navigator.geolocation)
       {
       navigator.geolocation.getCurrentPosition(showPosition);
       }
     else
    { 
    document.getElementById("html.net").innerHTML="Geolocation is not supported by this browser.";
    }
     }
     
   function showPosition(position)
     {
     document.getElementById("html.net").innerHTML="Latitude: " + position.coords.latitude +
     "<br>Longitude: " + position.coords.longitude;
     }

 </script>
 
 
First, let's take a look at the HTML. It includes an ID that is later fetched in the script (id="html.net") as well as an event on the button and the name of the function we are calling: getLocation(). This code might be anywhere on your page.
Next, let's walk through the Javascript. We start the script element (remember, this is either placed in the <head> element or before the </body> tag). Thereafter, we invoke the geolocation function itself.
 
 function getLocation()
 
 
After that, we cover the situation for when geolocation is not supported by the browser version or because they have JavaScript turned off. In that circumstance, the following message will display: Geolocation is not supported by this browser.
 
 function getLocation()
   {
   if (navigator.geolocation)
     {
     navigator.geolocation.getCurrentPosition(showPosition);
     }
   else
     {
     document.getElementById("html.net").innerHTML="Geolocation is not supported by this browser.";
     }
   }
 
 
After that, we actually call another function because we don't just want to get the location; we also want to display it to the reader as coordinates.
 
 function showPosition(position)
   {
   document.getElementById("html.net").innerHTML="Latitude: " + position.coords.latitude +
   "<br>Longitude: " + position.coords.longitude;
   }
 
 
The text inside the quotes can be modified. It's what people will see, followed by their actual latitude and longitude.
Then you end your script with </script> and it's all complete.

Show using Google Maps

If you want to show a map of the coordinates, you need to add replace the script above with a connector to the map generator you want, such as Google Maps.
 
 function showPosition(position)  
   {
   var latlon=position.coords.latitude+","+position.coords.longitude;
   var img_url="http://maps.googleapis.com/maps/api/staticmap?center="
   +latlon+"&zoom=14&size=400x300&sensor=false";
   document.getElementById("html.net").innerHTML="<img src='"+img_url+"'>";
   }
 
 

Learn HTML 5 Advanced APIs free tutorial

HTML5 and JavaScript

HTML5 gives you the ability to include some advanced features and interactions that can really add some interesting features to your website.
The challenge is that none of them is pure HTML5 code. They all require a combination of HTML and JavaScript, which is a more advanced coding language. I know, I know, another language!
HTML, CSS, and JavaScript often all work together in coordination to give us some great websites. When you get to the more advanced HTML functionality, you need to start learning more. But we'll make this as painless as possible. Now that you understand HTML, it's much easier to learn JavaScript.
So let's learn some very basic JavaScript! You'll learn more later by taking the JavaScript Tutorial, but for now, all you need is some basics.

Introduction to JavaScript

JavaScript functions are the backbone of JavaScript. They connect your HTML elements with actually doing something. A function looks like this:
 
 function functionName()
 
 
A function always has some sort of code following it that defines what action should occur. The code is between curly brackets { } and usually ends with a semicolon.
Functions always occur inside <script> elements. And <script> elements are either put in your <head> or right before the </body> element. If you have a lot of JavaScript running on a page, you should put them as low as you can on the page so they won't affect the speed of loading your page. For now, you can just put them in the <head> element.
A full JavaScript script looks like this:
 
 <head>
   <script>
     function functionName()
     {
     some code;
     }
   </script>
 </head>
 
 
In your HTML, you "call" your script by adding its name and event to an element, like a button. Events could be, for example, onclick or onhover where somthing happens (the event) when you click or hover the element, respectively. There are a number of other events that you'll learn about in the JavaScript tutorial.
Calling a script
 
 <button onclick="functionName()">Go!</button>
 
 
JavaScript can do all sorts of things, but one of the most important is to be able to use some logic that says "If...then...else". So "If you're browser supports geolocation, then show coordinates. Else, show this error message."
If, then, else example
 
 if (navigator.geolocation)
   {
   navigator.geolocation.getCurrentPosition(showPosition);
   }
 else
   {
   x.innerHTML="Geolocation is not supported by this browser.";
   }
 
 
That's all you need to know about Javascript for now. In the next lesson we will take a closer look at geolocation.

Learn HTML 5 Video and Audio

Videos

We've all gotten used to using YouTube or Vimeo (or others) to embed videos into our website. This is because there has been no general video player that people can all use. A plug-in like Flash, for example, had to be installed (with the right version) and still introduced some major problems, like poor usability and taking up major bandwidth
HTML5 introduced a new <video> element that means you don't need YouTube but also doesn't require a plug-in! [Warning: This is not true for all browsers. Internet Explorer 9+ requires Microsoft Media Player and Safari requires Quicktime to be installed.]
The coding is fairly simple to add a video to your web page.
Video
 
 <video width="320" height="240" controls>
   <source src="movie.mp4" type="video/mp4">
   Your browser does not support HTML5 videos. 
 </video> 
 
 
The height and width let the browser know how much space it needs to display the video. The controls attribute adds the Play/Pause controls we've all come to expect. The src needs to point to the location of your movie file (and don't forget to upload that file too when you move files onto the internet using the FTP client).
There are three types of videos supported: MP4, WebM, and Ogg. At this time, no one type of video is supported by all browsers. MP4 formats are not supported on FireFox 3.6+ or Opera 10.6+. Ogg is supported on those browsers, but not on Internet Explorer 9+ or Safari 5+. Right now, you've got all your bases covered if you have both MP4 and Ogg OR MP4 and WebM formats.
Both MP4 and OGG sources listed
 <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 HTML5 videos. 
 </video> 
 
 
Putting text inside the video element will cover the situation where the browser simply does not support the video for whatever reason.
If you have a video available, try it out yourself. Note: This code will only work if you're running this from the internet. If your page is still local, then you need to do this another way.
Local movie when page is local
 
 <input type="file" accept="video"/>
 <video controls autoplay></video>
 
 
This code lets you choose a video to play from your hard drive. Remember, it's not for use once you have your website up and running on the internet.

Audio

Like video, audio files had no standard way of being played other than by using a plug-in.
Now HTML5 has an <audio> element that you can use instead. You can play formats MP3, Wav, and Ogg, although, like video, none is supported on every browser. Use Wav+MP3 to cover all your bases.
Music
 
 <audio controls>
   <source src="music.wav" type="audio/wav">
   <source src="music.mp3" type="audio/mpeg">
   Your browser does not support the audio element.
 </audio>
 
 

Learn HTML 5 APIs

What is an API?

An API is an application programming interface, which is just a fancy way of saying that it's a way to send instructions between programmes. In this case, the instructions are between your web page and the browser to, for example, show a Google Map or offer a fullscreen view of your page.
Generally speaking, APIs are a way for you to offer more interactivity into your page.
Before HTML5, most APIs were written with JavaScript, an entirely different language. With HTML5, you can now add interactivity without having to always write JavaScript.

What kinds of APIs are there?

There are a lot of APIs you can use in HTML5, too many to cover in this tutorial, but we'll cover the big ones.
  1. Drawing: You can let people draw on your web page using the <canvas> tag. However, the canvas tag is just a holder… this one still needs JavaScript to actually draw.
  2. Audio/Video: You can now add a video right into your web page without having to embed a player or use YouTube. You can even add play/pause and other controls.
  3. Drag and drop: You can allow people to move things around on your page.
  4. Autofocus: Focusses the page on a specific item by moving the cursor there.
  5. Editable: You can make content editable. We mentioned this briefly in Lesson 16.
  6. History: You can add controls for going back or forward to specific pages or to relative pages (the page you were at before this one, for example).
There are a lot more HTML5 APIs and most of them require some knowledge or interaction with JavaScript as well.

Autofocus

The simplest API is autofocus. When the page loads, it takes your reader right to that spot. Let's try it on our forms page. Locate the country input box on your forms.htm page and add the autofocus="autofocus" attribute.
Autofocus
 
 <input autofocus="autofocus" type="text" list="country" name="countries">
 

How to create HTML 5 Forms? free tutorial

What is a form?

A form is a piece of web page that lets users enter their own information, like name and address. You would add a form when you want your readers to send you information.

Building a simple form

We are going to build a simple form that asks for someone to input their name and country. When they click "Submit" they get a response that says thank you.
We'll actually build two pages: one that has the form and another one that shows the message.
So get started by creating two new pages, name them and save them to the same folder.
Forms page: form.htm
 
   
 <body>

   <!--this is where your form will go-->  

 </body>

 
 
Output page: output.htm
 
 
 <body>

   <p>Thanks for your submission!</p>

 </body>

 
 
In your forms page, add the <form> element to your body.
Form element
 
 <form action="output.htm" method="get">     

 </form> 
 
 
In the action attribute, type in the name of your second file: your output page. The method attribute can be either get or post, but for our purposes, getis the easiest to use.
Let's add some content to our form. We're going to add two text fields that people can type in and a submit button that they click.
 
 <form action="output.htm" method="get">

   Name: <input type="text" name="name"><br>
   Country: <input type="text" name="countries"><br>  
   <input type="submit" value="Submit"> 
   

 </form>
 
 
When viewed from a browser, the results should look like this:
Name: 
Country: 
Try it out! Type in your name and country and click submit. You should get a new window or tab with the message that you put in your output page. After you click submit, notice that the URL address now includes the information you entered in the fields.
Congratulations, you've just created your very first form.

Getting fancy

Say you wanted someone to only have to type in the first few letters of their country instead of having to type in the whole thing. This is what we call an "autocomplete" feature.
Let's do that using a <datalist> element. First, add list attribute to your country input, then add the <datalist> with the same name as its ID (this is what connects them). Each line inside the datalist as its own option, showing the countries you want them to get prompted with.
Form with autocomplete
 
 <form action="output.htm" method="get">

   Name: <input type="text" name="name"><br>
   Country: <input type="text" list="country" name="countries">
    <datalist id="country">
     <option value="UK">
     <option value="Canada">
     <option value="USA">
     <option value="India">
     <option value="Brasil">
   </datalist>
   <br>
   <input type="submit" value="Submit">

 </form>
 
 
Save the file and try it out. Start typing USA and see what you get prompted with.
If you want to use radio buttons or checkboxes, you just change the input type from "text" to "checkbox" or "radio". Below is an example where we've added radio buttons with the second one selected by default using the checked="checked" attribute.
Form with radio buttons
 
 <form action="output.htm" method="get">

   Name: <input type="text" name="name"><br>
   Country: <input type="text" list="country" name="countries">  
   <datalist id="country">     
     <option value="UK">     
     <option value="Canada">     
     <option value="USA">     
     <option value="India">     
     <option value="Brasil">  
   </datalist><br>  
   Sex: <br>   
   <input type="radio" name="sex" value="Male"> Male<br>   
   <input type="radio" name="sex" value="Female" checked="checked"> Female<br>    
   <input type="submit" value="Submit"> 

 </form> 
 
 
Let's also add a comments area, where people can leave you feedback. Add that in right before the submit button.
 
 <textarea rows="4" cols="50">Leave us some comments 
 so we can improve this site!</textarea>
 
 
Try it out and play around with all the possibilities. Forms can get really complex and you can do all sorts of things, like make sure that a telephone is a telephone number or that the date has the correct format. For now, just play around with the basics and get familiar with all your options.
  • Drop-down menu: The reader gets to choose from a list of options.
Dropdown
 
 <select id = "myList">
   <option value = "1">one</option>
   <option value = "2">two</option>
   <option value = "3">three</option>
   <option value = "4">four</option>
 </select> 
 
 
  • Password: Reader enters their password in a text box and the text gets automatically converted to symbols.
Password
  
  Password: <input type="password">
  
 
  • Hidden fields: A field that isn't visible to readers, but can be used to pass information.
  
  <input type="hidden">
  
 
  • Cancel/reset button: Clears the form of all data. The value can be any text you want.
  
  <input type="reset" value="Cancel">

HTML 5 Invisible Things: Scripts, Metadata, Viewports, and Comments free tutorial

Scripts

Script tags are an easy way to link JavaScript or any other kinds of programming language into your HTML5 pages.
They are now also really easy to use. Somewhere in the body of your page, add the script element as follows:
Example of script
 
 <script>
   document.write("Hello from HTML.net!")
 </script>
 
 
Save the file and user your browser to try it out. It's not fancy, but any kind of script could be placed here, from something that calculates values to something that runs videos controls.
If you wanted to re-use a script over and over again on multiple pages, you would put that script in a .js file - just save a file with the extension .js instead of .htm - and refer to it from the script element whenever you need it.
Example of external script
 
 <script src="myscript.js"/>
 
 
HTML5 assumes that any script is by default JavaScript, so if you are using another language, you would have to set the type attribute as well.
You can also put scripts that control the entire page in the <head> or <footer> elements instead. Some best practices advocates say that putting labour-intensive scripts in the footer element, right before the </body> tag helps the page load faster as the browser read and show the simple HTML and CSS before it starts on the more complicated calculations in the script.

Metadata

Documents contain more than just the code and the content — they should also include metadata, which is information about the page. This information is not visible to readers, but does get used by the browser and by search engines.
We put metadata in the <head> element, where it can be read quickly by search engines.
The <meta> tag has a number of attributes and it is considered good practice to add the following four lines of <meta> tags to every page, but modifying the value of content in each case to match the sort of content you have on that page and who wrote it.
Example of metadata to add to every page
 
 <head> 
   <meta name="description" content="Free HTML5 tutorials"> 
   <meta name="keywords" content="HTML, CSS, JavaScript"> 
   <meta name="author" content="HTML.net"> 
   <meta charset="UTF-8"> 
 </head> 
 
 
The more exact your keywords and description, the more likely that your page will come back high on a search engine's list of results when someone searches for those particular terms.
The charset attribute is new for HTML5 and lets you specify the character set that you're using. It replaces this line in HTML4: <meta http-equiv="content-type" content="text/html; charset=UTF-8">. For English, the value is always UTF-8. If your content is Cyrillic, Greek, French or any other character set, you need to set it accordingly (Latin alphabet, for example, is ISO-8859). You can check this table for the right code if you're using another character set.

Viewports

There's one more thing to add in your metadata in the <head> element and that's a line that makes sure your content is somewhat visible no matter what sort of device someone is using to browse to your website: smartphone, tablet, laptop, or whatever else they might use.
 
 <head> 
   <meta name="description" content="Free HTML5 tutorials"> 
   <meta name="keywords" content="HTML, CSS, JavaScript"> 
   <meta name="author" content="HTML.net"> <meta charset="UTF-8"> 
   <meta name="viewport" content="width=device-width, initial-scale=1.0"> 
 </head> 
 
 
The content value sets the width of the page to the default width that the device's browser supports and also sets the starting zoom level at a value that will make most of the content visible on most devices, will change and update if they rotate the device, although they'll also be able to zoom in. There are many other properties possible here, like setting a maximum width in pixels, but the values we have given are an acknowledged best practice (as good as we can get) at this time.

Comments

Sometimes it can be awfully handy to leave yourself a note in the code. Maybe it's because you're organizing things or maybe it's because you need to remember why you did something in particular or who did something — who knows. It's really easy to add in a comment that doesn't get parsed by the browser — the browser skips right over it.
Like everything else, an HTML comment must be inside its own set of angled brackets, but the open bracket is immediately followed by the ! symbol and two dashes. To close a comment, add two more dashes and another angle bracket. You can have as much text between those symbols as you need, including other tags.
Example of HTML comments
 
 <!--Reminding myself to check this code for HTML5 validity--> 

 <!--Updated by AA on July 1--> 

 <!--This is a piece of code I'm going to troubleshoot <title>Notes</title> --> 
 
 
You now know how to control all those invisible things that you may never have known existed but that are awfully important and useful.

HTML 5 New Tags and Attributes free tutorial

Block and inline

Most HTML elements are either block-level elements or inline-level elements. Block-level elements just mean that those are the elements that define the structure of the site or they are elements that contain most of the content. Generally, they start on a new line. Examples: <h1><p><table><ul>.
Inline elements are found inside sentences usually and wouldn't indicate that content should start on a new line. Examples: <b><img><em>.

Structural elements

Structural elements are all block-level elements and help identify the type of content and the area on the page where that content will be placed.
A new structural element is <article>. It is meant for any content that you would consider full and complete on its own: a blog entry, a magazine article, a book, a thesis, a comment. It may have many sections (chapters, parts) to it.
The second structural element you need to know is a <section> and you use it for a section of an article. It's a logical grouping of information and the best test is whether you need a subtitle for it. If you want to stick a title on a subset of paragraphs, then you can use <section>.
Example 1: Article with a section
 
   <body>
     <article>   
       <h1>My Blog Entry</h1>   
       <p>This blog entry is my first.</p>
       <section>    
         <h2>What I Learned</h2>
         <p>HTML5 can have articles and sections.</p>
       </section>
     </article> 
   </body>
 
 
header and footer are the next new structural elements you need to know. They can hold all sorts of things, but this would be where you for example would put the title of your page (header) or your copyright information (footer).
Let's add those in.
 
  <body>

   <header>
     <h1>The name of this web page</h1>
     <p>Written by me!</p>
   </header>
   
  
   <article>   
     <h1>My Blog Entry</h1>   
     <p>This blog entry is my first.</p>
     <section>    
       <h2>What I Learned</h2>
       <p>HTML5 can have articles and sections.</p>
     </section>
   </article>

   <footer>
     <p> Copyright © 2013 All Rights</p>
   </footer>
   

 </body>
 
 
You can actually have many headers (and footers) in one page. You might have a header for the entire page and another header for the article. For the page, you would include the name of the web page. For the article, the header could be the title of the article as well as the author and date.

Classes

Classes are a handy little tool that attaches information to an element so you can do more things with some or all elements that belong to a certain class.
For example, if you wanted some of your articles to have a special border or font, you can identify those articles with a class.
 
 <body>
   <article class="fancy" > 
     <h1>My Blog Entry</h1>   
     <p>This blog entry is my first.</p>
   </article>
 </body>
 
 
Keep classes in mind as you start learning CSS — the piece that lets you format your page.

IDs

IDs, like classes, are metadata that you attach to elements. IDs are unique identifiers for a particular element. They must ALWAYS start with a letter, but you can add numbers afterwards.
You would set an ID on an element if you need to particularly do something with that element, like run some JavaScript on it or even set some unique styling on it.
 
 <button id="play1" onclick="play();">
   <image src="play_button.png"/>
 </button> 
 
 
You're most likely to use JavaScript on items that have interactivity. In this case, our play button needs to do something fancy. A piece of Javascript code can retrieve an element by its specific id of "play1" so that when someone clicks on the button (onclick), it will play whatever is needed — defined by the Javascript.
The details of Javascript are a little too advanced for this tutorial, but you do need to understand that adding the ID becomes an essential component of being able to add interactivity to your website.

Global attributes

There are 15 global attributes — attributes you can add to any element. The first and most important is the ID attribute, which we have already explained. You add it to any element you need to specially control.
Other cool attributes that are new to HTML5 include contenteditable, which makes an element's contents editable in the browser, draggable, which lets a user drag that element around, and translate, which can control whether the element's content is translated (or not translated!) when someone accesses it through a browser set up for a different language.
There are also an entire set of attributes specific to forms that we will look at in the next lesson.

Linking

You'll remember that links generally look like this:
 
 <a href="my_second_page.html">Second Page</a>
 
 
Well, what if you want that link to open a new browser window (so people don't navigate away from your site)?
The target attribute solves that problem. The target attribute specifies what happens in the browser when someone clicks the link. To open a new window or tab, use the _blank value.
 
 <a target="_blank" href="my_second_page.html">Second Page</a>
 
 
Try it yourself by linking one page to a second page that you've created. When you open the page with the link in the browser, as long as you havetarget="_blank" set, it will open a new tab or window.
You can also identify the type of link that you're using when you specify the rel attribute. You can set this on an <a> element, a <link> element, or an<area> element (a way to put hotspots on an image). This answers the question of why you are pointing to another page.
There are two categories of linking: links to external resources that augment the current document and hyperlinks, which just connects two pages together.
<link> to an external resource would be rel="stylesheet", which you will learn much more about in CSS tutorial. Most other types of linking would be just a regular hyperlink.
You might be wondering a bit about the difference between the <a> element and the <link> element. They both take the rel attribute, but the <a> element has something clickable inside it (a word, graphic, or button) while the link element doesn't display anything on the page — it's mostly used to link to resources, like a stylesheet.
There are a number of allowed values, but some of the notable ones are authoralternatehelpnextprevious, and search.
If the link above was connecting the first page of an article to the second page of an article, you would use the rel attribute with the next value.
 
 <a rel="next" href="my_second_page.html">Second Page</a>
 
 
If I was linking to the author's bio or website, I would use the author value instead. If I was linking to some Help document, I would put in the help value.

HTML5 — The New Tool in html5 tutorial

Going forward, HTML won't have a number version attached. Right now, we're still differentiating the old with the new by using the "5", but soon it won't be necessary. HTML will be what is known as a "living standard" — updated as it grows, piece by piece.
Already, the version doesn't matter too much. No browser supports everything in HTML5 yet but all of them support some of it. You always need to check with different browsers to see if your HTML code is coming out the way you want.

Tags mean what they say

The biggest change in HTML5 is that we now have a bunch of tags that mean what they say. So <header> is the header text of a page, <footer> is the footer text, <article> is…yes, you guessed it, used for an article — which could be any piece of writing that is meant to be self-contained like a blog entry, a magazine article, or anything else that is a complete piece of writing. Audiovideo… they all pretty much mean exactly what they are labelled.
These are called semantic (i.e. meaning) tags — and generally, you're going to try to use the tag that applies to the type of content you put inside them. Use the right tag for the right thing.

So, what new tools do I need in HTML5?

As in HTML4.0 and XHTML, a browser and text editor are all you really need.
There are some cool little tools that you can use in addition to Notepad that may make life a bit easier:
  • HTML5Reset: Take your old website designs and re-write as HTML5.
  • Liveweave: Test your HTML5 code in different browsers and play around with it.

Shiv

In old browsers HTML5 doesn't display correctly. This is where the HTML5Shiv comes in. It allows most of the old browsers to recognize the HTML5 tags and style them using CSS instead of HTML5. Therefore, consider include the shiv in every page so that anyone using an older browser can still see your website the way you intended.
HTML5Shiv
 
 <!DOCTYPE html>
 <html>
 
   <head>

     <!--[if lt IE 9]>
     <script
     src="http://html5shiv.googlecode.com/svn/trunk/html5.js">
     </script>
     <![endif]-->

     <title>Title</title>

   </head>

   <body>
     <p>text text</p>
   </body>

 </html>
 
 
This little piece of Javascript ensures that if someone is using Internet Explorer 6-9, Safari 4.x (and iPhone 3.x), and Firefox 3.x, that everything still looks and works ok.

Ok, let's continue

Using your text editor like Notepad, create a new file that looks like this:
 
 <!DOCTYPE html>
 <html>

   <head>
     <!--[if lt IE 9]>
     <script
     src="html5shiv.js">
     </script>
     <![endif]-->
     <title>My first HTML5 page!</title>
   </head>

   <body>
     <p>This is mynew HTML5 page.</p>
   </body>

 </html>
 
 
Save the file as .htm or .html and change Save as type to All, so you'll end up with page1.htm or page1.html.