Planning to build mobile apps? Then you need to be clear on what HTML5 is and is not.
If you've been even tangentially involved with Web development over the past year or so, you're more than likely familiar with the term "HTML5." Yet HTML5 is surrounded by a whole lot of confusion and misinformation. This quick tip will sort some of it out for you.
What HTML5 Is Not
HTML5 is the next generation of HTML code. The HTML5 specification provides an extensive array of new features provided mostly through the tags and attributes of HTML. Whether it's the new figure element or the placeholder attribute, HTML5 does a very good job of extending HTML to be much more friendly to both Web content generation and Web application development. I'll touch on a few of those features in a moment, but before I do, I'd really like to focus on what HTML5 is not.
You've probably heard about a number of new features that are either available for your Web documents or coming soon to a browser near you. These include things like CSS3 and local storage. And while many of these things are being released at the same time as HTML5, they are not strictly part of the HTML5 specification. Let me list a few.
- Local Storage—Most people who talk about HTML5 and local storage tend to do so in the same breath, although technically the two are not synonymous. Local storage, also known as Web storage, is so complicated a concept that it has been separated from the base HTML5 specification and now has a specification of its own. The 10-second summary, though, is that local storage is an API available to the application that provides access to both permanent storage by domain and temporary storage by session. Note that local storage by definition is not in the cloud; if your client machine gets fried, so does your data.
- WebSockets—Just as Web storage provides persistent data, WebSockets is meant to provide a persistent connection to the host. WebSockets is designed as a lighter-weight, easier-to-program, and better-performing replacement for the venerable XMLHttpRequest API that has been the basis of AJAX support for many years now. While its implementation is still spotty among the various browsers, I think WebSockets has the potential to have one of the biggest impacts of all the new specifications. You might want to take a closer look here.
What HTML5 Is
Now that I've explained what HTML5 isn't, let me point out a few of the things that it is. I tend to break this down into a few categories: features, syntax, and enhancements. I can only cover a fraction of what is available, so let me try to point out some highlights.
- Syntax—Syntax is a slightly different topic and involves extending the basic lexicon of the language. One way that HTML5 has done that is to implement a whole series of new tags that have specific meaning. Those who use the Web as a mass media outlet have long been waiting for something a little more sophisticated than H1 and BOLD. With HTML5, several new tags have been added, including things like Figure, Nav, Article, and Aside, all of which provide much-needed functionality for publishing online content. Take a look at the Figure element, for example. A simple idea, Figure combines an image with a caption. The HTML5 Doctor has a good example.
- Enhancements—Enhancements are sort of a mix between the previous two categories; take an existing element and add some new functionality—typically through a new tag—and you've got what I would call an enhancement. A whole lot of those have been added, especially to the forms-processing aspect of HTML5. For example, a couple of additional attributes are required and a placeholder. The required attribute for input fields is pretty intuitive; it means that the field is required and if the user doesn't enter it, the Submit button won't be processed. Note that in order to implement this, the HTML5 designers also had to add another attribute for the Submit button called formnovalidate. Formnovalidate changes a Submit button from the default of acting like a green-screen CF key to making it act like a CA key. It's amazing how these same concepts keep coming around, isn't it? The placeholder attribute will be a little less obvious to us green-screen folks, but it's really quite nice. If a field has a placeholder but no data has been entered, the placeholder is shown, usually in a gray font to differentiate from user-entered data. WebDesignerWall has a nice demo.
Time to Explore!
Yes, HTML5 support is still pretty uneven among the major desktop browsers (you can find out how well your browser scores by going to this Web site). However, the mobile devices tend to score pretty highly on HTML5 compliance, so if that's the direction you're headed, it would probably do you well to explore a little more about HTML5. And of course, even the hoary old desktop browsers will eventually follow suit, so it probably wouldn't hurt to stay ahead of that curve. Go have some fun with HTML5!