Showing posts with label HTML5. Show all posts
Showing posts with label HTML5. Show all posts

Navigation

The HTML <nav> element is used to designate the main navigation links or the main menu system on your page. You are not required to put all links on your page into this kind of tag, just your main links. Its usefulness comes into play when certain software technologies accessing your document need to bypass this tag or treat it with specific behavior.

NOTE: This new element is HTML5 and will be a standardized element in 2014.

Example:

<nav id="mylinkset1">
  <p>Main links on my page wrapped in the nav element.</p>
  <a href="index.html">Home</a> &bull;
  <a href="services.html">Services</a> &bull;
  <a href="portfolio.html">Portfolio</a> &bull;
  <a href="contact.html">Contact</a>
</nav>

HTML5 Video Dom

After going through the previous chapter now you may have familiar with HTML5 Geolocation. Now in this chapter we will learn about the HTML5 Video Dom.
HTML5 Video Dom

Video Dom is such an enhanced feature, which make video playing more reliable and user friendly. With the help of Video Dom now you can customize the Video playing, as we can add additional buttons to play, stop, resize and many more.

Below is complete syntax along with example


<!DOCTYPE html>

<html>
    <head>
    <title>Title name will go here</title>
    </head>
    
    <body>
<video width="420" height="375" id="video1">
<source src="media/sample_video.mp4" type="video/mp4" />
<source src="your ogg media file name" type="video/ogg" />
Your browser does not support the video tag.
</video>
<button onclick="playPause()">Play/Pause</button>
<button onclick="makeBig()">Big</button>
<button onclick="makeSmall()">Small</button>
<button onclick="makeNormal()">Normal</button>
<script type="text/javascript">
var myVideo=document.getElementById("video1");
function playPause()
{
if (myVideo.paused)
myVideo.play();
else
myVideo.pause();
}

function makeBig()
{
myVideo.width=530;
}

function makeSmall()
{
myVideo.width=320;
}
function makeNormal()
{
myVideo.width=420;
}
</script>
       
    </body>
    
</html>

HTML Video Element

After going through the previous chapter you may have some knowledge about the TRACK Element. In this chapter we will learn about the VIDEO Element, which is supported by all measure browsers.

<video> . . . </video>

The VIDEO Element is used to play a movie or video clip on the website. Before the development of HTML5 VIDEO Element we were in compulsion to use the object and embed element and it's lengthy scripts. Now with the help of VIDEO Element this the VIDEO file can be called clean an on easy steps.

Here is the Syntax for VIDEO Element
<video> Some additional element will go inside </video>

Below is complete syntax along with example
<!DOCTYPE html>

<html>
    <head>
    <title>Title name will go here</title>
    </head>
    
    <body>
<video width="500" height="375" controls="controls">
<source src="media/sample_video.mp4" type="video/mp4"/>
<source src="your ogg media file name" type="video/ogg"/>
Your browser does not support the video tag.
</video>
        
    </body>
    
</html>

HTML5 SVG Element

After going through the previous chapter now you may have familiar with SUMMARY Element. In this chapter we will learn about the SVG Element. We will also see some differences between the CANVAS and SVG Element.

<svg> . . . </svg>

The SVG Element is used for graphical representation with HTML5. Sometimes we feel that we need to draw a graphic representation. If there is a recommendation not to use of graphical software then mandatory task will be to create with code section. In HTML5 We came to know about the CANVAS, by which we were able to create the graphical representation. But there was also a lot of codes and scripting we had to write for even a single image or 2D output.

Now the new feature of HTML5 is SVG ELEMENT (Scalable Vector Graphics Element), by which we can also draw the graphical representation. There are some certain additional features, we would like to introduce it in blow given list.


✔ It defines the Vector based graphics

✔ The script of SVG is in XML format

✔ Since it is vector based graphics, So there is no any chance to loose the quality even on zoomed situation

✔ Every independent element can be animated also

✔ It is the recommendation of W3C

Here is the Syntax for SVG Element
<svg> The additional element will go here </svg>
<!DOCTYPE html>

<html>
    <head>
    <title>Title name will go here</title>
    </head>
    
    <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"/>
</svg>
        
    </body>
    
</html>

HTML5 Geolocation

After going through the previous chapter now you may have familiar with HTML5 Drag and Drop Event. Now in this chapter we will learn about the HTML5 Geolocation.

HTML5 Geolocation

Approx three years ago when mobile android devices came in to boom, and today we are surrounded by the many of smartphones and also now we are addicted to use it. In the present scenario the smartphone is not only for the voice interaction purpose but more than that. Now with development of HTML5 We can use the tracking of Geolocation and not only the latitude displaying but also we can view the digital map with HTML5 Geolocation features. Though We can use it on browser also, but it best suit on android or smartphone.

HTML5 Geolocation is basically used to locate the position of current internet user.

Below is complete syntax along with example

<!DOCTYPE html>

<html>
    <head>
     
<title>Title name will go here</title>

    </head>
    
    <body>
   
<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script>
 
<script type="text/javascript">
 
var x=document.getElementById("mapp");
function getLocation()
  {
  if (navigator.geolocation)
    {
    navigator.geolocation.getCurrentPosition(showPosition,showError);
    }
  else
{
x.innerHTML="Geolocation is not supported by this browser.";
}
  }
function showPosition(position)
  {
  lat=position.coords.latitude;
  lon=position.coords.longitude;
  latlon=new google.maps.LatLng(lat, lon)
  display=document.getElementById('display')
  display.style.height='250px';
  display.style.width='525px';
  var myOptions={
  center:latlon,zoom:14,
  mapTypeId:google.maps.MapTypeId.ROADMAP,
  mapTypeControl:false,
  navigationControlOptions:{style:google.maps.NavigationControlStyle.SMALL}};
  var map=new google.maps.Map(document.getElementById("display"),myOptions);
  var marker=new google.maps.Marker({position:latlon,map:map,title:"You are here!"});
  }

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;
    }
  }
 
</script>
<p id="mapp">Click on the button to see your current location. <button onclick="getLocation()">DEMO</button> </p>
<div id="display"></div>
        
    </body>
    
</html>

HTML5 Drag and Drop

After going through the previous chapter you may have familiar with WBR Element, which is the end of the HTML5 Elements Tutorial. Now from here let's start some additional advantages of HTML5.

Drag and Drop in HTML5

The Drag and Drop Event is the most fabulous properties of HTML5. With the help of Drag and Drop features We can move an object from one place to another place. The all measure browsers support the dragging except of Safari 5.1.2. In the process of dragging an object we have to just grab an object from its original place and leave it or drag it in the specified area. All the process is done with the help of Java Script. The Drag and Drop Event may be a little bit complex but we have tried to make it very simple just take a look at below of the page for detail descriptions.

Below is complete syntax along with example

<!DOCTYPE html>

<html>
    <head>
     
<title>Title name will go here</title>
 
<style>
#div1 {width:200px;height:150px;padding:10px;border:1px solid green;}
#div2 {width:200px;height:150px;padding:10px;border:1px solid green;}
 
</style>
 
<script type="text/javascript">
 
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)">
<img id="drag1" src="images/html5_logo.png" alt="html5 tutorial" draggable="true" ondragstart="drag(event)" id="drag1"/>
<p>Drag the image to another DIV.</p>
</div>
<div id="div2" ondrop="drop(event)" ondragover="allowDrop(event)">
</div>
        
    </body>
    
</html>

HTML5 Canvas Element

After going through the previous chapter now you may have a solid understanding of BDI Element. So now just lets learn another big boom of the HTML5 the CANVAS Element, the another solution of graphical representation.

<canvas> .... </canvas>

The another solution of graphical representation has been introduced with the develpment ofHTML5 as CANVAS Element. The CANVAS Element is incomplete without writing the JavaScript along with. So the CANVAS Element always followed by JavaScript also. The use of CANVAS Element has been built specially for graphical representation. A lot more affords has been reduced to use external plug-in like Photoshop and another Graphic Softwares. Still there is lot more can't be done with canvas but as creating the normal frame and graph it is sufficient. The another Element for graphical representation is SVG also. We will learn it in latter chapter and will try to do a snap differences between these elements also.

Here is the Syntax for CANVAS Element
<canvas>
    Some Text here
</canvas>
 
<script>
    Some codes of JavaScript
</script>

Below is complete syntax alogn with example

<!DOCTYPE html>
 
<html>
     
    <head>
         <title>Title name will go here</title>
    </head>
     
    <body>
 
    <canvas id="canvasuses" width="180" height="90">
    <p>Your browser does not support the HTML5 canvas element.</p>
    </canvas>
  
    <script type="text/javascript">
         
        var c=document.getElementById("canvasuses");
        var canvOK=1;
        try {c.getContext("2d");}
        catch (er) {canvOK=0;}
        if (canvOK==1)
            {
            var ctx=c.getContext("2d");
            var grd=ctx.createLinearGradient(0,0,200,0);
            grd.addColorStop(0,"green");
            grd.addColorStop(1,"white");
            ctx.fillStyle=grd;
            ctx.fillRect(10,10,150,80);
            }
     
    </script>
    </body>
     
</html>

HTML5 Audio

So after going though previous chapters you may have familiar with a few elements of HTML5. Now we will try to learn about a most popular element of HTML5, AUDIO Element. It is the one of the best powerful weapon of HTML5.

<audio> .... </audio>

With the development of HTML5, AUDIO Element has been introduced for playing the audio file in the browser with full user control support. Yet, before the development of HTML5 AUDIO Element, we were unable to play a audio file without using the third party browsers plug-in as flash player or quick time. Now the AUDIO Element can be used instead of installing a browser plug-in. The AUIDO Element contains an extra child element is called SOURCE, which is used to call the exact media file which we want to be played in the browser. The AUDIO Element can also contains it's properties for controlling the AUDIO File.


Here is the Syntax for AUDIO Element

<audio>
<source src="Place your audio file here with full path" type="audio/mpeg"/>
<source src="Place your audio file here with full path" type="audio/ogg"/>
</audio> 



Below is complete syntax alogn with example


<html>
<head>
<title>Title Name will go here</title>
</head>
<body>
<audio controls>
<source src="media/simple_audio.mp3" type="audio/mpeg"/>
<source src="media/simple_audio.ogg" type="audio/ogg"/>
<!-- This Line Will Be Called When You Are Running An Old Browser -->
<p>Your file doesn't support the audio element</p>
</audio>
</body>
</html> 

HTML5 Elements


HTML5 has been updated with few NEW ELEMENTS, which makes HTML5 more efficient markup language. We can reduce our external affords to use these NEW ELEMENTS. The Internet has changed since last development of HTML 4.01, So there are certain changes has been made in browser to use it more correctly. Few OLD ELEMENTS has been removed, where few NEW ELEMENTS has been updated in HTML5.

<aside> Defines content aside from the page content

<audio> Defines sound content

<bdi> Isolates a part of text that might be formatted in a different direction from other text outside it

<canvas> Used to draw graphics, on the fly, via scripting (usually JavaScript)

<command> Defines a command button that a user can invoke

<datalist> Specifies a list of pre-defined options for input controls

<defines> article an article

<details> Defines additional details that the user can view or hide

<embed> Defines a container for an external application or interactive content (a plug-in)

<figure> Specifies self-contained content, like illustrations, diagrams, photos, code listings, 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

<keygen> Defines a key-pair generator field (for forms)

<mark> Defines marked/highlighted text

<meter> Defines a scalar measurement within a known range (a gauge)

<nav> Defines navigation links

<output> Defines the result of a calculation

<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

<source> Defines multiple media resources for <video> and <audio>

<summary> Defines a visible heading for a <details> element

<track> Defines text tracks for <video> and <audio>

<time> Defines a date/time

<video> Defines a video or movie

<wbr> Defines a possible line-break