[whatwg] hrefclass attribute ? -- semantics token reuse
Charles Iliya Krempeaux
supercanadian at gmail.com
Sat Nov 26 14:28:49 PST 2005
This is kind of a follow up to a previous post of mine:
rel/rev for <form> ?
Now, although I still think "rel" and "rev" attributes on the <form>
element would be useful, I did note (to myself) that in some cases
"rel" and "rev" were not what I really wanted. "rel" and "rev"
specify semantics between (all or part of) the document they are in
and the resource the "href" (or "action") attribute points to. (At
least that's my understanding of it.) For example:
<a rel="alternate" type="application/rss+xml"
<a rel="friend met" href="http://joe-blow.example.com/">...</a>
Now, sometimes you just want to specify semantics about the resource
at the end of the "href" (or "action") attribute without there
necessarily having to be a relation (between the 2 resources).
Here's an examples where we can specify semantics about the resource
at the end of the "href":
<a hreflang="en-CA" href="http://example.com">...</a>
(The important part in that example is the "hreflang" attribute.)
This would tell you that the resource indicated by
"http://example.com" has a base language of "Canadian English".
Here's another example:
(The important part in that example is the "type" attribute.) This
would tell you that the resource indicated by
"http://example.com/test.torrent" has a content type of
We could also show similar examples for the <link> element. Like:
<link rel="stylesheet" type="text/css" media="tv" href="/style/tv.css" />
(Here we have the familiar "rel" specifying semantics, in addition to
"type" and "media", about the resource indicated by the "href"
Also, we could show examples for the <form> element with respect to
the "action" attribute; the <blockquote> element with respect to the
"cite" attribute; the <img>, <script>, and <style> elements with
respect to the "src" attribute. (This isn't an exhastive list.)
The problem here is that these attributes provide only limited metrics
which we can specify semantics on. For semantics beyond any of these
metrics, we have the "class" attribute at our disposal. (For this
discussion, I don't think it is relevant if the UA -- the web browser
-- necesarily understands that semantics exposes through the "class"
Among other things... like styling... the "class" attribute let's us
specify semantics. For example:
<a class="fn" href="mailto:charles at reptile.ca">Charles Iliya
<abbr class="type" title="work">(work)</abbr>
(For those curious, this is an hCard -- http://microformats.org/wiki/hcard )
Now, although there is nothing I can see that would prevent use of the
"class" attribute from being used to specify semantics on the resource
at the end of the "href" for the <a> or <link> elements (or the
resource at the end of the "action" attribute on the <form> element,
or the resource at the end of the "cite" element for the <blockquote>
element, or the resource at the end of the "src" attribute for the
<img>, <script>, or <style> elements, etc) it does make it somewhat
difficult or impossible to reuse semantic tokens. Let me illustrate
this with an example.
Let's say there there is a blog at http://example.com/. And let's say
we have a blog post (for this blog) at
http://example.com/log/1234.html. Now let's say this blog post --
http://example.com/log/1234.html -- contain the following link:
<a rel="author" href="http://example.com/">...</a>
(Pay attention to the "rel" attribute in that example.) This would
"say" that the author of that blog post --
http://example.com/log/1234.html -- is http://example.com/. Now let's
look at http://example.com/. This could contain the following link:
<a rev="author" href="http://example.com/log/1234.html">...</a>
(Pay attention to the "rev" attribute in that example.) This would
"say" that http://example.com/ is the author of what's pointed to by
the "href" attribute -- http://example.com/log/1234.html.
The important thing here is that we reused the same (semantic) token
-- author -- in both cases. (Once in the "rel" attribute and the
other in the "rev" attribute.) IMO, doing this semantics token reuse
is a boon and increases developer usability.
For purposes of (semantic) token reuse, it would be nice if there was
something like an "hrefclass" attribute. For example, let's say we
Now, lets say that instead of including this in our document, that we
wanted to defer this to somewhere else. Then having something like
the following would be very useful.
<a hrefclass="shows" href="http://example.com/shows">...</a>
Now, it's true that with the "class" attribute by itself we could do
<a class="href-shows" href="http://example.com/contact"></a>
<a class="refersto-shows" href="http://example.com/contact"></a>
But we don't have semantics token reuse in these cases.
With semantics token reuse one could imagine something like "generic"
parsers and web crawlers finding information when the things are
spread out across multiple documents. Since the same "semantic token"
is used in each case. All they'd need to do is "connect" things with
the same name. (Without having to know anything about the "meaning"
of the semantic tokens.) (Not to mention that it makes for better
Is there anything like this in the works?
Charles Iliya Krempeaux, B.Sc.
charles @ reptile.ca
supercanadian @ gmail.com
developer weblog: http://ChangeLog.ca/
Never forget where you came from
More information about the whatwg