[whatwg] microformats, microdata, and custom data attributes

Tab Atkins Jr. jackalmage at gmail.com
Mon Apr 18 12:48:27 PDT 2011

On Mon, Apr 18, 2011 at 11:53 AM, Justin Karneges <justin at affinix.com> wrote:
> Hi Tab,
> So I take it that using data-* for this is not recommended?

Yes, data-* isn't intended to be used for interchange information and
the like.  It's just a blessed way for scripts to stash data onto DOM
nodes directly, in situations where that's the most convenient place
to put the data.

> On Friday 15 April 2011 22:12:24 Tab Atkins Jr. wrote:
>> On Fri, Apr 15, 2011 at 6:29 PM, Justin Karneges <justin at affinix.com> wrote:
>> > Hi folks,
>> >
>> > I'm desiring a way to markup "mentions of a person" semantically within
>> > HTML, for use in an open standard.  Think of a more rich form of the
>> > @person convention used on Twitter and elsewhere:
>> >
>> > <p>@justin I totally agree</p>
>> >
>> > My first thought was to use a data-* attribute.  For example:
>> >
>> > <p><a href="http://example.org/justin/" data-mention-
>> > id="acct:justin at example.org" data-mention-context="reply">justin</a> I
>> > totally agree.</p>
>> >
>> > However, the HTML specification says custom data attributes are only to
>> > be used privately.  So, I am not sure if it is appropriate to create a
>> > public standard whereby independent developers are encouraged to utilize
>> > a common data-* attribute.
>> >
>> > Another way is to use Microdata, though I seem to have to hack it a bit
>> > to have hidden values:
>> >
>> > <p><a href="http://example.org/justin/" itemscope
>> > itemtype="http://example.org/itemtypes/mention"
>> > itemid="acct:justin at example.org"><span itemprop="context:reply"/><span
>> > itemprop="name">justin</span></a> I totally agree.</p>
>> If necessary, representing hidden data can be done via <meta itemprop
>> content> in Microdata.
>> It might be useful to understand a little more about your goal in
>> marking this up, though, so the most appropriate way to do so can be
>> determined.  Is this meant to be processed by machines?  If so, what
>> use will it be put to?
> Yes, this is meant to be processed by machines, as part of a data exchange
> protocol.  It is not browser-specific.  For example, this kind of HTML
> formatting may find its way into an Atom feed, or even an XMPP message.  It is
> not expected that this format would be shoved directly to a browser for render
> (although, if someone does that, ideally it should degrade gracefully, hence
> the use of <a> around the name).
> Here are two things I'd expect apps to do:
>  1) Render the mentions in a special way.  For example, our application shows
> the mentioned name inside of a colored, button-looking box with an icon image
> based on the domain of the person being mentioned.  This kind of presentation-
> level detail would not be encoded in the HTML itself.
>  2) Keep display names up to date.  In the event that a user changes his/her
> name, but the account id is not changed, future replays or retransmissions of
> this HTML may contain different name text (the 'justin' part in my example).
> For example, an aggregator may track name changes, and update its cached HTML
> accordingly rather than holding onto stale names.
> Regarding #2, it may also be useful for servers that persist this data to do
> so without saving any name text at all (imagine the 'a' element in the earlier
> example having no cdata).  Whenever the HTML blob is extracted from the db, it
> would need to be stamped with the name of the mentioned user before sending
> out to a client.

Okay, so it's intended as basically "RSS for tweets" - a distributed
way of marking of mini-conversation streams so arbitrary endpoint
applications can consume and reformat them?  Got it.

First, I recommend working with the Microformats community to define
the data language.  If this is meant to be a standard, they're the
go-to people to work with in getting this sort of thing stable and
complete.  This is roughly similar to hAtom, which is for marking up
blogs and similar, but it has a further element of "replying" or
"mentioning" which is somehow tied up in identity management.  There's
some difficult issues hiding in here that probably need a bunch of
eyes to find bugs.

Microformats are traditionally defined using HTML4 rel/class-based
techniques, but they're trivial to translate into a more explicit
Microdata-based vocabulary as well.


More information about the whatwg mailing list