Do the simplest thing that could possibly work

I snuck a little experiment into yesterday's posting. It contains a paragraph that's coded like so:

<p class="tip">
Here's a tip, by the way. When you're hacking around with your 
Radio feeds, turn upstreaming off. Otherwise you'll torment your 
subscribers. 
</p>

To the writer and to the reader, this "tip" thingy is a stylistic element. As such, it can acquire a distinctive appearance by way of a CSS binding:

 p.tip 
  {
  margin-left: 50px;
  margin-right: 50px;
  font-size: 80%;
  }
 p.tip:before
  {
  font-weight: bold;
  content: "TIP: ";
  }

Of course, CSS implementations being what they still are, this yields differing results:

Safari / Mac OS X

Mozilla / Mac OS X

MSIE 6 / Windows

I'd hoped to do something a bit more visual, by the way:

 p.tip:before
  {
  font-size: 250%;
  float: left;
  margin-right: 10;
  content: "☛";
  }

But although I can see the Unicode x261B (☛ BLACK RIGHT POINTING INDEX) on my Mac, it doesn't seem to render on Windows. (See Alan Wood's Unicode pages if you want to check out what your browser can display.) And even on the Mac, under Safari, Mozilla, and MSIE, the character doesn't seem to cooperate with the CSS :before pseudo-element.

Oh well. The point, in any case, is that I can associate a CSS style with this tip thingy. The label, the font change, and the wide margins conspire to set the element apart from the main flow of the text. As a writer I convey, and as a reader you intuitively understand, that it is a categorized chunk of content. This is immediately and narrowly useful.

It is also useful over a longer term, in a broader context. Assume that you've gathered a bunch of RSS feeds carrying xhtml:body elements, or that an aggregator has done so for you. The same class="tip" that CSS uses to style the element can be used to form queries like the ones I demonstrated in my Semantic Blog article. In this case, such queries might ask:

Which of the feeds contains tips?

Which of the items in Jon's feed contains tips?

Which items contain tips about Radio upstreaming?

This approach doesn't rely on anything fancy. Just CSS, RSS, XHTML, XPath. Why, I've been asked a few times lately, am I not advocating RDF? As the extreme programming folks like to say: Do the simplest thing that could possibly work.


Former URL: http://weblog.infoworld.com/udell/2003/04/18.html#a671