Activate your free membership today | Log-in

Wednesday, July 1st, 2009

Modernizr: HTML5 and CSS3 detection

Category: HTML, Standards

Modernizr is a new library that detects various HTML5 and CSS3 features and lets you know so you can use them:

Writing conditional CSS with Modernizr

Now, once your page loads, Modernizr will run and go through all of its tests. It will automatically add all the classes to the <body> element of the page, and these classes will be along the lines of body.feature or body.no-feature, with the former indicating that the current browser supports that specific feature and the latter indicating that the browser does not support the feature.

Additionally, it will create a new JavaScript object in the global scope, called Modernizr. This object will contain properties for each of the features that Modernizr detects for, and their value will be set to TRUE or FALSE depending on the browser's support for it.

What you can do from this point on is write pseudo-IF/ELSE statements in your CSS. Let's look at an example from the Modernizr.com site itself:

CSS:
  1.  
  2. .cssgradients #main {
  3.     background: -webkit-gradient(linear, left 0, right bottom,
  4.         from(rgba(255,255,255, .82)),
  5.         to(rgba(255,255,255, 0))) 0 0 no-repeat;
  6. }
  7.  

In the above example, we're doing an "IF" condition in CSS: IF the browser supports both CSS gradients, THEN apply this background property to the #main element (instead of the original background property).

Writing conditional JavaScript with Modernizr

When leveraging Modernizr in your JavaScript, it's as straight-forward as it can be to do IF-conditions based on what the browser currently supports:

CSS:
  1.  
  2. if (Modernizr.cssgradients) {
  3.     // perform some actions you only want to
  4.     // execute if the browser supports gradients
  5. }
  6.  

We are seeing a growth in these kinds of tools and shims to get HTML5 features into developers hands. Another great site to help is the new HTML5 Doctor.

Posted by Dion Almaer at 11:29 pm
5 Comments

++++-
4.6 rating from 13 votes

Monday, June 22nd, 2009

HTML 5 and the Wizard of Oz

Category: Fun, HTML

Kyle Weems, the CSS Squirrel and author of the occasional and bizarre comic of the same name, targets his latest rendering at Ian Hickson:

Click-through to see the full comic. The related blog entry fleshes out the basic complaint some more:

Why is it that the person who is the center of this process is allowed to be a man who rejects consensus, actively denies issues (based on his own admitted policy) and substitutes expert advice in important areas like accessibility with analyzing data from the Google Index and parsing numbers? Numbers that we cannot have a third party confirm because every request to do just this is ignored?

There is no doubt in my mind that Ian is brilliant. However no man, no matter how brilliant, should be allowed to be so influential on a spec when he is bringing all this baggage to the table with him.

The number of grievances folks have with any standards process are legion, but wouldn't life be more fun if they all came with comics?

(As I wrote this, Dion leaned over and said, "I used to work with Ian, I find it funny to think of anyone trying to control him.")

Posted by Ben Galbraith at 1:05 pm
11 Comments

++++-
4.4 rating from 25 votes

Monday, May 11th, 2009

Hixie discusses the addition of HTML5 “microdata”

Category: HTML, Standards

Ian Hickson has chatted about an addition to HTML5, "microdata":

Annotate structured data that HTML has no semantics for, and which nobody has annotated before, and may never again, for private use or use in a small self-contained community.

He goes on to detail a number of scenarios such as this subset:

  • A group of users want to mark up their iguana collections so that they can write a script that collates all their collections and presents them in a uniform fashion.
  • A scholar and teacher wants other scholars (and potentially students) to be able to easily extract information about what he teaches to add it to their custom applications.
  • The list of specifications produced by W3C, for example, and various lists of translations, are produced by scraping source pages and outputting the result. This is brittle. It would be easier if the data was unambiguously obtainable from the source pages. This is a custom set of properties, specific to this community.

and then shows how one could take:

HTML:
  1.  
  2. <section>
  3.  <h1>Hedral</h1>
  4.  <p>Hedral is a male american domestic shorthair, with a fluffy black
  5.  fur with white paws and belly.</p>
  6.  <img src="hedral.jpeg" alt="" title="Hedral, age 18 months"
  7.  class="photo"/>
  8. </section>
  9.  

and extract:

Cat name:    "Hedral"
Description: "Hedral is a male american domestic shorthair, with afluffy black fur with white paws and belly."
Image:       "http://example.org/hedral.jpeg"

Here is where the fun begins as Ian walks through the issues with the microformat-esque approach, namely the overloaded "class":

there is no way for a parser to know which classes are properties of cats and which are just for styling (e.g. 'photo' used in this example).

I have to admit that I think the baby could be thrown out with the bathwater here. I would hate to see class="cat" type="cat" for example!

Many iterations on, and we see:

HTML:
  1.  
  2. Page 1:
  3.    <section item="com.damowmow.cat">
  4.     <h1 property="com.damowmow.name">Hedral</h1>
  5.     <p property="com.damowmow.desc">Hedral is a male american domestic
  6.     shorthair, with a fluffy black fur with white paws and belly.</p>
  7.     <img property="com.damowmow.img" src="hedral.jpeg" alt="" title="Hedral, age 18 months"/>
  8.    </section>
  9.  
  10.    Page 2:
  11.    <body item="com.damowmow.cat">
  12.     <p>I love my cats. My oldest cat is <span property="com.damowmow.name">Silver</span>. <span property="com.damowmow.desc">Silver is <span property="com.damowmow.age">11</span> years old and refuses to eat
  13.     alone, always waiting for either Yellow or Blue to eat with
  14.     him.</span></p>
  15.    </body>
  16.  
  17.    Page 3:
  18.    <h2>My Cats</h2><h2>
  19.    <dl>
  20.     <dt>Schr&ouml;dinger
  21.     <dd item="com.damowmow.cat">
  22.      <meta property="com.damowmow.name" content="Schr&ouml;dinger">
  23.      </meta><meta property="com.damowmow.age" content="9">
  24.      <p property="com.damowmow.desc">Orange male.
  25.     <dt>Erwin
  26.     <dd item="com.damowmow.cat">
  27.      <meta property="com.damowmow.name" content="Lord Erwin">
  28.      </meta><meta property="com.damowmow.age" content="3">
  29.      <p property="com.damowmow.desc">Siamese color-point.
  30.      <img property="com.damowmow.img" alt="" src="/images/erwin.jpeg"/>
  31.    </p></meta></dd></dt></p></meta></dd></dt></dl>
  32.  

I don't miss the com.* world of Java. I hate the verboseness. It looks so ugly to compare "com.mycompany.foo.cat" to "cat". Is it just me?

Hixie then concludes:

To address this use case and its scenarios, I've added to HTML5 a simple
syntax (three new attributes) based on RDFa. It doesn't have the full
power of RDF, because that didn't seem to be necessary to address the use
cases. It doesn't really have anything in common with Microformats; I
didn't find the Microformats syntax to be very convenient. (This was also
the experience with eRDF.)

I expect the syntax will need adjustments over the coming weeks to address
issues that I overlooked. I look forward to such feedback.

I also found the following Tweets interesting (via @kevinmarks and @diveintomark) as I wrote this :)

@hixie @kidehen URLs are useful, as they resolve. all else is stamp collecting.

@kidehen In practice few people really understand the subtlties of URN vs URI vs IRI vs URL vs Web Address vs Hypertext Reference vs...

All this crap about HTML5 "gatekeepers" is hiLARious. For 6 years, they BEGGED the W3C to work on HTML+1. The W3C said no.

Posted by Dion Almaer at 6:13 am
20 Comments

++---
2.1 rating from 28 votes

Wednesday, April 29th, 2009

Birth of the datagrid element in HTML 5

Category: HTML, Standards

Mark Pilgrim has nicely discussed the new HTML 5 datagrid element on his latest This Week in HTML 5:

In the datagrid data model, data is structured as a set of rows representing a tree, each row being split into a number of columns. The columns are always present in the data model, although individual columns might be hidden in the presentation.

Each row can have child rows. Child rows may be hidden or shown, by closing or opening (respectively) the parent row.

Rows are referred to by the path along the tree that one would take to reach the row, using zero-based indices. Thus, the first row of a list is row "0", the second row is row "1"; the first child row of the first row is row "0,0", the second child row of the first row is row "0,1"; the fourth child of the seventh child of the third child of the tenth row is "9,2,6,3", etc.

The chains of numbers that give a row's path, or identifier, are represented by arrays of positions, represented in IDL by the RowID interface.

The root of the tree is represented by an empty array.

Each column has a string that is used to identify it in the API, a label that is shown to users interacting with the column, a type, and optionally an icon.

The possible types are as follows:

Keyword Description
text Simple text.
editable Editable text.
checkable Text with a check box.
list A list of values that the user can switch between.
progress A progress bar.
meter A gauge.
custom A canvas onto which arbitrary content can be drawn.

Each column can be flagged as sortable, in which case the user will be able to sort the view using that column.

Columns are not necessarily visible. A column can be created invisible by default. The user can select which columns are to be shown.

When no columns have been added to the datagrid, a column with no name, whose identifier is the empty string, whose type is text, and which is not sortable, is implied. This column is removed if any explicit columns are declared.

Each cell uses the type given for its column, so all cells in a column present the same type of information.

Posted by Dion Almaer at 4:26 am
6 Comments

++++-
4.8 rating from 23 votes

Monday, April 27th, 2009

CiteDrag: Cool library that groks the new drag and drop model

Category: HTML, JavaScript, Library

Elijah Grey has a very cool new script CiteDrag that "adds automatically citation (ie. blockquotes, text quotes, ect.) to any dragged content off of the website which is using the script. CiteDrag requires no additional setup other than include the script somewhere on your website."

I just dragged that above text from my blog post where announced the creation of CiteDrag and dropped it into my WordPress “Edit Page” interface, where automatically appeared quoted. Looking into the <blockquote> we can see that it even has the cite attribute defined. That is just one example of how CiteDrag works.

In a browser such as Firefox 3.5 beta (Shiretoku or a Firefox Nightly) go over to the test page and then start to drag the links, text, and image over to the text area.

Very cool work!

Posted by Dion Almaer at 8:21 am
5 Comments

++---
2.4 rating from 5 votes

Thursday, April 23rd, 2009

More Web Workers in Action

Category: HTML, Standards

Another day, another Paul Rouget HTML 5 demo :) This time he does something fun with Web Workers to allow you to see the difference that you can get when you use them.

His latest simulation has him implementing Simulated Annealing (in video) which is useful for finding the shortest path between several points in a canvas.

If you run the demo demo and watch the animated PNG you will see how smooth the world is based on if the animation stops from time to time. Try it with workers on and off to see.

We have been using Workers in Bespin from the get go. Malte Ubl is doing very cool work to ironout the differences between different Web Worker implementations (Firefox, Safari, and Gears). For example, through his abstraction you get the standard importScripts in Gears too, and it includes a mutex abstraction to boot. This has been crucial for us as we add more JS intensive features to the code editor such as realtime syntax checking, rich syntax highlighting, JSLint error reports inline, and more.

We have found that you do have to be careful with Workers though. You don't want to fire too many off as you end up with a raging CPU if you aren't careful, so Malte and others are working on a slicing plan that will keep the CPU down but also keep the UI responsive. We will report back.

Posted by Dion Almaer at 7:14 am
Comment here

++++-
4.1 rating from 16 votes

Monday, April 13th, 2009

Getting to the depths of “time”

Category: HTML

PPK has a nice detailed posting on the HTML 5 time tag and he asserts:

The HTML 5 spec introduces the

It goes into great depth to discuss the nuance of dates and it makes you really reflect on how complex this can be.

Who needs machine readable dates? As far as I can see there are two target audiences for this operation. The first is obviously social applications that have to work with dates, and where it can be useful to compare dates of two different events. An app must be able to see if two events fall on the same day and warn you if they do.

However, as a target audience social applications are immediately followed by historians (or historical, chronological applications). After all, historians are (dare I say it?) historically the most prolific users of dates, until they were upstaged by social applications.

This raises the question whether the <time> element should be tailored for historical use at all. When I started writing this entry I was convinced that it should.

In keeping with the definition of its purpose I the see the <time> element as a tool for an Internet-wide chronological search-and-compare system. Such a system will be a boon to historians, who would be allowed to quickly and easily look up events that happened around the same time as the event they’re writing about.

In history, just as in other academic disciplines, serendipitous discoveries are the meat of exciting new theories. A history-compliant use of the <time> element that allows automatic search and compare would broaden the horizons of historians.

However, now that I’ve reviewed some of the more common problems that have to be solved in order to decrease potential harm, I’m starting to doubt whether the <time> element can easily be made to fit history.

Right now, though, the specification is a vague compromise that doesn’t make the <time> element useful for historical research, but still allows it to be used historically.

I feel this ambiguity should be removed. I feel that the specification should clearly state whether the <time> element is meant for historical use or not. The current vague, implied “No” should be changed to a clear answer. I prefer Yes, but I can live with No.

Posted by Dion Almaer at 6:34 am
1 Comment

++++-
4.5 rating from 15 votes

Tuesday, March 31st, 2009

Shrinking HTML5

Category: HTML, Standards

Anne van Kesteren has posted on the specs that are moving out of the large HTML5 mega spec, and into their own little ditties:

The current state of things is that the following editor drafts are separated out from HTML5:

Meanwhile DanC created an initial draft that will lead to splitting out the URL section as detailed in my last post. I did some testing on CSS URL handling and found out it uses exactly the same algorithm as HTML5 in user agents except that the URL character encoding is always set to UTF-8, just like it works for XMLHttpRequest. In light of this it would make sense to simply revise the IRI specification to make more sense, but there are not enough proponents for that apparently as it would affect e.g. Atom. I guess creating a separate IRI specification (which is what the HTML5 URL handling is) creates less theoretical issues… I wonder though whether anyone has actually tested Atom clients. Do they really refuse to handle spaces in URLs? Do they really do the right thing per the IRI specification and normalize URLs when the encoding of the feed is not a Unicode encoding? Do any clients that handle IRIs do that properly? I doubt it.

Posted by Dion Almaer at 3:57 am
Comment here

+++--
3.8 rating from 4 votes

Monday, March 23rd, 2009

All for one, and one for all

Category: HTML, Standards

Philippe Le Hegaret has created an uber-demo that puts a bunch of new technology into one HTML document.

View source that puppy to see html video with DFXP captions, SVG, MathML, RDF, CSS goodness, and much much more.

I can't admit to caring as much about the XHTML 5 support that Sam talks about ;)

Posted by Dion Almaer at 12:12 am
2 Comments

++---
2.5 rating from 4 votes

Friday, March 6th, 2009

The Road to HTML 5: spellchecking and contentEdible

Category: HTML, Standards

I am sorry, but I can't help but write contentEdible for some reason :) Mark Pilgrim has been pushing forward with his series on HTML 5, and recently has a couple of interesting dives:

Spellchecking

The feature of the day is spell checking, by which I mean client-side in-browser checking of text in standard <textarea> and <input type=text> elements. Several browsers support this out-of-the-box, including Firefox 2 and 3, Safari 3, Opera 9, and Google Chrome. However, each browser has different defaults of which elements get spell-checked, and only a handful allow the web author to suggest whether browsers should offer checking on a particular element.

In this article:

contentEditable

Welcome back to my semi-regular column, "The Road to HTML 5," where I'll try to explain some of the new elements, attributes, and other features in the upcoming HTML 5 specification.

The feature of the day is contentEditable, by which I mean client-side in-browser "rich text" editing. All major browsers support this now, including Firefox 3, Safari 3, Opera 9, Google Chrome, and Internet Explorer (since 5.5). Of course, the devil is in the details.

In this article:

Posted by Dion Almaer at 6:06 am
4 Comments

++---
2.8 rating from 13 votes

Friday, February 20th, 2009

Caching scripts in HTML5 Database

Category: HTML

Ian Collins has created DBScriptCache, a JavaScript program that "automatically caches script files in the browser's HTML5 client-side database. Rather than including your scripts using script tags, you include them using this script. The first time a user views the page the scripts will be pulled into the db and stored. On subsequent visits the scripts will be loaded from the db cache and not from your server. The script will continue to come from the cache until you supply a new version number or change the name of the script."

You can see it in action on Ian's site:

HTML:
  1.  
  2. <script src="cache_loader.js">
  3. window.script_cache = window.script_cache || new ScriptCache();
  4. window.script_cache.includes([
  5.   ['js/brawndo.js','1.5'],
  6.   ['js/app.js','1.5']
  7. ]);
  8. </script>
  9.  

Posted by Dion Almaer at 6:30 am
10 Comments

+++--
3.8 rating from 21 votes

Thursday, February 19th, 2009

Google Maps on Palm Pre; Gmail on iPhone

Category: HTML, Mobile

Vic Gundotra, my former VP at Google, gave some great demonstrations of HTML 5 and the Mobile Web the Mobile World Congress in Barcelona.

He showed off the Palm Pre device running a Web application on their platform:

Video courtesy of PreCommunity.com

Gmail Demo on iPhone and HTC Magic

Then he showed Gmail Offline running on iPhone and HTC using HTML 5 Storage API

Video courtesy of AndroidCommunity.com

Once again we get to see HTML pushing hard in the mobile space.

Posted by Dion Almaer at 4:55 am
Comment here

+++--
3.2 rating from 5 votes

Thursday, February 12th, 2009

Frames are back

Category: HTML

Remember the days of frames and framesets? Not the iframe, but when you had sites with fixed headers and you cursed at not being able to bookmark correctly.

Anne Van Kesteren has blogged about HTML5 frames and how the world is different:

Personally I’m quite fond of the way HTML frames are handled in HTML5. In case you missed it, HTML5 now defines rendering of HTML in non-normative fashion. All gory rendering details of all HTML elements that affect rendering in contemporary Web browsers defined, including blink and marquee. Yay! For implementors this is really useful. I can recall several instances offhand where Opera QA was trying to figure out what the default styling was in other browsers for certain elements because pages did not look quite the same. (E.g. margin of form elements in quirks mode or various elements that need to have text-indent:initial applied to them for unknown reasons.)

Frames and framesets is designed as a simple grid algorithm that ignores CSS for that particular document. For an obsolete feature, it’s quite neat. I almost started writing evil test cases against it (e.g. inserting a body element before the frameset, removing the head element, etc.), but then decided that ensuring that extremely old and obsolete features work correctly is probably not the best use of my time. (Admittedly I’m still tempted.)

He links to Mark Pilgrims latest HTML5 update that includes:

The big news this week is more major work on the non-normative section on rendering HTML documents, including a lot of reverse-engineered documentation of legacy (invalid) attributes that users expect browsers to support.

Posted by Dion Almaer at 6:33 am
9 Comments

++---
2.2 rating from 36 votes

Wednesday, February 11th, 2009

When can I use a given Web feature?

Category: Browsers, HTML, Standards

When can I use... is a nice site that Brad Neuberg mentioned which does something that we have been looking to do. It gives compatibility tables for features in HTML5, CSS3, SVG and others.

Great stuff!

Posted by Dion Almaer at 2:28 pm
11 Comments

++++-
4.4 rating from 23 votes

Monday, February 9th, 2009

A couple of weeks in HTML 5

Category: HTML

Mark Pilgrim release a couple of HTML 5 roundup posts in a row. In his first post he talks about:

Big news #1: r2692, a major revamp of the way application caches are defined. Application caches are the heart of the offline web model which can be used to allow script-heavy web applications like Gmail to work even after you disconnect from the internet.

Big news #2: r2684, which redefines the on* attributes in a way that doesn't suck quite as much. Also, it defines the widely used (but poorly understood) onerror attribute in a way that matches what browsers actually do with it.

Big news #3: r2685 and r2686 defines a whole slew of important events that are fired on the Window object, including onbeforeunload, onerror, and onload. Previously, some of these were defined on the <body> element, which didn't actually match current browser behavior.

In his latest post he discusses the news this week that is the beginning of the non-normative section on rendering HTML documents. For those of you not up on spec-writing lingo, "non-normative" means "you can ignore this and still claim to be in compliance with the specification." It's advice, not commands. On the other hand, it's generally useful advice, so ignoring it completely is probably not in your best interests.

Posted by Dion Almaer at 4:02 am
3 Comments

+++--
3 rating from 12 votes

Friday, February 6th, 2009

document.getElementById(”check1″).indeterminate = true; Now shipping in Firefox Trunk

Category: Firefox, HTML, Mozilla, Standards

Michael Ventnor posted about his implementation of the indeterminate state that is specified in HTML5 for checkboxes and radio buttons:

If you do any web development, chances are you know checkboxes and radio buttons can have two states: checked and unchecked. But in the case of checkboxes, you may want to indicate to the user that they are half-way between those states, for example when you have a master checkbox above many other checkboxes of singular items. This is now possible on Trunk (Firefox 3.2) thanks to the implementation of the HTML5 "indeterminate" DOM property. All it takes is a bit of script:

JAVASCRIPT:
  1.  
  2. document.getElementById(”check1?).indeterminate = true;
  3.  

Now you can see if the sub-glass is half full. CSS3 :indeterminate pseudoclass isn't there yet.... but check back tomorrow.

Posted by Dion Almaer at 6:40 am
5 Comments

+++--
3.2 rating from 21 votes

Next Page »