HTML5-An overview

HTML5-An overview

Fadıl

This site Learn HTML5.info aims at providing better exposure to HTML5 to the users. For more than a decade there has been no prominent updation in the HTML4 version. But once HTML5 was released a couple of years back it has been a hot topic for a while. Many interesting features have been added in the HTML5. for years users and the browsers have to depend on 3rd party plugins to play audio and video but now HTML5 has given a solution for that. Give us a chance to see a portion of the noticeable and interesting highlights of HTML5 in this instructional exercise HTML5 a presentation.

HTML5 form elements

HTML5 form elements

Fadıl

HTML5 has new form elements that previous versions of HTML did not feature.They are

  • <datalist></datalist>
  • <keygen></keygen>
  • <output></output>

<datalist> Element

The <datalist> element in HTML5 specify the options that can be included for an input field . This <datalist> element  will specify the list of options for an input field.

The <datalist> element specifies a list of options for an input field.<option> tag can be used to insert/create elements within the <datalist> tag.In order to bind a<datalist> element to an input field refer the list attribute of the input field to the data list id.

HTML5 Web Storage

HTML5 Web Storage

Fadıl

HTML5 comes with two objects for storing data in the client machine.

localstorage – There is no time limit for the data stored
sessionstorage – Data is stored for one session.

Cookies were used for this purpose, but cookies cannot be used if the data amount is large and they are also slow and ineffective as these cookies are passed to server on every request.
In HTML5 data is not passed every time whenever there is a server request. The data is sent only when the particular information is requested by the server. This will help a lot in increasing server performance.

Drag and drop – overview

Drag and drop – overview

Fadıl

The HTML5 – HTML series latest version comes with a drag and drops API. This feature allows the user to drag and drop the data within the website or with other websites.

This drag and drop feature allows the user to click and hold an element using the button in the mouse drag that element and drop into another location. That location may be the same site or another site. When the element is dragged from a location a translucent image follows the path that the mouse moves during this dragging operation.

A complex canvas example

A complex canvas example

Fadıl

In the previous post we saw about canvas using path and also using rectangles in this example we will see how to combine them to form a complex and at the same time an interesting composition.

&lt;html&gt;
  &lt;head&gt;
   &lt;script type="application/javascript"&gt;
 function drawBowtie(ctx, fillStyle) {

   ctx.fillStyle = "rgba(200,200,200,0.3)";
   ctx.fillRect(-30, -30, 60, 60);

   ctx.fillStyle = fillStyle;
   ctx.globalAlpha = 1.0;
   ctx.beginPath();
   ctx.moveTo(25, 25);
   ctx.lineTo(-25, -25);
   ctx.lineTo(25, -25);
   ctx.lineTo(-25, 25);
   ctx.closePath();
   ctx.fill();
 }

 function dot(ctx) {
   ctx.save();
   ctx.fillStyle = "black";
   ctx.fillRect(-2, -2, 4, 4);
   ctx.restore();
 }

 function draw() {
   var canvas = document.getElementById("canvas");
   var ctx = canvas.getContext("2d");

   // note that all other translates are relative to this
   // one
   ctx.translate(45, 45);

   ctx.save();
   //ctx.translate(0, 0); // unnecessary
   drawBowtie(ctx, "red");
   dot(ctx);
   ctx.restore();

   ctx.save();
   ctx.translate(85, 0);
   ctx.rotate(45 * Math.PI / 180);
   drawBowtie(ctx, "green");
   dot(ctx);
   ctx.restore();

   ctx.save();
   ctx.translate(0, 85);
   ctx.rotate(135 * Math.PI / 180);
   drawBowtie(ctx, "blue");
   dot(ctx);
   ctx.restore();

   ctx.save();
   ctx.translate(85, 85);
   ctx.rotate(90 * Math.PI / 180);
   drawBowtie(ctx, "yellow");
   dot(ctx);
   ctx.restore();
 }
    &lt;/script&gt;
  &lt;/head&gt;
  &lt;body onload="draw()"&gt;
    &lt;canvas id="canvas" width="300" height="300"&gt;&lt;/canvas&gt;
  &lt;/body&gt;
 &lt;/html&gt;

In the above example, we can find two methods drawbowtie and dot both these methods are called 4 times each. And the calls like translate(), rotate() are used to set transformation matrix which in turn positions the dot and the bowtie .dot function is used to place the small black square at (0,0). That dot is moved around by the transformation matrix .drawBowtie will create a very simple bowtie path using the passed-in fill style.
The functions save() and restore() are used to set the original canvas state.This rotation always occur around the current origin.Thus a translate() rotate() translate() sequence will yield different results than a translate() translate() rotate() series of calls.