Feed Sign in with OpenID OpenID

Simon Willison’s Weblog

Embedding custom non-visible data in HTML 5. “Every HTML element may have any number of attributes starting with the string ’data-’ specified, with any value.”—this will be incredibly useful for unobtrusive JavaScript where there’s no sensible place to store configuration data as HTML content. It will also mean Dojo has an approved method for adding custom attributes to declaratively instantiate Dojo widgets.

3 comments

  1. Hurrah! Invisible metadata!

    Related: Principles of visibility and human friendliness
    http://tantek.com/log/2005/06.html#d03t2359

    Drew McLellan - 21st April 2008 18:18 - #

  2. I don't think this kind of attribute counts as invisible metadata, at least not in the same way as the meta elements Tantek uses in his example. If you use a data-* attribute with unobtrusive JavaScript the effect of that attribute becomes immediately visible - if you are configuring a slider for example and you have the wrong value in your markup the slider won't behave as you expected it to. The wording of that part of the HTML 5 spec seems to discourage the application of meaning to those attributes outside of the page that they appear on, which suggests that they are not intended for exposing metadata at all.

    Simon Willison - 22nd April 2008 18:57 - #

  3. Yes, I think you're correct.

    "User agents must not derive any implementation behavior from these attributes or values."

    The risk of data-rot is still there, but mitigated somewhat.

    Drew McLellan - 23rd April 2008 10:49 - #

Sign in with OpenID

Auto-HTML: Line breaks are preserved; URLs will be converted in to links.

Manual XHTML: Enter your own, valid XHTML. Allowed tags are a, p, blockquote, ul, ol, li, dl, dt, dd, em, strong, dfn, code, q, samp, kbd, var, cite, abbr, acronym, sub, sup, br, pre

A django site