Why Isn’t There a lh in (X)HTML?

Something bugs me just about every time I mark up a list in (X)HTML.

There’s no list-head (<lh>) element.

Let’s say I’m marking up a list of my top three Last.fm artists. It would look something like:

<ol>
  <li>Teenage Fanclub</li>
  <li>Mogwai</li>
  <li>Yo La Tengo</li>
</ol>

Which, of course, would then render like:

  1. Teenage Fanclub
  2. Mogwai
  3. Yo La Tengo

But what if I wanted to label that list something like “My Top 3 Artists on Last.fm”. What are my options? I could throw it in a paragraph (<p>) tag. But a random paragraph doesn’t really semantically relate it to the list. I could put it in a header tag (<h1>, <h2>, etc.). That would at least tell me it is a header to something and not just an arbitrary paragraph. But still, that header isn’t associated with the list itself in any meaningful way (beyond proximity).

If I marked this up in a table, I have the option to add a table header (<th>). Tables are for tabular data, so for this example, I’ll show what the markup would look like if I wanted to make a table of my top three artists with the number of times I played them.

<table>
  <tr>
    <th>My Top 3 Artists on Last.fm</th>
    <th>Play Count</th>
  </tr>
  <tr>
    <td>Teenage Fanclub</td>
    <td>855</td>
  </tr>
  <tr>
    <td>Mogwai</td>
    <td>755</td>
  </tr>
  <tr>
    <td>Yo La Tengo</td>
    <td>705</td>
  </tr>
</table>

And that would render like this:

My Top 3 Artists on Last.fm Play Count
Teenage Fanclub 855
Mogwai 755
Yo La Tengo 705

Like the header tags and <strong> tag, most (if not all) user agents will show the <th> in bold. Also, since the <th> is a different element than the standard <td>, it is really easy to style headers differently from other table cells.

Best of all, though, the <th> is nested inside the <table>, meaning that it is explicitly a part of that table. Simply adding a <p> or <h3> above the <table> wouldn’t have the same semantic value.

Really all I’m wondering is… why don’t we have a <lh> to use when marking up ordered and unordered lists?

5 Comments

  1. On May 1st, 2008 at 1:45 pm Will said:

    A table has to have the heading information inside of the table due to the fact that there are meant to be multiple columns/rows and tying the heading to the content is vitally important. This complex relationship can be further seen when considering the scope attribute for th tags.

    Since a list has a single “column”, you don’t need to have the heading be part of the element since there isn’t a complex relationship to present.

    Beyond that, I don’t think the semantic nature of an h2 above a list would be lost. This is how headings and paragraphs work, and we don’t seem to have problem with that relationship.

    I think it really just comes down to the fact that tables are so complex that the tags need to be nested for them to work at all.

  2. On May 1st, 2008 at 1:55 pm Adam Darowski said:

    Good point about the headers to paragraphs correlation.

    I guess it just bugs me that it is something so explicitly attached to the list (whereas the <h2> can be interpreted as “this is the header for everything until you see another <h2>”). Kinda like how you have a <label> near an <input>, but you’re allowed to say <label> for="id-goes-here"... to explicitly associate them in the code.

  3. On May 1st, 2008 at 4:05 pm Noah Mittman said:

    Yeah, as Will pointed out, header tags work this way with following content as it is already, so this is exactly the way to go.

    In fact, I think this is exactly the reason why DIV and SPAN were added — for their general grouping concept?

  4. On May 1st, 2008 at 6:51 pm Adam Darowski said:

    Mmm… I guess you could argue that the header is actually a header for ALL of the content in the DIV then and not the LIST on it’s own. As Will pointed out the table headers are to describe the individual columns of the table. I’m kind of thinking of a list as a one-column table. Sure that’s not a “complex relationship”, but it is a relationship, nonetheless.

    Though at this point I think I’m making my own head hurt. :)

  5. On May 4th, 2008 at 9:03 pm Natalie Jost said:

    That’s an interesting question and something I hadn’t thought about before. And I was just about to say “would it be non-semantic to make an actual single-column table” but then you sort of made that point in your last comment. :)