Question

I am referring to the usage a table for showing tabular data, eg: a spreadsheet, focusing on numbers, that I feel and see in UX that should be right aligned, properly formatted (with same number of decimals) to facilitate sums. For numbers this looks like a borderline case between semantics and formatting, for other kind of data types like dates choosing an alignment is more arbitrary.

I of course agree in using css when possible but css is not always supported or enabled and I see reasons to use align='right' since it gives decent default for when there is no support for css. This happens for example in my version of Lynx or when a browser user disables css to print.

Speculation: perhaps a more semantic attribute like <td number='true'> could do the work also if seen how problematic are

 <input type='number'> 

in HTML5 in respect to localization I would just expect from it to align on right.

I remember also at some point in time was difficult to override align attribute with css (and I remember css designers asking me to remove it from HTML) but this seems not true (anymore?) now

Am I missing something ? I am personally generating align='right' for numbers in my html.

My main question is: is there any reason except the fact that is deprecated to not use ALIGN='right' for properly formatted numbers on an HTML TD ?

Thanks.

Was it helpful?

Solution

You sound like you know what you are talking about, so I would say just use align=right. Of course just be aware of the disadvantages of this:

  • more dificult to maintain later. If you have multiple tables and change the alignment you will need to do this for every table
  • search engins may penalise sites that rely heavily on deprecated tags
  • browsers could remove support for deprecated tags in future. They will anounce this in advance though, so of you expect the site to revive ongoing maintainable you will have time to remedy this

OTHER TIPS

I don’t think that aligning changes the semantics in this example. Certainly, it’s good to align the numbers, but no meaning is changed/lost when they are not aligned. It’s just a little bit harder to read the content. But this is the case for other CSS properties, too.

I wouldn’t use the align attribute. It was obsoleted for a reason ("must not be used by authors", not "should not")

Instead, have a look at Unicode’s figure space (U+2007). If you can’t use this character directly, you could use the character references:

  • hexadecimal: &#x2007;
  • decimal: &#8199;

<table>
  <tr><td>100000.00</td></tr>
  <tr><td>&#8199;&#8199;&#8199;100.00</td></tr>
</table>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top