There is no markup for units of measurements in HTML, or for numbers, so if you need some markup for them (e.g., in order to style them uniformly or to process them with a client-side script), use a span
element with a class
attribute for numbers or units or both, e.g.
<td><span class=number>3.8</span> <span class=unit>g</span></td>
(Note that by international standards, number and unit shall be separated by a space, which can be a nonbreaking space,
, if needed).
Normally, no markup is needed for units. Or, rather, there is no markup we could use for a useful purpose, and writing span
markup just for the fun of it makes the HTML code less readable.
In some interpretations, however, symbols of units are abbreviations, so abbr
markup could be used. Note that this by default causes a dotted line under (bottom border) in most browsers, a mostly irritating feature; to remove it, set abbr { border: none }
in CSS. By essence, symbols of units are conventional notations rather than abbreviations.
Using a title
attribute, on span
, abbr
, or other element, makes some assistive software show the attribute value when requested by the user. It also tends to make it shown in a tooltip in common browsers. It is questionable whether such “hints” are useful rather than just disturbing for commonly known symbols.
Using em
would mean emphasis in principle, which is hardly appropriated, and would cause italic to be used in practice. By international standards, symbols of units shall never be italicized. Although you can use CSS to remove italic, it would be odd to use markup that tends to cause it.