Introduction to HTML5 for ASP.NET Developers


More and more web applications are harnessing the power of client side features of a browser. To that end HTML5 has many features to offer web developers. HTML markup, JavaScript and CSS have become more powerful and flexible than ever before. ASP.NET Developers must be well-versed with HTML5 features because all of the leading browsers are aggressively supporting them and newer web applications are bound to rely heavily on them. This article is intended to give you an overview of some key features of HTML5 from a developer's perspective. We won't go into too much detail of new HTML tags, CSS3 and such "markup" level features, instead we will focus on features more appealing to web developers.

Features of Interest

HTML5 is an emerging web standard that has received a great deal of attention from browser companies and the developer community. All of the major browsers, including Internet Explorer, FireFox, Chrome, Safari and Opera have support for HTML5 in varying degrees. Although not all of the browsers support all of the HTML5 features in the same way, web developers can still avail themselves of many of the benefits of HTML5 from the current releases of these browsers. All of these browser companies are aggressively working to provide full-fledge standardized support for HTML5 features. As far as this article is concerned we will focus on the following features of HTML5.

  • Local Storage
  • JavaScript Selectors
  • Web Sockets
  • Web Workers
  • Application Caching
  • Client side drawing
  • Custom attributes

Remember that HTML5 is a collective term used for new HTML elements, JavaScript enhancements and CSS 3 specifications. Throughout the article when we say HTML5 we mean one of these technologies and not just HTML markup tags.

New HTML Markup Tags

HTML5 adds many new tags to the existing set of markup elements. Though we won't discuss each and every tag in detail, here are a few tags that might be interesting to ASP.NET developers.

  • <audio> and <video> tags allow you to embed audio and video inside a web page respectively.
  • Forms can now have new elements - <datalist>, <keygen> and <output>. The <input> element now supports various input types such as url, email and datetime.
  • Elements such as <section>, <header> and <footer> allow you to design a page in a structured manner.

We won't go in too much detail about these tags in this article. See later sections of this article that talk about how various Microsoft tools support HTML5 schema and provide intellisense for these elements.

Local Storage

ASP.NET developers often used cookies to store small pieces of data on the client side. One of the limitations of using cookies is the amount of data that can be saved. For example, many browsers have size limit of 4,096 bytes for a single cookie. HTML5 local storage allows developers to store more data on the client side using JavaScript code. Local storage typically allows you to store up to 5 MB of data (different browsers may have slightly different limits). Local storage comes in two flavors viz. local storage and session storage (together they are often called Web Storage). Local storage is persisted on the client machine across browser sessions whereas session storage is persisted only for the current session. These storages can be accessed via JavaScript using localStorage and sessionStorage objects. The following code fragment illustrates how data can be saved and retrieved in localStorage object.

function SetData() {

    window.localStorage["myKey"] = document.getElementById("Text1").value;

    alert("Data saved!");



function GetData() {

    document.getElementById("Text2").value = window.localStorage["myKey"];


As you can see the SetData() JavaScript function stores values from a textbox into a localStorage key named myKey. The GetData() function then retrieves the previously stored key and assigns the value to another textbox. The localStorage and sessionStorage objects also expose methods to remove and clear items from the respective storages.

JavaScript Selectors

If you used JavaScript before you are probably aware of getElementById() and getElementByTagName() methods. These methods return elements based on supplied parameter (either ID or tag name). JavaScript now has two more selector methods viz. querySelector() and querySelectorAll(). The former method returns the first element from the matched result set whereas the later method returns all of the matching elements. The following code fragment shows how these methods can be used.


<li id="id1" class="class1">ASP.NET</li>

<li class="class1">Windows Forms</li>

<li id="id2" class="class1">jQuery</li>

<li class="class2">MVC</li>

<li class="class2">WCF</li>


var item = document.querySelector("li.class1");


var items = document.querySelectorAll("li.class1");

alert(items.length + " items found!");

var items = document.querySelectorAll("#id1,#id2");

alert(items.length + " items found!");

The call to querySelector() method returns the first <li> element whose class attribute is set to class1. Similarly, querySelectorAll() method that follows returns all the <li> elements whose class attribute is set to class1. The second call to querySelectorAll() method returns all the elements that have specified ID attribute.

Web Sockets

If you have ever programmed a desktop chat application then probably you are aware of socket programming. Web Sockets is essentially socket programming for web applications. Currently a popular approach to ping back server for some processing is AJAX. However, AJAX communication involves the client browser polling the server periodically. Web sockets, on the other hand, provide a two way communication channel where the server can send data to the client browser. The Web socket feature is still in evolving stages and there are concerns over security. In the days to come we may expect a standardized and secure form of web sockets supported by all of the leading browsers. 

Web Workers

Web workers bring multithreading to browser based applications. Web workers essentially allow you to load and execute a JavaScript file in a separate thread without affecting the responsiveness of the user interface. Not all browsers support web workers at this stage. A sample code fragment, shown below, shows how web workers can be used in FireFox.

HTML page


var worker = new Worker("MyWorker.js");

worker.postMessage("Hello World");

worker.onmessage = function (evt) {



worker.onerror = function (evt) {

    alert("Error : " +;


MyWorker.js file


onmessage = function (evt) {

    postMessage("Data processed : " +;


As you can see the Worker object refers to a JavaScript file to be loaded in a separate thread. The postMessage() method is used to send data to the code being executed from the file. The onmessage function displays the data received back from the code. The entire processing of MyWorker.js is happening in a separate thread and the end user is free to work with the web page user interface. 

Application Caching

Web applications require a live connection with the server in order to work properly. This always connected behavior can create problems of its own when the server goes offline for some reason or the network connection is lost temporarily. The Application Caching features of HTML5 tries to address these scenarios in two ways - client side SQL database (Web SQL) and Offline Application Caching APIs. In the former approach a local SQL database is used to store a local copy of data on which the user can work. The later approach makes use of a Cache Manifest file that stores a list of files that are to be cached locally. Note that the SQL database option (though initially proposed by W3C) is no longer actively pursued by W3C and may not become a standard across all the browsers.

Client Side Drawing

One of the reasons for the popularity of the web is the graphical user interface they offer to the end user. Images, animations, fonts and other interactive effects make a website appealing from an end user's perspective. However, one limitation that website developers often encounter is drawing graphics in the browser. As a solution, developers often resort to Flash or Silverlight based plug-ins or generate graphics on the fly at server side and then send it to the client. HTML5 does a great job in client side graphic rendering by offering what is known as the Canvas. The actual drawing can be carried out using JavaScript code and certain new graphic objects.

The HTML5 Canvas is very similar to a real life drawing canvas in that it allows you to draw shapes, text, backgrounds and many such drawing operations. Of course, HTML5 Canvas is browser based and is measured in pixels. At HTML markup level canvas is represented by the <canvas> tag. A basic usage of <canvas> tag is shown below.

<canvas id="myCanvas" width="500" height="500"></canvas>

Consider the following piece of code:

var myCanvas = document.getElementById('myCanvas');

var context = myCanvas.getContext('2d');

context.fillRect(10,10, 200, 100);







context.font = '20pt Arial';

context.fillText('Drawing text on the Canvas', 0, 100);

As you can see the getContext() method of canvas object returns a rendering context object. Various methods of the rendering context object such as fillRect(), lineTo() and fillText() allow you to draw on the canvas.

Custom Data Attributes

Traditionally HTML elements have a fixed set of attributes that can be assigned (either through markup or via JavaScript code). HTML5 introduces what is known as Custom Data Attributes that allow you to define custom attributes for an HTML element. These custom data attributes won't affect the user interface of the element in any way but you can access and manipulate them via JavaScript code. These attribute take the form of data-* where * is any custom name. e.g. data-firstname, data-birthdate and data-validationmessage. The following code shows how custom data attributes can be used.

<input type="text" id="Text1" data-validationmessage="Invalid Birth Date" />

<br />

<br />

<input type="button" value="Show Custom Data Attribute" onclick="OnClick();"/>

Notice how data-validationmessage defines a validation message for a textbox. The value of data-validationmessage attribute can then be retrieved as follows:

function OnClick() {

    var text1 = document.getElementById("Text1")


    text1.setAttribute("data-validationmessage", "Birth date is invalid")



The getAttribute() and setAttribute() methods essentially get and set the custom attribute value respectively. It would be interesting to note that ASP.NET MVC3 un-obstructive validation makes use of custom data attributes.

Now that you know about what HTML5 has to offer, let's see how Microsoft development tools support HTML5 markup. Note that these tools basically support HTML5 markup schema. Support for new JavaScript objects and code level features should come from the target browser.

HTML5 Support in Visual Studio 2010

When Visual Studio 2010 was released there was no in-built support for HTML5 schema and tags. However, Service Pack 1 fills that gap. With Visual Studio SP1 installed you can turn HTML5 support on using Tools > Options menu as shown below:

Visual Studio SP1 HTML5 support
Figure 1: Visual Studio SP1 HTML5 support

As you can see the HTML schema is set to HTML5. This will cause the HTML editor of Visual Studio to show HTML5 option like this:

The HTML schema is set to HTML5
Figure 2: The HTML schema is set to HTML5

You can then use intellisense for new HTML5 tags inside the pages. 

Intellisense for new HTML5 tags
Figure 3: Intellisense for new HTML5 tags

The future versions of Visual Studio will, of course, enhance and extend these features further.

HTML5 Support in Microsoft Expression Web

Microsoft Expression Web 4 also follows the path of Visual Studio for providing HTML5 support. When you install Service Pack 1 for Expression Web 4 you are able to set HTML5 schema using Tools > Page Editor Options menu item.

Microsoft Expression Web 4 Service Pack 1 Page Editor Options
Figure 4: Microsoft Expression Web 4 Service Pack 1 Page Editor Options

Notice the section titled "Doctype and Secondary Schema" that allows you to select the HTML5 option. Once selected you can get intellisense for HTML5 specific tags similar to Visual Studio 2010. 

HTML5 Support in WebMatrix

HTML5 support in WebMatrix is quite straightforward. When you create a new HTML page all you get is :

WebMatrix new HTML page
Figure 5: WebMatrix new HTML page

As you can see, unlike the default template of Visual Studio, this template is simple with DOCTYPE set to html. This is what is sufficient to start writing an HTML5 page.


HTML5 offers many new features for any ASP.NET developer. In addition to new markup tags, features such as local storage, JavaScript selectors, web sockets, web workers, client side drawing  and custom data attributes are important from an ASP.NET developer's perspective. Current Microsoft development tools such as Visual Studio 2010, Expression Web 4 and WebMatrix provide support for HTML5 schema through service packs and we can expect enhanced support for HTML5 in their future releases.

About the Author

Bipin Joshi

Bipin Joshi is a blogger and writes about apparently unrelated topics - Yoga & technology! A former Software Consultant by profession, Bipin has been programming since 1995 and has been working with the .NET framework ever since its inception. He has authored or co-authored half a dozen books and numerous articles on .NET technologies. He has also penned a few books on Yoga. He was a well known technology author, trainer and an active member of Microsoft developer community before he decided to take a backseat from the mainstream IT circle and dedicate himself completely to spiritual path. Having embraced Yoga way of life he now codes for fun and writes on his blogs. He can also be reached there.



  • It's been a zippy week on account of motor coach insinuate retailer|prepare fissure online

    Posted by Stoompota on 06/24/2013 12:29pm

    The Two-Toned Beauty Bag is a great size to fit makeup and brushes easily for travel. The zippers are a bit stiff to open, but it actually doesn't really make a difference if you're using this bag as a makeup bag. The zipper tabs are detailed with croc leather that matches the body of the bag, which looks great. I love all of the croc detailing throughout the bag--the croc leather is strategically placed so you can see the back of the crocodile down the center of the bag. However, I'm not crazy about the contrasting two-tone with red and black and I'm pretty sure that's why I'm turned off by this bag. I digress, this punk rock look is perfect for many other bagistas. My favorite of the two bags is the Itty Bitty Box Bag is a bag that can be used to carry makeup and brushes while traveling, or with the use of the wristlet strap, can be used for a night out. Carry this bag like a wristlet and carry your camera, credit card, ID and lip gloss with room to spare. If you don't feel like going out, fine. This bag can be used for what you'd like to use it for. With a convenient side pocket with a magnetic closure, you can slip business cards and work-related items into this design with ease [url=]coach outlet[/url] and look sleek at the same time. We [url=]wholesale coach [url=]coach outlet online[/url] handbags[/url] received two accessory bags from the EXOTIC Elegance collection to review. One of which, is a Two-Toned Beauty Bag to hold all of your beauty supplies while traveling. The other, my personal favorite, is the Itty Bitty Box Bag is a small bag that can hold whatever beauty supplies or other accessories that you may need. EXOTIC Elegance [url=]coach outlet[/url] is an exotic handbag line based out of Chicago, Illinois. Founder, Sunni Patterson, "created EXOTIC Elegance as a reminder of our individual beauty, inspiration, and how we impact those around us when we are authentic." A specialty boutique that highlights genuine exotic leather handbags, business accessories and beauty accessories, EXOTIC Elegance designs are quality, luxe and unique goods for those who appreciate such "elegance."

  • cheap basketball jerseys,cheap youth jerseys,cheap authentic football jerseys

    Posted by stotstessig on 06/04/2013 07:14pm

    As soon as and also Ibrahimovic within the People from france court includes "kiss of the edge" civelli, Seedorf employed opponent. Last night, civelli consequence fine coach indicated which the gambler can switch, he said: "the INDIVIDUALS support civelli could be the innovator, they're superior, they need him for you to renew this post paid, although I'm sure his or her goal, he hopes to sign up for a big tavern keen on him. " According to this People from france and the Malta media information, [url=]wholesale football jerseys free shipping[/url] this tavern can be ALTERNATING CURRENT Milan. On the flip side, ALTERNATING CURRENT Milan and also Empoli high-level getting together with, the two characteristics talk for a second time this exchange dilemma with Szabo Nara and also Ragini, but the other remains to be definitely not resolved this, because play-offs Empoli has not concluded, most of for you to wait around until finally following a very last to determine. Neymar by Santos registered Barcelona, a different as good gambler throughout South america could also gotten this European leaders, People from france media proved this Rome Saint-Germain with Gansel very serious, Leonardo hope he came out one of many team's lineup future year. According to People from france media Le10Sport information, recent typical director with Rome Saint-Germain's Leonardo that is today throughout South america, he was starying a new Ganco negotiations. [url=]cheap soccer jerseys[/url] Gansel very last September ahead of the exchange by Santos registered Sao Paulo, South america and a lot of various other gamers, Gansel challenge with possession can be very bothersome, they're at the moment 68% of the possession within the poker hands with Sonda Class, a different 32% throughout Sao Paulo tavern, Sao Paulo to acheive Gansel, spent twenty three. in search of zillion reais a year ago, this Languages like german "transfer market", said this exchange charge was all over 900 zillion euros. Concerning Rome St Germain and also St. Paul acquired accomplished an issue around the very last summer time, Rome Saint-Germain for you to above 50 zillion euros for you to finalize the price tag on a smaller Lucas, and also throughout Jan of the yr officially finished this operation. And also Gansel as well Leonardo beloved merchandise is a several years, when he was with ALTERNATING CURRENT Milan around the offered order Gansel, but then owing to leg injuries Ganco, ALTERNATING CURRENT Milan lost the fight this order, and from now on Leonard many possess an opportunity to finished their unique this would like.

  • authentic mlb jerseys,thailand arsenal jersey

    Posted by AffongeAtorge on 05/07/2013 11:21am

    "He ended up being most likely going to get the legend! " The Conti from the eye balls from the popular Juventus participant Gboba, the nineteen -- year-old renegade during Juventus that period placed the Thames a terrific coup, has grown a crucial fellow member from the team's midfield, and take up space for just one individual from the France national workforce. Even though Juventus earned the night bogeba Reddish Carnival connected with faults, yet they are unquestionably Juventus that period the best farm! From the outset from the period, Juventus are generally free of Man utd closed the bogeba just simply lower the beautiful physique. In accordance with the bogeba thoughts, [url=]Fox soccer[/url] Vieira ideas your pet to be able to become a member of Juventus, "there ended up many golf equipment the phone inside myself, Man utd possesses still left myself, yet I'd like to be able to become a member of Juventus, quite a few France persons are in such a team a hit. Vieira in addition cautioned myself to be able to become a member of Juventus, at this point this is a achievements. " Many that is apparently Vieira envisioned, the France Foreign reported connected with Pogba: "he is known for a impressive skills, once i first found your pet if they ended up being a young son, in those days My spouse and i observed your pet from now on is going to be in a, they better still than myself, additional comprehensive. "Although Man utd in a tiny space, however the bogeba soaring pace and also will be fantastic. Your fourth round from the Serie The, Pogba earned the 1st video game connected with likelihood, along with played all of the 90 moments, aiding the workforce to be able to 2-0 victory over Chievo. After that Pogba confirmed the hair get out of hand, a lot more excellent, the 8th round from the little league, Juventus 2-0 residence conquer the name competition Napoli, [url=]Live soccer scores[/url] Pogba seventy-sixth moments over regular, they scored an excellent purpose from the eighty-second tiny, that will the workforce have a important victory. Even more amazing performance from the 10th round from the little league, Pogba's performance brought lower the property, inside his ninety-second tiny header Juesha specifically that will the workforce to your 2-1 victory on the Bologna amassed three factors, along with previous to that will Pogba plus a rocket from the column, plus a purpose to become offered, they became Juventus the most intimidating participant.

  • snapback hats wholesale

    Posted by tdexpenueMoxjef on 03/29/2013 11:27pm

    [url=]cheap sunglasses[/url]cheap snapbacks [url=]oakleys cheap[/url]cheap snapbacks from china [url=]cheap snapbacks from china[/url]wholesale snapbacks [url=]cheap oakley[/url]cheap snapbacks from china [url=]cheap snapbacks[/url]cheap sunglasses

  • wholesale snapback hats

    Posted by dyexpenueMoxjef on 03/29/2013 11:22pm

    [url=]cheap snapbacks from china[/url]snapback hats wholesale [url=]wholesale snapback hats[/url]cheap snapbacks for sale [url=]cheap snapbacks for sale[/url]cheap snapbacks from china [url=]cheap snapbacks[/url]cheap snapbacks from china [url=]wholesale snapbacks[/url]cheap snapbacks for sale

  • snapback hats wholesale

    Posted by ynexpenueMoxjef on 03/29/2013 11:18pm

    [url=]cheap oakley[/url]snapback hats wholesale [url=]cheap oakley[/url]wholesale snapback hats [url=]snapback hats wholesale[/url]oakleys cheap [url=]cheap oakley[/url]wholesale snapbacks [url=]cheap oakley[/url]snapback hats wholesale

  • snapback hats wholesale

    Posted by ytexpenueMoxjef on 03/29/2013 11:14pm

    [url=]wholesale snapbacks[/url]cheap sunglasses [url=]cheap sunglasses[/url]snapback hats wholesale [url=]oakleys cheap[/url]cheap snapbacks [url=]wholesale snapbacks[/url]oakley sunglasses cheap [url=]cheap snapbacks from china[/url]oakleys cheap

  • wayfarer sunglasses cheap

    Posted by ogliliImpumpnov on 03/29/2013 10:22am - oakley discount wholesale oakley sunglasses - oakley sunglasses cheap oakley sunglasses cheap - fake ray ban wayfarer cheap wayfarer sunglasses - discount ray ban fake ray ban - cheap ray ban,,,, discount oakley sunglasses,,,,,o

  • wholesale sunglasses china

    Posted by ngliliImpumpfsy on 03/29/2013 09:17am - cheap fake oakley sunglasses oakley sunglasses cheap - fake oakleys designer sunglasses cheap - discount oakley sunglasses,,,,,o oakley discount - discount oakleys cheap ray ban sunglasses - cheap oakleys for sale cheap ray ban

  • French Maid Lingerie

    Posted by Fishnetat1040 on 03/29/2013 09:00am - sexy adult costumesGreen also signifies growth and hope The removal of these garments can at times try a man's patience - Sexy BodyStockingslingerie?has been derived from the French word On this day, you can be whoever you want - Lace ChemiseThe dropshipper would then ship the product, directly from their warehouse, to your customer See if they have return policy, conditions, size chart, contact information - Sexy Babydoll LingerieOne more interesting moment - on main picture maybe the model will be in black color but this company also offers this style in other color If all your bartenders are over pouring, that's a tremendous amount of money in a month - Sexy LingerieSo if only you will choose comfortably and nicely in the set of all the lingerie in front of you, you can turn that uncomfortable feeling into confidence Sometimes, the lingerie wholesaler offer wholesale lingerie that consists of a pack of similar lingerie

  • Loading, Please Wait ...

Leave a Comment
  • Your email address will not be published. All fields are required.

Top White Papers and Webcasts

  • As all sorts of data becomes available for storage, analysis and retrieval - so called 'Big Data' - there are potentially huge benefits, but equally huge challenges...
  • The agile organization needs knowledge to act on, quickly and effectively. Though many organizations are clamouring for "Big Data", not nearly as many know what to do with it...
  • Cloud-based integration solutions can be confusing. Adding to the confusion are the multiple ways IT departments can deliver such integration...

Most Popular Programming Stories

More for Developers

RSS Feeds

Thanks for your registration, follow us on our social networks to keep up-to-date