Five HTML5 Techniques to Learn Now
No doubt about it:HTML5 is hot stuff.A year or two ago it was esoteric andunripe; now it's necessary. But does it still make you uncomfortable?
Your hesitation is understandable: Parts ofHTML5are still years away from completion, and other parts involve programming concepts that were entirely absent from front-end work up through HTML4. Don't let those realities intimidate you, though. You can and should take your first HTML5 steps today!
HTMLDOC and Validation: The Easiest Leap Forward
As this article demonstrates, your first few steps will be easy to apply immediately, they'll likely improve your HTML right away, and they won't demand that you learn any client-side scripting or programming. Before you do anything else, for instance, learn how to upgrade existing HTML to HTML5, as well as create new HTML5 source.
You probably already have source that looks like this:
The Title ...
If so, you should transform it to look more like this:
The Title ...
Simple enough, right?
As tiny as this change appears at first, it has significant benefits:
- Essentially all pertinent browsers, even those from before the year 2000, recognize thisDOCTYPEas a marker of standards-based source. This puts them on their best behavior in regard to minimization of vendor-specific interpretations.
- You can validate your source as HTML5. Have you ever validated your HTML source? It's a great thing to do, and becomes even better with HTML5.
The advantages of HTML5 validation are actually a bit more subtle. Validation is a priceless technique—roughly, using an easy "grammar checker" for HTML—and you definitely should become familiar with it. The best return on your investment will come when you not onlyvalidate, but alsocheckyour HTML. You'll need two things:
- An HTML5validator, such asValidator.nu
- An HTML5checkersuch asHTML Lint
These tools quickly detect common spelling errors, missing characters, and other mistakes that plague many HTML sources. On a recent day when I usedvalidator.nuto scanhttp://apple.com/例如,验证器检测到四个迪斯汀ct and definite errors, including use of an obsoleteframeborderattribute foriframe.However extensive your experience with HTML, and however disciplined your process for source creation, modern validation tools will likely improve your results.
Pick a Date
你的最终用户是否需要安排未来的event, such as the expiration for an offer, or a target for a test run? Before HTML5, your choices for such a selection were simple textbox fill-ins with annoyingly complex validation (calendrical rules are complicated), or a more appealing graphical widget from any of several competing libraries.
Now your choice is much simpler:
This is HTML5's standard way of receiving user input for a calendar date. A sufficiently modern browserenforcesthat the only value that can result is a valid date. In the worst case, the input falls back to behave as an old-style textbox.
There's More! Further Structure for Your Forms
dateis only one of 13 newinputtypes that HTML5 makes available. You'll eventually want to learn and incorporateall of them.The availability of these new types allows you to concentrate on domain- and customer-specific concepts, while leveraging standard widgets for numeric values, search boxes, locale-savvy telephone numbers, color selection, and more.
Think for a moment how you'd ask your end user to pick a number between 1 and 50. You could construct a list box with 50 elements, but that would look awkward on most pages, and it would be clumsy to maintain as HTML. You could have users fill in a two-position text box and validate the result, with the overhead involved in programming validation. Or, with HTML5, you can write this:
With this option, you'll becertainthat users can enter only proper whole numbers in the desired range. Even better than that, the user's view is of a standard widget that invites correct data entry.
Curious about which widgets work with which browsers? Learn the latest on this score with theModernizrlibrary, which efficiently detects and reports HTML5 feature support.
Join the Media Club
HTML5 is a large standard.Not only does the article you're reading right now not teach it all, but you probably willneverlearn all of it. That's okay; in fact, the most important aim of this article is not the five specific HTML5 items covered here, but the right attitude to have about HTML5. It's safe to learn little parts of HTML5 as they become useful to you, and then you can build on those parts to expand your HTML5 expertise.
Video is a part of HTML5 that illustrates this principle very well. As you'll see in a moment, you can learn one video construct right now that will pay off immediately for you. As your experience and comfort with it grows, you'll probably extend what you've learned "horizontally," into audio playback, and "vertically," where you'll acquire knowledge about differentcodecsand their roles, as well as the video configurations that HTML5 supports.
The place to start is with a simple tag:
With this tag, you can embed your video on a web page, but not force end users into dependency on specific proprietary plug-ins such as Flash or QuickTime. That's a good thing! In fact, not only do most modern desktop browsers support video, but so do browsers available for most smartphones.
It's also far from the end. As you work with media formats, you'll learn that multimedia formatting is encumbered with technical tradeoffs—and, even more, legal complexity. But it's right to begin simply by replacing theobject,embed, or whatever you've been using, withvideo.
Search and Other Engines
While most of HTML5—especially the graphical parts frequently publicized in strategic discussions—requires JavaScript programming, at least one more important piece of HTML5 should be known to those operating purely at the tag level: HTML5microdata.When we work withinputandvideoand so on, we think in terms of what humans see, but web pages have another audience: search engines and other computer applications. Microdata can help you to get across the point of your web page to robotic readers.
In so-calledsearch-engine optimization(SEO) circles, there's abundant speculation that the right microdata will move a page up in competitive search result rankings. While SEO is outside the scope of this introduction, it's likely that you'll be asked about microdata sometime. You'll need to learn enough about it to be able to answer with confidence that, yes, you can add HTML5 microdata markup.
Although HTML5 microdata operates mostly in the realm of tagged markup, it has even more depth and difficulty thanvideo.Eventually you should read a couple of the fine tutorials that are available. For now, think of a specific concrete example: the "Contact Us" page on the last website you did. Here's how it might look with microdata decorations:
The Organization
This is a great organization. Here is what we say for people to read.135 Elm Street ...人们会阅读这个编码,包括物理al address, and casually focus on the specific details of interest—street address, telephone number, and so on, based on experience that teaches us "135 Elm Street" is more likely to be a street address than to be the name of the CEO. Butitempropexplicitly identifies for search engines that this is astreet-address, with the name of anOrganization, and more. With HTML5 microdata, you clearly identify thetelandfax, and eliminate any possibility that search engines will mistake one for the other.
As with the other HTML5 elements in this introduction, you can start experimenting with microdata right away. However, the payoffs aren't as immediate: It's hard to be certain what a search engine "thinks" as it reads your pages, and browsers themselves are only beginning to interpret semantic markup.
You can set your own schedule for learning these various elements, as they're almost entirely independent of each other. In a world where so many readers are holding HTML5-enabled mobile handsets, however, surelynowis the right time to start.
Page 1of 1