1

Is there a semantically correct way of showing a tooltip in a table header cell that explains something about the column's data?

My table looks like this:

---------------------
| URL   | Pageviews |
---------------------
| url/1 |  5 / 20   |
---------------------
| url/2 |  2 / 14   |
---------------------

I want the "Pageviews" text to have a tooltip that says "Week / Total" (explaining why the data looks like that).

Is abbr the right element for me to use? (it would look like this: <th><abbr title="Week / Total">Pageviews</abbr></th> I can't seem to find a better one. The definition says it's supposed to be used for abbreviations, which is not my case.

cambraca
  • 27,014
  • 16
  • 68
  • 99
  • Why not just use the title attribute on the th? – j08691 Mar 21 '14 at 14:55
  • @j08691 I'd like to style it later, maybe have it (the `abbr` element) show a question mark icon to the right (something like a `padding-right` and a `background` in CSS). – cambraca Mar 21 '14 at 14:58

1 Answers1

2

HTML5 allows you to use the "title" attribute on any element. http://dev.w3.org/html5/alt-techniques/ is a good summary of such techniques.

<th title="Week"> Pageviews </th>

I'd highly recommend adding a <caption/> under the table with such data for usability and UX purposes !

Jaibuu
  • 578
  • 3
  • 9