Monday 28 March 2016

HTML5 WebSockets Tutorial

HTML5 WebSockets



Web Sockets is a next-generation bidirectional communication technology for web applications which operates over a single socket and is exposed via a JavaScript interface in HTML 5 compliant browsers.
Once you get a Web Socket connection with the web server, you can send data from browser to server by calling a send() method, and receive data from server to browser by an onmessage event handler.


Following is the API which creates a new WebSocket object.:
var Socket = new WebSocket(url, [protocal] );
Here first argument, url, specifies the URL to which to connect. The second attribute, protocol is optional, and if present, specifies a sub-protocol that the server must support for the connection to be successful.

Web Socket Attributes:


Following are the attribute of Web Socket object. Assuming we created Socket object as mentioned above:
Attribute
Description
Socket.readyState
The readonly attribute readyState represents the state of the connection. It can have the following values:
A value of 0 indicates that the connection has not yet been established.
A value of 1 indicates that the connection is established and communication is possible.
A value of 2 indicates that the connection is going through the closing handshake.
A value of 3 indicates that the connection has been closed or could not be opened.
Socket.bufferedAmount
The readonly attribute bufferedAmount represents the number of bytes of UTF-8 text that have been queued using send() method.

Web Socket Events:

Following are the events associated with Web Socket object. Assuming we created Socket object as mentioned above:

Event
Event Handler
Description
open

Socket.onopen
This event occurs when socket connection is established.
message

Socket.onmessage
This event occurs when client receives data from server.
error

Socket.onerror
This event occurs when there is any error in communication.
close

Socket.onclose
This event occurs when connection is closed.

WebSocket Methods:


Following are the methods associated with WebSocket object. Assuming we created Socket object as mentioned above:
Method
Description
Socket.send()
The send(data) method transmits data using the connection.
Socket.close()
The close() method would be used to terminate any existing connection.

WebSocket Example:

A WebSocket is a standard bidirectional TCP socket between the client and the server. The socket starts out as a HTTP connection and then "Upgrades" to a TCP socket after a HTTP handshake. After the handshake, either side can send data.
Client Side HTML & JavaScript Code:
At the time of writing this tutorial, there are only few web browsers supporting WebSocket() interface. You can try following example with latest version of Chrome, Mozilla, Opera and Safari.
<!DOCTYPE HTML>
<html>
<head>
<script type="text/javascript">
function WebSocketTest()
{
  if ("WebSocket" in window)
  {
     alert("WebSocket is supported by your Browser!");
     // Let us open a web socket
     var ws = new WebSocket("ws://localhost:9998/echo");
     ws.onopen = function()
     {
        // Web Socket is connected, send data using send()
        ws.send("Message to send");
        alert("Message is sent...");
     };
     ws.onmessage = function (evt)
     {
        var received_msg = evt.data;
        alert("Message is received...");
     };
     ws.onclose = function()
     {
        // websocket is closed.
        alert("Connection is closed...");
     };
  }
  else
  {
     // The browser doesn't support WebSocket
     alert("WebSocket NOT supported by your Browser!");
  }
}
</script>
</head>
<body>
<div id="sse">
   <a href="javascript:WebSocketTest()">Run WebSocket</a>
</div>
</body>
</html>

Install pywebsocket:

Before you test above client program, you need a server which supports WebSocket. Download mod_pywebsocket-x.x.x.tar.gz from pywebsocket which aims to provide a Web Socket extension for Apache HTTP Server ans install it following these steps.
Unzip and untar the downloaded file.
Go inside pywebsocket-x.x.x/src/ directory.
$python setup.py build
$sudo python setup.py install
Then read document by:
$pydoc mod_pywebsocket
This will install it into your python environment.
Start the Server
Go to the pywebsocket-x.x.x/src/mod_pywebsocket folder and run the following command:
$sudo python standalone.py -p 9998 -w ../example/
This will start the server listening at port 9998 and use the handlers directory specified by the -w option where our echo_wsh.py resides.
Now using Chrome browser open the html file your created in the beginning. If your browser supports WebSocket(), then you would get alert indicating that your browser supports WebSocket and finally when you click on "Run WebSocket" you would get Goodbye message sent by the server script

HTML5 Server Sent Events

HTML5 Server Sent Events

Conventional web applications generate events which are dispatched to the web server. For example a simple click on a link requests a new page from the server.
The type of events which are flowing from web browser to the web server may be called client-sent events.
Along with HTML5, WHATWG Web Applications 1.0 introduces events which flow from web server to the web browsers and they are called Server-Sent Events (SSE). Using SSE you can push DOM events continously from your web server to the visitor's browser.
The event streaming approach opens a persistent connection to the server, sending data to the client when new information is available, eliminating the need for continuous polling.
Server-sent events standardizes how we stream data from the server to the client.

Web Application for SSE:


To use Server-Sent Events in a web application, you would need to add an <eventsource> element to the document.
The src attribute of <eventsource> element should point to an URL which should provide a persistent HTTP connection that sends a data stream containing the events.
The URL would point to a PHP, PERL or any Python script which would take care of sending event data consistently. Following is a simple example of web application which would expect server time.
<!DOCTYPE HTML>
<html>
<head>
<script type="text/javascript">
/* Define event handling logic here */
</script>
</head>
<body>
<div id="sse">
   <eventsource src="/cgi-bin/ticker.cgi" />
</div>
<div id="ticker">
   <TIME>
</div>
</body>
</html>

Server Side Script for SSE:


A server side script should send Content-type header specifying the type text/event-stream as follows.
print "Content-Type: text/event-stream\n\n";
After setting Content-Type, server side script would send an Event: tag followed by event name. Following example would send Server-Time as event name terminated by a new line character.
print "Event: server-time\n";
Final step is to send event data using Data: tag which would be followed by integer of string value terminated by a new line character as follows:
$time = localtime();
print "Data: $time\n";
Finally, following is complete ticker.cgi written in perl:
#!/usr/bin/perl

print "Content-Type: text/event-stream\n\n";
while(true){
   print "Event: server-time\n";
   $time = localtime();
   print "Data: $time\n";
   sleep(5);
}

Handle Server-Sent Events:

Let us modify our web application to handle server-sent events. Following is the final example.
<!DOCTYPE HTML>
<html>
<head>
<script type="text/javascript">
   document.getElementsByTagName("eventsource")[0].
            addEventListener("server-time", eventHandler, false);
   function eventHandler(event)
   {
       // Alert time sent by the server
       document.querySelector('#ticker').innerHTML = event.data;

   }
</script>
</head>
<body>
<div id="sse">
   <eventsource src="/cgi-bin/ticker.cgi" />
</div>
<div id="ticker" name="ticker">
   [TIME]
</div>
</body>
</html>

HTML5 Web SQL

HTML5 Web SQL Database

The Web SQL Database API isn't actually part of the HTML5 specification but it is a separate specification which introduces a set of APIs to manipulate client-side databases using SQL.

I'm assuming you are a great web developer and if that is the case then no doubt, you would be well aware of SQL and RDBMS concepts. If you still want to have a session with SQL then, you can go through our SQL Tutorial.
Web SQL Database will work in latest version of Safari, Chrome and Opera.

The Core Methods:

There are following three core methods defined in the spec that I.m going to cover in this tutorial:
openDatabase: This method creates the database object either using existing database or creating new one.

Transaction: This method give us the ability to control a transaction and performing either commit or rollback based on the situation.

ExecuteSql: This method is used to execute actual SQL query.

Opening Database:
The openDatabase method takes care of opening a database if it already exists, this method will create it if it already does not exist.

To create and open a database, use the following code:
var db = openDatabase('mydb', '1.0', 'Test DB', 2 * 1024 * 1024);
Above method took following five paramters:
Database name
Version number
Text description
Size of database
Creation callback
The last and 5th argument, creation callback will be called if the database is being created. Without this feature, however, the databases are still being created on the fly and correctly versioned.

Executing queries:
To execute a query you use the database.transaction() function. This function needs a single argument, which is a function that takes care of actually executing the query as follows:
var db = openDatabase('mydb', '1.0', 'Test DB', 2 * 1024 * 1024);
db.transaction(function (tx) {
   tx.executeSql('CREATE TABLE IF NOT EXISTS LOGS (id unique, log)');
});
The above query will create a table called LOGS in 'mydb' database.
INSERT Operation:
To create enteries into the table we add simple SQL query in the above example as follows:
var db = openDatabase('mydb', '1.0', 'Test DB', 2 * 1024 * 1024);
db.transaction(function (tx) {
   tx.executeSql('CREATE TABLE IF NOT EXISTS LOGS (id unique, log)');
   tx.executeSql('INSERT INTO LOGS (id, log) VALUES (1, "foobar")');
   tx.executeSql('INSERT INTO LOGS (id, log) VALUES (2, "logmsg")');
});
We can pass dynamic values while creating entering as follows:
var db = openDatabase('mydb', '1.0', 'Test DB', 2 * 1024 * 1024);
db.transaction(function (tx) {
  tx.executeSql('CREATE TABLE IF NOT EXISTS LOGS (id unique, log)');
  tx.executeSql('INSERT INTO LOGS
                        (id,log) VALUES (?, ?'), [e_id, e_log];
});
Here e_id and e_log are external variables, and executeSql maps each item in the array argument to the "?"s.

READ Operation:
To read already existing records we use a callback to capture the results as follows:
var db = openDatabase('mydb', '1.0', 'Test DB', 2 * 1024 * 1024);
db.transaction(function (tx) {
   tx.executeSql('CREATE TABLE IF NOT EXISTS LOGS (id unique, log)');
   tx.executeSql('INSERT INTO LOGS (id, log) VALUES (1, "foobar")');
   tx.executeSql('INSERT INTO LOGS (id, log) VALUES (2, "logmsg")');
});
db.transaction(function (tx) {
   tx.executeSql('SELECT * FROM LOGS', [], function (tx, results) {
   var len = results.rows.length, i;
   msg = "<p>Found rows: " + len + "</p>";
   document.querySelector('#status').innerHTML +=  msg;
   for (i = 0; i < len; i++){
      alert(results.rows.item(i).log );
   }
 }, null);
});

Final Example:
So finally, let us keep this example in full fledged HTML5 document as follows and try to run it with Safari browser.
<!DOCTYPE HTML>
<html>
<head>
<script type="text/javascript">
var db = openDatabase('mydb', '1.0', 'Test DB', 2 * 1024 * 1024);
var msg;
db.transaction(function (tx) {
  tx.executeSql('CREATE TABLE IF NOT EXISTS LOGS (id unique, log)');
  tx.executeSql('INSERT INTO LOGS (id, log) VALUES (1, "foobar")');
  tx.executeSql('INSERT INTO LOGS (id, log) VALUES (2, "logmsg")');
  msg = '<p>Log message created and row inserted.</p>';
  document.querySelector('#status').innerHTML =  msg;
});

db.transaction(function (tx) {
  tx.executeSql('SELECT * FROM LOGS', [], function (tx, results) {
   var len = results.rows.length, i;
   msg = "<p>Found rows: " + len + "</p>";
   document.querySelector('#status').innerHTML +=  msg;
   for (i = 0; i < len; i++){
     msg = "<p><b>" + results.rows.item(i).log + "</b></p>";
     document.querySelector('#status').innerHTML +=  msg;
   }
 }, null);
});
</script>
</head>
<body>
<div id="status" name="status">Status Message</div>
</body>
</html>
This would produce following result with latest version of either Safari or Opera:
Log message created and row inserted.

Found rows: 2

foobar

logmsg

Saturday 26 March 2016

HTML5 Web Storage

HTML5 Web Storage

HTML5 introduces two mechanisms, similar to HTTP session cookies, for storing structured data on the client side and to overcome following drawbacks.
Cookies are included with every HTTP request, thereby slowing down your web application by transmitting the same data.
Cookies are included with every HTTP request, thereby sending data unencrypted over the internet.
Cookies are limited to about 4 KB of data . Not enough to store required data.
The two storages are session storage and local storage and they would be used to handle different situations.
The latest versions of pretty much every browser supports HTML5 Storage including Internet Explorer.

Session Storage:
The Session Storage is designed for scenarios where the user is carrying out a single transaction, but could be carrying out multiple transactions in different windows at the same time.

Example:
For example, if a user buying plane tickets in two different windows, using the same site. If the site used cookies to keep track of which ticket the user was buying, then as the user clicked from page to page in both windows, the ticket currently being purchased would "leak" from one window to the other, potentially causing the user to buy two tickets for the same flight without really noticing.
HTML5 introduces the sessionStorage attribute which would be used by the sites to add data to the session storage, and it will be accessible to any page from the same site opened in that window ie session and as soon as you close the window, session would be lost.
Following is the code which would set a session variable and access that variable:
<!DOCTYPE HTML>
<html>
<body>

  <script type="text/javascript">
    if( sessionStorage.hits ){
       sessionStorage.hits = Number(sessionStorage.hits) +1;
    }else{
       sessionStorage.hits = 1;
    }
    document.write("Total Hits :" + sessionStorage.hits );
  </script>
  <p>Refresh the page to increase number of hits.</p>
  <p>Close the window and open it again and check the result.</p>

</body>
</html>
Local Storage:



The Local Storage is designed for storage that spans multiple windows, and lasts beyond the current session. In particular, Web applications may wish to store megabytes of user data, such as entire user-authored documents or a user's mailbox, on the client side for performance reasons.
Again, cookies do not handle this case well, because they are transmitted with every request.
Example:
HTML5 introduces the localStorage attribute which would be used to access a page's local storage area without no time limit and this local storage will be available whenever you would use that page.
Following is the code which would set a local storage variable and access that variable every time this page is accessed, even next time when you open the window:
<!DOCTYPE HTML>
<html>
<body>

  <script type="text/javascript">
    if( localStorage.hits ){
       localStorage.hits = Number(localStorage.hits) +1;
    }else{
       localStorage.hits = 1;
    }
    document.write("Total Hits :" + localStorage.hits );
  </script>
  <p>Refresh the page to increase number of hits.</p>
  <p>Close the window and open it again and check the result.</p>

</body>
</html>
Delete Web Storage:
Storing sensitive data on local machine could be dangerous and could leave a security hole.
The Session Storage Data would be deleted by the browsers immediately after the session gets terminated.
To clear a local storage setting you would need to call localStorage.remove('key'); where 'key' is the key of the value you want to remove. If you want to clear all settings, you need to call localStorage.clear() method.

Following is the code which would clear complete local storage:
<!DOCTYPE HTML>
<html>
<body>

  <script type="text/javascript">
    localStorage.clear();

    // Reset number of hits.
    if( localStorage.hits ){
       localStorage.hits = Number(localStorage.hits) +1;
    }else{
       localStorage.hits = 1;
    }
    document.write("Total Hits :" + localStorage.hits );
  </script>
  <p>Refreshing the page would not to increase hit counter.</p>
  <p>Close the window and open it again and check the result.</p>

</body>
</html>

HTML5 Math ML

HTML5 MathML Tutorial


The HTML syntax of HTML5 allows for MathML elements to be used inside a document using <math>...</math> tags.
Most of the web browsers can display MathML tags. If your browser does not support MathML, then I would suggest you to use latest version of Firefox.
You can check W3 Specification for MathML at MathML 2.0 Specification.

MathML Examples:
Following is a valid HTML5 document with MathML:
<!doctype html>
  <html>
  <head>
  <meta charset="UTF-8">
  <title>Pythagorean theorem</title>
  </head>
  <body>
    <math xmlns="http://www.w3.org/1998/Math/MathML">
      <mrow>
        <msup><mi>a</mi><mn>2</mn></msup>
        <mo>+</mo>
        <msup><mi>b</mi><mn>2</mn></msup>
        <mo>=</mo>
        <msup><mi>c</mi><mn>2</mn></msup>
      </mrow>
    </math>
  </body>
</html>
This would produce following result:
a2 + b2 = c2

Using MathML Characters:
Consider, following is the markup which makes use of the characters &InvisibleTimes;:
<!doctype html>
  <html>
  <head>
  <meta charset="UTF-8">
  <title>MathML Examples</title>
  </head>
  <body>
    <math xmlns="http://www.w3.org/1998/Math/MathML">
       <mrow>
          <mrow>
             <msup>
                <mi>x</mi>
                <mn>2</mn>
             </msup>
             <mo>+</mo>
             <mrow>
                <mn>4</mn>
                <mo>⁢</mo>
                <mi>x</mi>
             </mrow>
             <mo>+</mo>
             <mn>4</mn>
          </mrow>
             <mo>=</mo>
             <mn>0</mn>
        </mrow>
   </math>
</body>
</html>
This would produce following result. If you are not able to see proper result like x2 + 4x + 4 = 0, then use Firefox 3.5 or higer version.
x2 + 4x + 4 = 0

Matrix Presentation Examples:
Consider the following example which would be used to represent a simple 2x2 matrix:
<!doctype html>
  <html>
  <head>
  <meta charset="UTF-8">
  <title>MathML Examples</title>
  </head>
  <body>
    <math xmlns="http://www.w3.org/1998/Math/MathML">
       <mrow>
          <mi>A</mi>
          <mo>=</mo>
          <mfenced open="[" close="]">
             <mtable>
                <mtr>
                   <mtd><mi>x</mi></mtd>
                   <mtd><mi>y</mi></mtd>
                </mtr>
                <mtr>
                   <mtd><mi>z</mi></mtd>
                   <mtd><mi>w</mi></mtd>
                </mtr>
             </mtable>
         </mfenced>
      </mrow>
   </math>
</body>
</html>
This would produce following result. If you are not able to see proper result, then use Firefox 3.5 or higer version.
MathML

HTML5 SVG

HTML5 SVG 


SVG stands for Scalable Vector Graphics and it is a language for describing 2D-graphics and graphical applications in XML and the XML is then rendered by an SVG viewer.
SVG is mostly useful for vector type diagrams like Pie charts, Two-dimensional graphs in an X,Y coordinate system etc.
SVG became a W3C Recommendation 14. January 2003 and you can check latest version of SVG specification at SVG Specification.

Viewing SVG Files:
Most of the web browsers can display SVG just like they can display PNG, GIF, and JPG. Internet Explorer users may have to install the Adobe SVG Viewer to be able to view SVG in the browser.

Embeding SVG in HTML5
HTML5 allows embeding SVG directly using <svg>...</svg> tag which has following simple syntax:
<svg xmlns="http://www.w3.org/2000/svg">
...  
</svg>
Firefox 3.7 has also introduced a configuration option ("about:config") where you can enable HTML5 using the following steps:
Type about:config in your Firefox address bar.
Click the "I'll be careful, I promise!" button on the warning message that appears (and make sure you adhere to it!).
Type html5.enable into the filter bar at the top of the page.
Currently it would be disabled, so click it to toggle the value to true.
Now your Firefox HTML5 parser should now be enabled and you should be able to experiment with the following examples.

HTML5 - SVG Circle
Following is the HTML5 version of an SVG example which would draw a cricle using <circle> tag:
<!DOCTYPE html>
<head>
<title>SVG</title>
<meta charset="utf-8" />
</head>
<body>
<h2>HTML5 SVG Circle</h2>
<svg id="svgelem" height="200" xmlns="http://www.w3.org/2000/svg">
    <circle id="redcircle" cx="50" cy="50" r="50" fill="red" />
</svg>
</body>
</html>
This would produce following result in HTML5 enabled latest version of Firefox.
HTML5 SVG Circle

HTML5 - SVG Rectangle
Following is the HTML5 version of an SVG example which would draw a rectangle using <rect> tag:
<!DOCTYPE html>
<head>
<title>SVG</title>
<meta charset="utf-8" />
</head>
<body>
<h2>HTML5 SVG Rectangle</h2>
<svg id="svgelem" height="200" xmlns="http://www.w3.org/2000/svg">
    <rect id="redrect" width="300" height="100" fill="red" />
</svg>
</body>
</html>
This would produce following result in HTML5 enabled latest version of Firefox.
HTML5 - SVG Rectangle

HTML5 - SVG Line
Following is the HTML5 version of an SVG example which would draw a line using <line> tag:
<!DOCTYPE html>
<head>
<title>SVG</title>
<meta charset="utf-8" />
</head>
<body>
<h2>HTML5 SVG Line</h2>
<svg id="svgelem" height="200" xmlns="http://www.w3.org/2000/svg">
    <line x1="0" y1="0" x2="200" y2="100"
          style="stroke:red;stroke-width:2"/>
</svg>
</body>
</html>
You can use style attribute which allows you to set additional style information like stroke and fill colors, width of the stroke etc.
This would produce following result in HTML5 enabled latest version of Firefox.
HTML5 SVG Line

HTML5 - SVG Ellipse
Following is the HTML5 version of an SVG example which would draw an ellipse using <ellipse> tag:
<!DOCTYPE html>
<head>
<title>SVG</title>
<meta charset="utf-8" />
</head>
<body>
<h2>HTML5 SVG Ellipse</h2>
<svg id="svgelem" height="200" xmlns="http://www.w3.org/2000/svg">
    <ellipse cx="100" cy="50" rx="100" ry="50" fill="red" />
</svg>
</body>
</html>
This would produce following result in HTML5 enabled latest version of Firefox.
HTML5 SVG Ellipse

HTML5 - SVG Polygon
Following is the HTML5 version of an SVG example which would draw a polygon using <polygon> tag:
<!DOCTYPE html>
<head>
<title>SVG</title>
<meta charset="utf-8" />
</head>
<body>
<h2>HTML5 SVG Polygon</h2>
<svg id="svgelem" height="200" xmlns="http://www.w3.org/2000/svg">
    <polygon  points="20,10 300,20, 170,50" fill="red" />
</svg>
</body>
</html>
This would produce following result in HTML5 enabled latest version of Firefox.
HTML5 SVG Polygon

HTML5 - SVG Polyline
Following is the HTML5 version of an SVG example which would draw a polyline using <polyline> tag:
<!DOCTYPE html>
<head>
<title>SVG</title>
<meta charset="utf-8" />
</head>
<body>
<h2>HTML5 SVG Polyline</h2>
<svg id="svgelem" height="200" xmlns="http://www.w3.org/2000/svg">
 <polyline points="0,0 0,20 20,20 20,40 40,40 40,60" fill="red" />
</svg>
</body>
</html>
This would produce following result in HTML5 enabled latest version of Firefox.
HTML5 SVG Polyline
HTML5 - SVG Gradients
Following is the HTML5 version of an SVG example which would draw a ellipse using <ellipse> tag and would use <radialGradient> tag to define an SVG radial gradient.
Similar way you can use <linearGradient> tag to create SVG linear gradient.
<!DOCTYPE html>
<head>
<title>SVG</title>
<meta charset="utf-8" />
</head>
<body>
<h2>HTML5 SVG Gradient Ellipse</h2>
<svg id="svgelem" height="200" xmlns="http://www.w3.org/2000/svg">
   <defs>
      <radialGradient id="gradient" cx="50%" cy="50%" r="50%"
      fx="50%" fy="50%">
      <stop offset="0%" style="stop-color:rgb(200,200,200);
      stop-opacity:0"/>
      <stop offset="100%" style="stop-color:rgb(0,0,255);
      stop-opacity:1"/>
      </radialGradient>
   </defs>
   <ellipse cx="100" cy="50" rx="100" ry="50"
      style="fill:url(#gradient)" />
</svg>
</body>
</html>
This would produce following result in HTML5 enabled latest version of Firefox.
HTML5 SVG Gradient

HTML5 Web Forms

HTML5 Web Forms 2.0



Web Forms 2.0 is an extension to the forms features found in HTML4. Form elements and attributes in HTML5 provide a greater degree of semantic mark-up than HTML4 and remove a great deal of the need for tedious scripting and styling that was required in HTML4.
The <input> element in HTML4
HTML4 input elements use the type attribute to specify the data type.HTML4 provides following types:
Type
Description
text
A free-form text field, nominally free of line breaks.
password
A free-form text field for sensitive information, nominally free of line breaks.
checkbox
A set of zero or more values from a predefined list.
radio
An enumerated value.
submit
A free form of button initiates form submission.
file
An arbitrary file with a MIME type and optionally a file name.
image
A coordinate, relative to a particular image's size, with the extra semantic that it must be the last value selected and initiates form submission.
hidden
An arbitrary string that is not normally displayed to the user.
select
An enumerated value, much like the radio type.
textarea
A free-form text field, nominally with no line break restrictions.
button
A free form of button which can initiates any event related to button.
Following is the simple example of using labels, radio buttons, and submit buttons:
...
<form action="http://example.com/cgiscript.pl" method="post">
    <p>
    <label for="firstname">first name: </label>
              <input type="text" id="firstname"><br />
    <label for="lastname">last name: </label>
              <input type="text" id="lastname"><br />
    <label for="email">email: </label>
              <input type="text" id="email"><br>
    <input type="radio" name="sex" value="male"> Male<br>
    <input type="radio" name="sex" value="female"> Female<br>
    <input type="submit" value="send"> <input type="reset">
    </p>
 </form>
 ...
The <input> element in HTML5
Apart from the above mentioned attributes, HTML5 input elements introduced sevral new values for the type attribute. These are listed below.

NOTE: Try all the following example using latest version of Opera browser.
Type
Description
datetime
A date and time (year, month, day, hour, minute, second, fractions of a second) encoded according to ISO 8601 with the time zone set to UTC.
datetime-local
A date and time (year, month, day, hour, minute, second, fractions of a second) encoded according to ISO 8601, with no time zone information.
date
A date (year, month, day) encoded according to ISO 8601.
month
A date consisting of a year and a month encoded according to ISO 8601.
week
A date consisting of a year and a week number encoded according to ISO 8601.
time
A time (hour, minute, seconds, fractional seconds) encoded according to ISO 8601.
number
This accepts only numerical value. The step attribute specifies the precision, defaulting to 1.
range
The range type is used for input fields that should contain a value from a range of numbers.
email
This accepts only email value. This type is used for input fields that should contain an e-mail address. If you try to submit a simple text, it forces to enter only email address in email@example.com format.
url
This accepts only URL value. This type is used for input fields that should contain a URL address. If you try to submit a simple text, it forces to enter only URL address either in http://www.example.com format or in http://example.com format.
The <output> element
HTML5 introduced a new element <output> which is used to represent the result of different types of output, such as output written by a script.

You can use the for attribute to specify a relationship between the output element and other elements in the document that affected the calculation (for example, as inputs or parameters). The value of the for attribute is a space-separated list of IDs of other elements.

The placeholder attribute
HTML5 introduced a new attribute called placeholder. This attribute on <input> and <textarea> elements provides a hint to the user of what can be entered in the field. The placeholder text must not contain carriage returns or line-feeds.
Here is the simple syntax for placeholder attribute:
<input type="text" name="search" placeholder="search the web"/>
This attribute is supported by latest versions of Mozilla, Safari and Crome browsers only.

The autofocus attribute
This is a simple one-step pattern, easily programmed in JavaScript at the time of document load, automatically focus one particular form field.
HTML5 introduced a new attribute called autofocus which would be used as follows:
<input type="text" name="search" autofocus/>
This attribute is supported by latest versions of Mozilla, Safari and Crome browsers only.

The required attribute
Now you do not need to have javascript for client side validations like empty text box would never be submitted because HTML5 introduced a new attribute called required which would be used as follows and would insist to have a value:
<input type="text" name="search" required/>
This attribute is supported by latest versions of Mozilla, Safari and Crome browsers only.

HTML5 Events

HTML5 Events



When a user visit your website, they do things like click on text and images and given links, hover over things etc. These are examples of what JavaScript calls events.

We can write our event handlers in Javascript or vbscript and you can specify these event handlers as a value of event tag attribute. The HTML5 specification defines various event attributes as listed below:
There are following attributes which can be used to trigger any javascript or vbscript code given as value, when there is any event occurs for any HTM5 element.
We would cover element specific events while discussing those elements in detail in subsequent chapters.
Attribute
Value
Description
offline
script
Triggers when the document goes offline
onabort
script
Triggers on an abort event
onafterprint
script
Triggers after the document is printed
onbeforeonload
script
Triggers before the document loads
onbeforeprint
script
Triggers before the document is printed
onblur
script
Triggers when the window loses focus
oncanplay
script
Triggers when media can start play, but might has to stop for buffering
oncanplaythrough
script
Triggers when media can be played to the end, without stopping for buffering
onchange
script
Triggers when an element changes
onclick
script
Triggers on a mouse click
oncontextmenu
script
Triggers when a context menu is triggered
ondblclick
script
Triggers on a mouse double-click
ondrag
script
Triggers when an element is dragged
ondragend
script
Triggers at the end of a drag operation
ondragenter
script
Triggers when an element has been dragged to a valid drop target
ondragleave
script
Triggers when an element leaves a valid drop target
ondragover
script
Triggers when an element is being dragged over a valid drop target
ondragstart
script
Triggers at the start of a drag operation
ondrop
script
Triggers when dragged element is being dropped
ondurationchange
script
Triggers when the length of the media is changed
onemptied
script
Triggers when a media resource element suddenly becomes empty.
onended
script
Triggers when media has reach the end
onerror
script
Triggers when an error occur
onfocus
script
Triggers when the window gets focus
onformchange
script
Triggers when a form changes
onforminput
script
Triggers when a form gets user input
onhaschange
script
Triggers when the document has change
oninput
script
Triggers when an element gets user input
oninvalid
script
Triggers when an element is invalid
onkeydown
script
Triggers when a key is pressed
onkeypress
script
Triggers when a key is pressed and released
onkeyup
script
Triggers when a key is released
onload
script
Triggers when the document loads
onloadeddata
script
Triggers when media data is loaded
onloadedmetadata
script
Triggers when the duration and other media data of a media element is loaded
onloadstart
script
Triggers when the browser starts to load the media data
onmessage
script
Triggers when the message is triggered
onmousedown
script
Triggers when a mouse button is pressed
onmousemove
script
Triggers when the mouse pointer moves
onmouseout
script
Triggers when the mouse pointer moves out of an element
onmouseover
script
Triggers when the mouse pointer moves over an element
onmouseup
script
Triggers when a mouse button is released
onmousewheel
script
Triggers when the mouse wheel is being rotated
onoffline
script
Triggers when the document goes offline
onoine
script
Triggers when the document comes online
ononline
script
Triggers when the document comes online
onpagehide
script
Triggers when the window is hidden
onpageshow
script
Triggers when the window becomes visible
onpause
script
Triggers when media data is paused
onplay
script
Triggers when media data is going to start playing
onplaying
script
Triggers when media data has start playing
onpopstate
script
Triggers when the window's history changes
onprogress
script
Triggers when the browser is fetching the media data
onratechange
script
Triggers when the media data's playing rate has changed
onreadystatechange
script
Triggers when the ready-state changes
onredo
script
Triggers when the document performs a redo
onresize
script
Triggers when the window is resized
onscroll
script
Triggers when an element's scrollbar is being scrolled
onseeked
script
Triggers when a media element's seeking attribute is no longer true, and the seeking has ended
onseeking
script
Triggers when a media element's seeking attribute is true, and the seeking has begun
onselect
script
Triggers when an element is selected
onstalled
script
Triggers when there is an error in fetching media data
onstorage
script
Triggers when a document loads
onsubmit
script
Triggers when a form is submitted
onsuspend
script
Triggers when the browser has been fetching media data, but stopped before the entire media file was fetched
ontimeupdate
script
Triggers when media changes its playing position
onundo
script
Triggers when a document performs an undo
onunload
script
Triggers when the user leaves the document
onvolumechange
script
Triggers when media changes the volume, also when volume is set to "mute"
onwaiting
script
Triggers when media has stopped playing, but is expected to resume

HTML5 Attributes

HTML5 Attributes



As explained in previous chapter, elements may contain attributes that are used to set various properties of an element.

Some attributes are defined globally and can be used on any element, while others are defined for specific elements only. All attributes have a name and a value and look like as shown below in the example.

Following is the example of an HTML5 attributes which illustrates how to mark up a div element with an attribute named class using a value of "example":
<div class="example">...</div>
Attributes may only be specified within start tags and must never be used in end tags.
HTML5 attributes are case insensitive and may be written in all uppercase or mixed case, although the most common convention is to stick with lowercase.

Standard Attributes:
The attributes listed below are supported by almost all the HTML 5 tags.
Attribute
Options
Function
accesskey
User Defined
Specifies a keyboard shortcut to access an element.
align
right, left, center
Horizontally aligns tags
background
URL
Places an background image behind an element
bgcolor
numeric, hexidecimal, RGB values
Places a background color behind an element
class
User Defined
Classifies an element for use with Cascading Style Sheets.
contenteditable
true, false
Specifies if the user can edit the element's content or not.
contextmenu
Menu id
Specifies the context menu for an element.
data-XXXX
User Defined
Custom attributes. Authors of a HTML document can define their own attributes. Must start with "data-".
draggable
true,false, auto
Specifies whether or not a user is allowed to drag an element.
height
Numeric Value
Specifies the height of tables, images, or table cells.
hidden
hidden
Specifies whether element should be visible or not.
id
User Defined
Names an element for use with Cascading Style Sheets.
item
List of elements
Used to group elements.
itemprop
List of items
Used to group items.
spellcheck
true, false
Specifies if the element must have it's spelling or grammar checked.
style
CSS Style sheet
Specifies an inline style for an element.
subject
User define id
Specifies the element's corresponding item.
tabindex
Tab number
Specifies the tab order of an element.
title
User Defined
"Pop-up" title for your elements.
valign
top, middle, bottom
Vertically aligns tags within an HTML element.
width
Numeric Value
Specifies the width of tables, images, or table cells.
For a complete list of HTML5 Tags and related attributes please check reference to HTML5 Tags.

Custom Attributes:
A new feature being introduced in HTML 5 is the addition of custom data attributes.
A custom data attribute starts with data- and would be named based on your requirement. Following is the simple example:
<div class="example" data-subject="physics" data-level="complex">
...
</div>
The above will be perfectly valid HTML5 with two custom attributes called data-subject and data-level. You would be able to get the values of these attributes using JavaScript APIs or CSS in similar way as you get for standard attributes

HTML5 Syntax

HTML5 Syntax



The HTML 5 language has a "custom" HTML syntax that is compatible with HTML 4 and XHTML1 documents published on the Web, but is not compatible with the more esoteric SGML features of HTML 4.
HTML 5 does not have the same syntax rules as XHTML where we needed lower case tag names, quoting our attributes, an attribute had to have a value and to close all empty elements.
But HTML5 is coming with lots of flexibility and would support the followings:

Uppercase tag names.
Quotes are optional for attributes.
Attribute values are optional.
Closing empty elements are optional.

The DOCTYPE:
DOCTYPEs in older versions of HTML were longer because the HTML language was SGML based and therefore required a reference to a DTD.
HTML 5 authors would use simple syntax to specify DOCTYPE as follows:
<!DOCTYPE html>
All the above syntax is case-insensitive.

Character Encoding:
HTML 5 authors can use simple syntax to specify Character Encoding as follows:
<meta charset="UTF-8">
All the above syntax is case-insensitive.
The <script> tag:
It's common practice to add a type attribute with a value of "text/javascript" to script elements as follows:
<script type="text/javascript" src="scriptfile.js"></script>
HTML 5 removes extra information required and you can use simply following syntax:
<script src="scriptfile.js"></script>
The <link> tag:
So far you were writing <link> as follows:
<link rel="stylesheet" type="text/css" href="stylefile.css">
HTML 5 removes extra information required and you can use simply following syntax:
<link rel="stylesheet" href="stylefile.css">

HTML5 Elements:
HTML5 elements are marked up using start tags and end tags. Tags are delimited using angle brackets with the tag name in between.
The difference between start tags and end tags is that the latter includes a slash before the tag name.
Following is the example of an HTML5 element:
<p>...</p>
HTML5 tag names are case insensitive and may be written in all uppercase or mixed case, although the most common convention is to stick with lowercase.
Most of the elements contain some content like <p>...</p> contains a paragraph. Some elements, however, are forbidden from containing any content at all and these are known as void elements. For example, br, hr, link and meta etc.
Here is a complete list of HTML5 Elements.

HTML5 Attributes:
Elements may contain attributes that are used to set various properties of an element.
Some attributes are defined globally and can be used on any element, while others are defined for specific elements only. All attributes have a name and a value and look like as shown below in the example.
Following is the example of an HTML5 attributes which illustrates how to mark up a div element with an attribute named class using a value of "example":
<div class="example">...</div>
Attributes may only be specified within start tags and must never be used in end tags.
HTML5 attributes are case insensitive and may be written in all uppercase or mixed case, although the most common convention is to stick with lowercase.
Here is a complete list of HTML5 Attributes.

HTML5 Document:
The following tags have been introduced for better structure:
section: This tag represents a generic document or application section. It can be used together with h1-h6 to indicate the document structure.
article: This tag represents an independent piece of content of a document, such as a blog entry or newspaper article.
aside: This tag represents a piece of content that is only slightly related to the rest of the page.
header: This tag represents the header of a section.
footer: This tag represents a footer for a section and can contain information about the author, copyright information, et cetera.
nav: This tag represents a section of the document intended for navigation.
dialog: This tag can be used to mark up a conversation.
figure: This tag can be used to associate a caption together with some embedded content, such as a graphic or video.
The markup for an HTM 5 document would look like the following:
<!DOCTYPE html>
<html>
<head>
   <meta charset="utf-8">
   <title>...</title>
</head>
<body>
  <header>...</header>
  <nav>...</nav>
  <article>
    <section>
      ...
    </section>
  </article>
  <aside>...</aside>
  <footer>...</footer>
</body>

HTML5 Overview

HTML5 Overview



HTML5 is the next major revision of the HTML standard superseding HTML 4.01, XHTML 1.0, and XHTML 1.1. HTML5 is a standard for structuring and presenting content on the World Wide Web.
HTML5 is a cooperation between the World Wide Web Consortium (W3C) and the Web Hypertext Application Technology Working Group (WHATWG).
The new standard incorporates features like video playback and drag-and-drop that have been previously dependent on third-party browser plug-ins such as Adobe Flash, Microsoft Silverlight, and Google Gears.

Browser Support:
The latest versions of Apple Safari, Google Chrome, Mozilla Firefox, and Opera all support many HTML5 features and Internet Explorer 9.0 will also have support for some HTML5 functionality.
The mobile web browsers that come pre-installed on iPhones, iPads, and Android phones all have excellent support for HTML5.

New Features:
HTML5 introduces a number of new elements and attributes that helps in building a modern websites.

 Following are great features introduced in HTML5.

New Semantic Elements: These are like <header>, <footer>, and <section>.
Forms 2.0: Improvements to HTML web forms where new attributes have been introduced for <input> tag.
Persistent Local Storage: To achieve without resorting to third-party plugins.

WebSocket : A a next-generation bidirectional communication technology for web applications.
Server-Sent Events: HTML5 introduces events which flow from web server to the web browsers and they are called Server-Sent Events (SSE).

Canvas: This supports a two-dimensional drawing surface that you can program with JavaScript.

Audio & Video: You can embed audio or video on your web pages without resorting to third-party plugins.

Geolocation: Now visitors can choose to share their physical location with your web application.

Microdata: This lets you create your own vocabularies beyond HTML5 and extend your web pages with custom semantics.

Drag and drop: Drag and drop the items from one location to another location on a the same webpage.

Backward Compatibility
HTML5 is designed, as much as possible, to be backward compatible with existing web browsers. New features build on existing features and allow you to provide fallback content for older browsers.
It is suggested to detect support for individual HTML5 features using a few lines of JavaScript.
If you are not familiar with any previous version of HTML, I would recommend to go through our HTML Tutorial before you explore further concepts of HTM5

HTML 5 Intro

HTML5 Introduction




HTML5 is the latest and most enhanced version of HTML.
Technically, HTML is not a programming language, but rather a markup language.
This tutorial gives very good understanding on HTML5

HTML Deprecated Tags

HTML Deprecated Tags



A complete list of deprecated HTML tags and attributes are given here. All the tags have been ordered alphabetically along with their equivalent tag or alternate CSS option.
Tag
Description
Alternate
<applet>
Deprecated. Specifies an applet
<object>
<basefont>
Deprecated. Specifies a base font

<center>
Deprecated. Specifies centered text
text-align
<dir>
Deprecated. Specifies a directory list

<embed>
Deprecated. Embeds an application in a document
<object>
<font>
Deprecated. Specifies text font, size, and color
font-family, font-size
<isindex>
Deprecated. Specifies a single-line input field

<listing>
Deprecated. Specifies listing of items
<pre>
<menu>
Deprecated. Specifies a menu list

<plaintext>
Deprecated. Specifies plaintext
<pre>
<s>
Deprecated. Specifies strikethrough text
text-decoration
<strike>
Deprecated. Specifies strikethrough text
text-decoration
<u>
Deprecated. Specifies underlined text
text-decoration
<xmp>
Deprecated. Specifies preformatted text
<pre>
HTML Decprecated Attributes
Following is the list of deprecated HTML attributes and alternative CSS options available.
Attribute
Description
Alternate
align
Specifies positioning of an element
text-align, float & vertical-align
alink
Specifies the color of an active link or selected link
active
background
Specifies background image
background-image
bgcolor
Specifies background color
background-color
border
Specifies a border width of any element
border-width
clear
Indicates how the browser should display the line after the <br /> element
clear
height
Specifies height of body and other elements
height
hspace
Specifies the amount of whitespace or padding that should appear left or right an element
padding
language
Specifies scripting language being used
type
link
Specifies the default color of all links in the document
link
nowrap
Prevents the text from wrapping within that table cell
white-space
start
Indicates the number at which a browser should start numbering a list
counter-reset
text
Specifies color of body text
color
type
Specifies the type of list in <li> tag
list-style-type
vlink
Specifies the color of visited links
visited
vspace
Specifies the amount of whitespace or padding that should appear above or below an element
padding
width
Specifies width of body and other elements
width

HTML Character Encoding

HTML Character Encodings



Character encoding is a method of converting bytes into characters. To validate or display an HTML document properly, a program must choose a proper character encoding.
The most common character set or character encoding in use on computers is ASCII the American Standard Code for Information Interchange, and this is probably the most widely used character set for encoding text electronically.
ASCII encoding supports only the upper- and lowercase Latin alphabet, the numbers 0-9, and some extra characters which make a total of 128 characters in all. You can have a look at complete set of Printable ASCII Characters
However, many languages use either accented Latin characters or completely different alphabets. ASCII does not address these characters; therefore you need to learn about character encodings if you want to use any non-ASCII characters.
The International Standards Organization created a range of character sets to deal with different national characters. For the documents in English and most other Western European languages, the widely supported encoding ISO-8859-1 is used.
Here is the list of Character Set being used around the world along with their description.
Character Set
Description
ISO-8859-1
Latin alphabet part 1
Covering North America,Western Europe, Latin America, theCaribbean, Canada, Africa
ISO-8859-2
Latin alphabet part 2
Covering Eastern Europe
ISO-8859-3
Latin alphabet part 3
Covering SE Europe, Esperanto, miscellaneous others
ISO-8859-4
Latin alphabet part 4
Covering Scandinavia/Baltics (and others not in ISO-8859-1)
ISO-8859-5
Latin/Cyrillic alphabet part 5
ISO-8859-6
Latin/Arabic alphabet part 6
ISO-8859-7
Latin/Greek alphabet part 7
ISO-8859-8
Latin/Hebrew alphabet part 8
ISO-8859-9
Latin 5 alphabet part 9
Same as ISO-8859-1 except Turkish characters replace Icelandic ones
ISO-8859-10
Latin 6 Latin 6 Lappish, Nordic, and Eskimo
ISO-8859-15
The same as ISO-8859-1 but with more characters added
ISO-2022-JP
Latin/Japanese alphabet part 1
ISO-2022-JP-2
Latin/Japanese alphabet part 2
ISO-2022-KR
Latin/Korean alphabet part 1
The Unicode Consortium was then set up to devise a way to show all characters of different languages, rather than have these different incompatible character codes for different languages.
Therefore, if you want to create documents that use characters from multiple character sets, you will be able to do so using the single Unicode character encodings.
Unicode therefore specifies encodings that can deal with a string in special ways so as to make enough space for the huge character set it encompasses. These are known as UTF-8, UTF-16, and UTF-32.
Character Set
Description
UTF-8
A Unicode Translation Format that comes in 8-bit units that is, it comes in bytes. A character in UTF8 can be from 1 to 4 bytes long, making UTF8 variable width.
UTF-16
A Unicode Translation Format that comes in 16-bit units that is, it comes in shorts. It can be 1 or 2 shorts long, making UTF16 variable width.
UTF-32
A Unicode Translation Format that comes in 32-bit units that is, it comes in longs. It is a fixed-width format and is always 1 "long" in length.
The first 256 characters of Unicode character sets correspond to the 256 characters of ISO-8859-1.
By default, HTML 4 processors should support UTF-8, and XML processors are supposed to support UTF-8 and UTF-16; therefore all XHTML-compliant processors should also support UTF-16.

HTML Url Encoding

HTML URL Encoding



URL encoding is the practice of translating unprintable characters or characters with special meaning within URLs to a representation that is unambiguous and universally accepted by web browsers and servers. These characters include:
ASCII control characters - Unprintable characters typically used for output control. Character ranges 00-1F hex (0-31 decimal) and 7F (127 decimal). A complete encoding table is given below.
Non-ASCII control characters - These are characters beyond the ASCII character set of 128 characters. This range is part of the ISO-Latin character set and includes the entire "top half" of the ISO-Latin set 80-FF hex (128-255 decimal). A complete encoding table is given below.
Reserved characters - These are special characters such as the dollar sign, ampersand, plus, common, forward slash, colon, semi-colon, equals sign, question mark, and "at" symbol. All of these can have different meanings inside a URL so need to be encoded. A complete encoding table is given below.
Unsafe characters - These are space, quotation marks, less than symbol, greater than symbol, pound character, percent character, Left Curly Brace, Right Curly Brace , Pipe, Backslash, Caret, Tilde, Left Square Bracket , Right Square Bracket, Grave Accent. These character present the possibility of being misunderstood within URLs for various reasons. These characters should also always be encoded. A complete encoding table is given below.
The encoding notation replaces the desired character with three characters: a percent sign and two hexadecimal digits that correspond to the position of the character in the ASCII character set.
Example
One of the most common special characters is a white space. You can't type a space in a URL directly. A space position in the character set is 20 hexadecimal. So you can use %20 in place of a space when passing your request to the server.
http://www.example.com/new%20pricing.htm
This URL actually retrieves a document named "new pricing.htm" from the www.example.com
ASCII control characters encoding
This includes the encoding for character ranges 00-1F hex (0-31 decimal) and 7F (127 decimal)
Decimal
Hex Value
Character
URL Encode
0
00


1
01

%01
2
02

%02
3
03

%03
4
04

%04
5
05

%05
6
06

%06
7
07

%07
8
08
backspace
%08
9
09
tab
%09
10
0a
linefeed
%0a
11
0b

%0b
12
0c

%0c
13
0d
carriage return
%0d
14
0e

%0e
15
0f

%0f
16
10

%10
17
11

%11
18
12

%12
19
13

%13
20
14

%14
21
15

%15
22
16

%16
23
17

%17
24
18

%18
25
19

%19
26
1a

%1a
27
1b

%1b
28
1c

%1c
29
1d

%1d
30
1e

%1e
31
1f

%1f
127
7f

%7f
Non-ASCII control characters encoding
This includes the encoding for the entire "top half" of the ISO-Latin set 80-FF hex (128-255 decimal.)
Decimal
Hex Value
Character
URL Encode
128
80

%80
129
81

%81
130
82

%82
131
83
ƒ
%83
132
84

%84
133
85

%85
134
86

%86
135
87

%87
136
88
ˆ
%88
137
89

%89
138
8a
Š
%8a
139
8b

%8b
140
8c
Œ
%8c
141
8d

%8d
142
8e
Ž
%8e
143
8f

%8f
144
90

%90
145
91

%91
146
92

%92
147
93

%93
148
94

%94
149
95

%95
150
96

%96
151
97

%97
152
98
˜
%98
153
99

%99
154
9a
š
%9a
155
9b

%9b
156
9c
œ
%9c
157
9d

%9d
158
9e
ž
%9e
159
9f
Ÿ
%9f
160
a0

%a0
161
a1
¡
%a1
162
a2
¢
%a2
163
a3
£
%a3
164
a4
¤
%a4
165
a5
¥
%a5
166
a6
¦
%a6
167
a7
§
%a7
168
a8
¨
%a8
169
a9
©
%a9
170
aa
ª
%aa
171
ab
«
%ab
172
ac
¬
%ac
173
ad
%ad
174
ae
®
%ae
175
af
¯
%af
176
b0
°
%b0
177
b1
±
%b1
178
b2
²
%b2
179
b3
³
%b3
180
b4
´
%b4
181
b5
µ
%b5
182
b6

%b6
183
b7
·
%b7
184
b8
¸
%b8
185
b9
¹
%b9
186
ba
º
%ba
187
bb
»
%bb
188
bc
¼
%bc
189
bd
½
%bd
190
be
¾
%be
191
bf
¿
%bf
192
c0
À
%c0
193
c1
Á
%c1
194
c2
Â
%c2
195
c3
Ã
%c3
196
c4
Ä
%c4
197
c5
Å
%c5
198
c6
Æ
%v6
199
c7
Ç
%c7
200
c8
È
%c8
201
c9
É
%c9
202
ca
Ê
%ca
203
cb
Ë
%cb
204
cc
Ì
%cc
205
cd
Í
%cd
206
ce
Î
%ce
207
cf
Ï
%cf
208
d0
Ð
%d0
209
d1
Ñ
%d1
210
d2
Ò
%d2
211
d3
Ó
%d3
212
d4
Ô
%d4
213
d5
Õ
%d5
214
d6
Ö
%d6
215
d7
×
%d7
216
d8
Ø
%d8
217
d9
Ù
%d9
218
da
Ú
%da
219
db
Û
%db
220
dc
Ü
%dc
221
dd
Ý
%dd
222
de
Þ
%de
223
df
ß
%df
224
e0
à
%e0
225
e1
á
%e1
226
e2
â
%e2
227
e3
ã
%e3
228
e4
ä
%e4
229
e5
å
%e5
230
e6
æ
%e6
231
e7
ç
%e7
232
e8
è
%e8
233
e9
é
%e9
234
ea
ê
%ea
235
eb
ë
%eb
236
ec
ì
%ec
237
ed
í
%ed
238
ee
î
%ee
239
ef
ï
%ef
240
f0
ð
%f0
241
f1
ñ
%f1
242
f2
ò
%f2
243
f3
ó
%f3
244
f4
ô
%f4
245
f5
õ
%f5
246
f6
ö
%f6
247
f7
÷
%f7
248
f8
ø
%f8
249
f9
ù
%f9
250
fa
ú
%fa
251
fb
û
%fb
252
fc
ü
%fc
253
fd
ý
%fd
254
fe
þ
%fe
255
ff
ÿ
%ff
Reserved characters encoding
Following is the table to be used to encode reserved characters.
Decimal
Hex Value
Char
URL Encode
36
24
$
%24
38
26
&
%26
43
2b
+
%2b
44
2c
,
%2c
47
2f
/
%2f
58
3a
:
%3a
59
3b
;
%3b
61
3d
=
%3d
63
3f
?
%3f
64
40
@
%40
Unsafe characters encoding
Following is the table to be used to encode unsafe characters.
Decimal
Hex Value
Char
URL Encode
32
20
space
%20
34
22
"
%22
60
3c
<
%3c
62
3e
>
%3e
35
23
#
%23
37
25
%
%25
123
7b
{
%7b
125
7d
}
%7d
124
7c
|
%7c
92
5c
\
%5c
94
5e
^
%5e
126
7e
~
%7e
91
5b
[
%5b
93
5d
]
%5d
96
60
`
%60