HTML has revolutionized the way we do just about everything. We buy plane tickets via Web pages rendered in HTML, we read the statuses posted by our friends and update our own status via HTML pages, and our applications exchange data using XML documents that are inspired by the example of HTML. Most of us even get our news and entertainment through the medium of the Web, where HTML has been king since the early days.
There have been several attempts over the years to reinvent HTML, including the introduction of Curl. I was personally involved in helping the company behind Curl develop its first sample applications many years ago. It has found its niche, but fell short of replacing HTML as the default medium for the Web.
There are, of course, the various add-ons such as Adobe Flash and Microsoft’s Silverlight, but none have come close to the success of the original Web delivery media. The original is what we call just plain HTML, though it is really HTML4—officially standardized in 1997.
Conventional wisdom is that if you cannot make something better, then the best course is to improve on the original instead. That wisdom has led us slowly to the development of HTML5. I say slowly, because it has been taking shape for many years now and has caused a great bit of infighting and posturing by the various stakeholders. In fact, even as of this writing, it has still not been completed officially, yet it is solid enough that the major browser makers have been adopting the features to a great enough extent that HTML5 development is here and real. Many of the earliest adopters predicted, and in many cases hoped, that this new style of application would undermine Microsoft’s position in the Web development world. Now, as you will see, even Microsoft has a story for leveraging HTML5. You can decide if the way it has allowed for HTML5 on its systems makes those predictions true or not.
HTML5 background and philosophy
The Web Hypertext Application Technology Working Group (WHATWG) is a group comprised of representatives from most of the various companies that offer browser software, including founding members from Apple, Mozilla and Opera Software. Because the W3C was not working on HTML5, but instead occupied itself with XHTML, this group took matters into its own hands by starting to work out the specification for the next version of HTML. In 2007, the W3C came around to the realization that HTML5 was the place to be and picked up the work started by WHATWG. The W3C has been adding its credibility to the effort since that time.
But the process has been fraught with politics and competing agendas. Chris Wilson of Microsoft was invited to join WHATWG but refused, reportedly over patent policy issues. Many viewed the entire effort as an opportunity to dislodge Microsoft’s position (with ASP.NET) in the Web technology world, but the real goal, now at least, seems to be to make Web development easier for everyone. The politics endangered that, but the good news is that it seems to be coming together now, thanks in large part to some well thought-out guiding principles that have helped build consensus.
Stephanie (Sullivan) Rewis of W3Conversions gave an “Intro to HTML5” presentation in which she outlined the philosophy for HTML5. I recommend it to anyone wanting to really develop expertise with the technology.
According to Rewis, one of the guiding principles for HTML5 is that if any browser maker does not agree to support a feature, then the feature is dropped. I assume that only counts for what we would consider major browser vendors, but she did not elaborate. In either case, I believe that this is important to make sure that fragmenting the browsers does not occur, something that I, as a Web developer myself, am very grateful to see in place.
She also explained that the process of figuring out what to change for HTML5 involved finding the common things that were being done with HTML4 and seek to make those easier and better. This is meant to clear the hacks out of the system and lend itself to higher productivity, since it minimizes the time that Web developers have to spend working around weaknesses in the old system.
Finally, Rewis emphasized the introduction of error handling into HTML5 as a huge benefit. Error handling is of course the key to robust systems and by extension to developing quality systems.
In May of this year, the HTML5 specification entered the Last Call phase, pointing to 2014 as the timeframe for final Recommendation for the standard. There is, though, no need to wait that long to make things happen by solving problems with HTML5.
Why HTML5 matters
There is no longer a single operating platform to rule them all, and in truth, it has been a very long time since there has been one. As Mac machines and Linux-based PCs gained popularity, the Web offered a safe middle ground that helped developers, and the companies that paid them, avoid the tradeoff of single-client support versus building the same application multiple times. The downside, though, was that Web applications have historically meant sacrifices in functionality and difficulty in development relative to native applications.
A word of caution here: We have heard these promises before, and not that long ago. The promise of rich Internet applications sounded a lot like this same story, but in that case the engine behind the promise was always a plug-in, such as Silverlight or Flash. But as vendors like Apple disallow plug-ins on their systems, this becomes an unworkable strategy. Even Microsoft appears poised to have Windows 8 not support plug-ins within the Metro version of the IE10 browser.
One application developed that works well on all platforms would be great, but there are still major things that Web applications cannot accomplish. This means that while HTML5 will help prevent developers from having to create multiple versions of their Web applications, there is still room for native applications. As we will see, the work done in HTML5 can be useful there as well.
What changes with HTML5
HTML5 has already been designed, and it really is less a work in progress than a specification going through its final phase. A major goal of HTML5 has been to better enable what people are already doing on Web pages. Accepting that the greater goal is to facilitate better Web application development, there are several areas where this can be realized. Most obviously, it introduces a slew of new elements, including those that are getting a lot of attention (like the canvas and video elements) to others that are more mundane, such as the figcaption or article elements.
The W3C provides a great resource for seeing exactly those elements that have changed or been added. For example, one of the most common tags there is, the anchor tag, has had the target attribute un-deprecated because it has proven useful in Web applications. The anchor element has also seen the addition of the Media attribute.
This evolutionary process is like taking phrases that are common in regular speech and developing shortcuts for them as we see done all the time in texting. If you are familiar with the meaning and use of the term LOL, then you should appreciate how these evolutions can help. The problem is that change is painful for people, and the bigger the change the greater the leap required.
Having a backward-compatible mode often helps reduce this pain. For example, there is a new syntax available with HTML5 that dispenses with the old section definitions of HEAD and BODY for a more trim syntax, but you can still do things with the old sectional format if you prefer.
Modernizer bridges with the past
As technologies progress, a significant problem has been the need to support the old and new worlds through the same experience. For Web applications, there have been a number of strategies to cope with this issue. Detecting the browser agent and redirecting to targeted versions of the site is a strategy that works, but multiplies the work to achieve the solution. The Modernizr.js script takes a vendor-agnostic approach to something Microsoft provided a solution to for years. In ASP.NET, the App_Browsers folder can be populated with browser definition files that allow the system to do the right thing based on the browser making the request.
The problem with all of Microsoft’s techniques is that they were not adopted by other vendors, whereas Modernizr is open source and widely used, and there is not the same “not invented here” bias against it. The open-source community embraces it, Microsoft’s competitors embrace it, and now Microsoft is promoting it, which is a clear sign that it is the way forward to solving this particular problem of history.
The strength of this book is the fact that it walks the reader through building a sample application from scratch and does not spare the details of the code. It also explains the role of the WinJS API and WinRT in that development process.
WCSchools.com versus WCFools.com
When I first looked into learning HTML5, this was the first site I found useful for playing around easily with the actual HTML5 syntax. My attitude is not shared by everyone. There is another site called W3Fools.com that asserts that the W3Schools site is not only unaffiliated with any real authority such as W3C, but also that the site provides damaging, wrong information. I have no idea if the first claim is actually correct, and for my purposes it did not matter at all. When I reviewed their claims, the data that is cited as incorrect is in the details, deep down. Examples include simplifications and errors about which features are supported by specific browsers.
I agree with the advice to be wary of any informational site, but while I might get some abuse for saying it, the “Try it yourself” feature is too useful to not play with. The best advice is to always get a second source for any information, and to know the source. If you find a blogger or presenter that has provided good information in the past, chances are they will be good in the future.
HTML5 support in Internet Explorer 10
Starting with Internet Explorer 9, Microsoft started to support HTML5 features. With IE10, it has gone into embrace mode. Now that we understand that HTML5 is the key to many companies’ cross-platform strategy, Microsoft only really has two choices: Embrace the wave and make the best of it, or introduce something more capable and compelling and thereby divert the wave.
The latter option is a tall order, though I expect Microsoft thinks its strategy is a bit of a hybrid between the two. If Metro-style apps are a big success, then that is probably true, but with the support for HTML5 in IE10, Microsoft shows it has it covered and won’t be left behind by the other platforms. There is a site provided by Microsoft that lets you see exactly how HTML5 is supported by IE10. I have tried it out and it has the advantage of letting you modify the markup and see how it renders very easily. This is similar to the feature I liked from W3Schools.com.
Metro-style apps with HTML5
The Grid Application template is a Metro-style staple that allows you to quickly build an application that lets you browse things whether those things are books, songs, tasks or anything else you can make work in a grid context.
Figure 2 shows a sample of an application created with this template with only a single edit to the generated HTML. To make that change, I opened the HTML page and edited the text of the page title from the default (the project name) to what I wanted it to display.
When it makes sense
He went on to explain, “If a company plans on using HTML5 outside of Windows 8 for traditional browser applications, then it’s important to understand that only the most modern browsers support HTML5.”