NukeViet CMS 4.x

http://vimhpgroup.vn

HTML 5 review

I have to say that my money used to be on XHTML 2.0 eventually winning the battle for the next great web standard. Either that, or the two titans would continue to battle it out for the forseable future, leading to an increasingly fragmented web.

But now that the W3C has admitted defeat, and abandoned XHTML 2.0, there’s now no getting away f-rom the fact that HTML 5 is the future. As such, I’ve now spent some time taking a look at this emerging standard, and hope you’ll endulge my ego by taking a glance over my thoughts on the matter.

Before I get started though, I have to say that I’m very impressed by what I’ve seen. It’s a good set of standards that are being cre-ated, and I hope that they will gradually be adopted over the next few years.

New markup

HTML 5 introduces some new markup elements to encourage better structure within documents. The most important of these is <section>, which is used to define a hierarchy within a document. Sections can be nested to define subsections, and each section can be broken up into <header> and <footer> areas.

The important thing about this addition is that it removes the previous dependancy on <h1>, <h2> and related tags to define structure. Within each <section>, the top level heading is always <h1>. You can use as many <h1> tags as you like within your content, so long as they are correctly nested within <section> tags.

There’s a plethora of other new tags, all of which seem pretty useful. The best thing about all of this, however, is that there’s no reason not to start using them right away. There’s a small piece of JavaScript that’s needed to make Internet Explorer behave, but aside f-rom that it’s all good. More details about this hack are available at http://www.diveintohtml5.org

Easier media embedding

HTML 5 defines some new tags that will make it a lot easier to embed video and audio into pages. In the same way that images are embedded using <img> tags, so now can video and audio files be embedded using <video> and <audio>.

I don’t think than anyone is going to complain about these new features. They free us f-rom relying on third-party plugins, such as Adobe Flash, for such simple activities such as playing video.

Unfortunately, due to some annoying licensing conditions and a lack of support for the open-source Theora codec, actually using these tags at the moment requires that videos are encoded in two different formats. Even then, you’ll still need to still provide an Adobe Flash fallback for Internet Explorer.

You’ll need to be pretty devoted to HTML 5 to use these tags yet…

Relaxed markup rules

This is one thorny subject. You know how we’ve all been so good recently with our well-formed XHTML, quoting those attributes and closing those tags? Now there’s no need to, apparently…

On the surface, this seems like a big step backwards into the bad days of tag soup. However, if you dig deeper, the reasoning behind this decision goes something like this:

  1. It’s unnacceptable to crash out an entire HTML page just because of a simple XML syntax error.
  2. This means that browsers cannot use an XML parser, and must instead use a HTML-aware fault-tolerant parser.
  3. For consistency, all browsers should handle any such “syntax errors” (such as unquoted attributes and unclosed tags), in the same way.
  4. If all browsers are behaving in the same way, then unquoted attributes and unclosed tags are not really syntax errors any more. In fact, by leaving them out of our pages, we can save a few bytes!

This isn’t to say that you have to throw away those XHTML coding habits. It’s still all valid HTML 5. In fact, if you really want to be strict, you can set a different content-type header to enforce well-formed XHTML. But for most people, we’ll just carry on coding well-formed HTML with the odd typo, but no longer have to worry about clients screaming at us when the perfectly-rendered page doesn’t validate.

So what now?

The HTML 5 specification is getting pretty close to stable, so it’s now safe to use bits of this new standard in your code. How much you use is entirely a personal choice. However, we should all get used to the new markup over the next few years, because HTML 5 is assuredly here to stay.

Myself, I’ll be switching to the new doctype and using the new markup for document sections in my code. This step involves very little effort and does a good job of showing support for the new specification.

The new media tags are another matter. Until all platforms support a single video format, it’s simply not sustainable to be transcoding all videos into two filetypes. When this is coupled with having to provide a Flash fallback, it all seems like a pretty poor return on investment.

These features will no doubt become more useable over the next few years, as newer browser take the place of old. One day, hopefully, we’ll be able write clean, semantic pages without having to worry about backwards-compatibility.

Part of this progress relies on web developers using these new standards in our pages. By adopting new technology, we show our support for the standards it represents and place pressure on browser vendors to adhere to those standards. It’s a bit of effort in the short term, but in the long term it will pay dividends.

', 'http://www.etianen.com/blog/developers/2010/2/html-5-review/

Source: Enlightened Website Development

You did not use the site, Click here to remain logged. Timeout: 60 second