mark nottingham

Ubiquitious Fragment Identifiers

Sunday, 30 May 2004

Tim Bray is trying out “purple number signs” on his Web site to make fragment identifiers ubiquitous and easy to find.

This site has something along similar lines, through this CSS:

[id]:hover:after {
  content: " #" attr(id) " ";
  font-size: 50%;
  color: #ccc;
  text-decoration: none;

which means that everything with an id attribute gets its anchor advertised when you mouse over it; try the front page and the RSS tutorial for examples.

I prefer this to the “purple” approach, for two reasons. First, there’s less line noise when you’re browsing a page, while still making it easy to find anchors.

Second, and perhaps more importantly, I prefer to be a little more parsimonious with my anchors. Advertising them is a commitment on the part of the publisher to keep them meaningful and stable; in other words, to be cool URIs. While I have a reasonable hope of keeping heading-level anchors stable, I’m less confident that the meaning of every paragraph I write won’t change over time, sometimes very quickly.

In other words, anchors that aren’t linked to the semantics of a document can lead to brittleness and loss of utility, as discussed before. This isn’t to say that “purple”-style anchors are bad, but it does mean there should be a commitment to avoid changing the text in ways that invalidates them. It’s a pretty high bar for “living” documents, like Weblog entries.

At any rate, it’s great to see support for fragment identifiers getting more attention; I note that the new PDF media type registration documents a useful fragID syntax. Now if only Word did that…


Moose said:

This has been done in the past:


Sunday, May 30 2004 at 10:55 AM

Ben Tremblay said:


fyi: the “PDF Media type” has moved; the whole site has been re-jigged:


Thursday, October 12 2006 at 10:38 AM