This is an archived snapshot of W3C's public bugzilla bug tracker, decommissioned in April 2019. Please see the home page for more details.

Bug 11812 - The align attribute on the td and th elements should be conforming
Summary: The align attribute on the td and th elements should be conforming
Status: RESOLVED WONTFIX
Alias: None
Product: HTML WG
Classification: Unclassified
Component: LC1 HTML5 spec (show other bugs)
Version: unspecified
Hardware: All All
: P2 normal
Target Milestone: ---
Assignee: Ian 'Hixie' Hickson
QA Contact: HTML WG Bugzilla archive list
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-01-19 15:42 UTC by Henri Sivonen
Modified: 2011-08-17 05:26 UTC (History)
7 users (show)

See Also:


Attachments

Description Henri Sivonen 2011-01-19 15:42:29 UTC
Please make the align attribute on the td and th elements conforming.
 * It is an interoperably-implemented existing feature.
 * Alignment needs to vary on a per-cell basis depending on the contents of the cell.
 * Selecting cells by content using Selectors doesn't work yet. Even if it worked in the future, the solution wouldn't be compatible with browsers that authors need their content to be compatible with for the nearish future.
 * Working around the above problem by using the class attribute is a worse solution than the already-implemented align attribute, because the align attribute is more portable across authoring tools that offer cell alignment UI without having a full style system and ingest support for arbitrary CSS.
 * The main argument I've heard from Hixie against allowing this attribute is that it causes a slippery slope problem for non-presentationalism advocacy by introducing subtle points to a currently categorical advocacy message. I think advocacy concerns shouldn't override practical considerations for authors like me who use authoring tools that generate the align attribute.
Comment 1 Ian 'Hixie' Hickson 2011-02-16 09:10:01 UTC
Do you have an example of how this would be used?

Many if not all of the arguments presented above apply to a whole raft of legacy HTML features, like <font>, <big>, <tt>, <p align>, <center>, <marquee>, <hr color>, etc. Why is <td align> special?

I could see an argument for align="<string>" (as in, align="." or align="$"), but I don't really understand what's special about align=right or align=left on <td>.
Comment 2 Henri Sivonen 2011-03-18 14:34:14 UTC
(In reply to comment #1)
> Do you have an example of how this would be used?

<th align=left>Header for column whose data cells contain text</th>
<th align=center>Header for column whose data mostly consists of checkmarks, bullets or such</th>
<th align=right>Header for column whose data is mostly numbers (or that is the rightmost column in some designs)</th>
<td align=center></td>
<td align=right>42</td>
Comment 3 Henri Sivonen 2011-03-18 14:38:05 UTC
(In reply to comment #1)
> Many if not all of the arguments presented above apply to a whole raft of
> legacy HTML features, like <font>, <big>, <tt>, <p align>, <center>, <marquee>,
> <hr color>, etc. Why is <td align> special?

I find that I want to use align on table cells almost every time I publish a table on the Web. I haven't felt the need to use <font> or <hr color> for years. <marquee> never. I think <code> is just a synonym of <tt> in practice.

Even though I haven't used <center> for years myself, I seems to be alive and well. View source on http://canweshipyet.com/
Comment 4 Aryeh Gregor 2011-03-18 16:48:52 UTC
I agree that it's very common to want to align particular table cells differently, depending on their contents.  Cells that have something like a checkmark or X in them should be centered, for instance, and that comes up in lots of tables.  E.g., just in the last few days I've been working on <http://aryeh.name/spec/editcommands/autoimplementation.html>, and the last column should really be centered.

Customized alignment for some cells is desirable in possibly even a majority of tables.  For instance, when I looked at the first Wikipedia article I thought of ([[HTML5]]), I found two tables, and both had cells with their alignment overridden (using style, though, not align).

The major use-case is actually centering columns, though, not cells, so actually <col align> would be the most useful thing.  I don't know when you'd want to align individual cells and not a whole column, not counting when you want to make just the header different.

It's quite uncommon to want to change font color/size/face of a particular run of text, make marquees, make text large, align individual paragraphs, or make colored horizontal rules, other than in cases where there are semantic elements like <h#>.  So those are all different.

<tt> is a common need, but you can just use <code> instead, so it's not really needed.  <center> is also a special case because it can't actually be done in CSS -- e.g., I don't know of any way to do this in CSS, such that all children will be centered without you having to modify each child's style individually:

data:text/html,<!doctype html>
<center>
<div style=width:10em;height:2em;background:blue></div>
<div style=width:5em;height:2em;background:red></div>
</center>
Comment 5 Henri Sivonen 2011-03-21 08:09:52 UTC
(In reply to comment #2)
> <th align=right>Header for column whose data is mostly numbers (or that is the
> rightmost column in some designs)</th>

Note that :first-child and :last-child don't work as desired for choosing cells in the leftmost or the rightmost column when rowspan is involved.

(In reply to comment #4)
> I don't know when you'd
> want to align individual cells and not a whole column, not counting when you
> want to make just the header different.

Maybe. However, given existing tools that apply align to each cell (e.g. OpenOffice.org), it would be really annoying to ban align on td because use cases thought of so far suggest align on col and th only.
Comment 6 Ian 'Hixie' Hickson 2011-05-06 23:29:50 UTC
(In reply to comment #3)
> I find that I want to use align on table cells almost every time I publish a
> table on the Web. I haven't felt the need to use <font> or <hr color> for
> years.

Interesting. I wonder why the difference.

Personally, I just have some styles for common table types that I write, and they just kick in whenever I write a table so I don't have to worry about formatting each cell each time. It seems a bit odd to me that someone would do that.

Do you have any examples of tables you've written recently? It would be helpful to see what is different about the tables you're writing that make this more attractive to you.
Comment 7 Ian 'Hixie' Hickson 2011-05-08 22:51:59 UTC
(Anecdotal datapoint: I just added a table to a page I was writing. Aligning all the cells in their various ways took about 5 seconds and a couple of lines of CSS. In comparison, getting the borders right took many minutes and some rather hairy selectors. In this particular case, an align="" attribute on table cells wouldn't have been any help at all.)
Comment 8 Henri Sivonen 2011-05-09 09:28:57 UTC
(In reply to comment #6)
> (In reply to comment #3)
> > I find that I want to use align on table cells almost every time I publish a
> > table on the Web. I haven't felt the need to use <font> or <hr color> for
> > years.
> 
> Interesting. I wonder why the difference.

Using hr in the middle of an article isn't part of my writing style and the hr I have in my page template gets more complex styling than just color. I don't use <font>, because in my writing, I usually don't feel a need to apply a font based on the text but based on things that HTML has semantics for.

OTOH, I do feel the need to align stuff in tables contextually and not only based on a th/td distinction.
 
> Do you have any examples of tables you've written recently? It would be helpful
> to see what is different about the tables you're writing that make this more
> attractive to you.

http://hsivonen.iki.fi/html5-lecture/2011/slides.html#75
http://hsivonen.iki.fi/test/moz/meta-caching.html
http://hsivonen.iki.fi/about-blank/ (simply overrides the default th alignment due to authoring tool making this way more convenient)
Comment 9 Jukka K. Korpela 2011-05-20 04:45:32 UTC
The most obvious need for the align attribute is in numeric tables, which are tabular data par excellence. Columns containing integers should be right-aligned (align="right"), and columns containing real numbers should be aligned to the decimal separator (currently not possible in HTML or in CSS except with trickery, but the need is still there).

It is illogical to leave this entirely to CSS, since the need relates to the type of content, not just styling preferences. As we cannot use markup like, say, <col type="numeric">, please let us at least keep using <td align="right"> without feeling guilty.
Comment 10 brunoais 2011-06-25 07:35:27 UTC
I'm still wondering...
Is that difficult to write:
<td class="someClass center">something</td>
or
<td class="center">something</td>
instead of:
<td class="someClass" align="center">something</td>
or
<td align="center">something</td>

?

If I were to choose... It seems like the 1st option wins with the less characters used for the same thing. The win is when you already need to use a class in that data, in the other way, it's about the same size (depends on the class name).
So, do we still need to keep align?
Comment 11 Jukka K. Korpela 2011-06-25 08:10:35 UTC
(In reply to comment #10)
> I'm still wondering...
> Is that difficult to write:
> <td class="someClass center">something</td>
> or
> <td class="center">something</td>

Ease of writing is not the issue. It is not difficult to write, say, <td class="symbol">.

It might be an issue to people using authoring tools that let them center cells in a column with a single click so that the tool generates align="center" attributes and has no simple way of adding a class attribute in all cells of a column.

Any use of class attributes for something means that you give up every hope of achieving a particular result when style sheets are not used.

Would it be too practical to mention what happens when you copy and paste a table from an HTML document onto Word or Excel? Style sheets are lost, but align attributes get mapped to properties of cells.
Comment 12 Henri Sivonen 2011-06-27 08:21:13 UTC
(In reply to comment #10)
> I'm still wondering...
> Is that difficult to write:
> <td class="someClass center">something</td>

I'm authoring tables using LibreOffice Writer/Web. It (and many other authoring tools) can write and *read* align. Changing those tools to use a per-tool private class name doesn't seem like an improvement.
Comment 13 Michael[tm] Smith 2011-08-04 05:34:00 UTC
mass-move component to LC1
Comment 14 Ian 'Hixie' Hickson 2011-08-17 05:26:40 UTC
(In reply to comment #8)
> >
> > Do you have any examples of tables you've written recently? It would be helpful
> > to see what is different about the tables you're writing that make this more
> > attractive to you.
> 
> http://hsivonen.iki.fi/html5-lecture/2011/slides.html#75

tr { text-align: center; }
tr > :first-child { text-align: left; }
tr > :last-child { text-align: right; }

Note that there is nothing semantic about the alignment in this table. It's just presentational. The table could easily be styled differently without any loss of usability, just for stylistic reasons.


> http://hsivonen.iki.fi/test/moz/meta-caching.html

Given the default TD and TH styles, the entirety of the alignment of these tables can be described with a single line of CSS:

   tr > :first-child { text-align: right; }

Again, the alignment here is purely stylistic. In fact I would prefer a style that makes the first column left-aligned but the data cells centered.

You could also style this by using <thead> and <tbody> instead of just <tbody>; then the rule would just be:

   tbody th { text-align: right; }


> http://hsivonen.iki.fi/about-blank/ (simply overrides the default th alignment
> due to authoring tool making this way more convenient)

Again, no semantic need for any particular styling here, and everything can just be done using:

   td, th { text-align: left; }


In all three cases, consider what it would take to change the style with the current markup (with presentational attributes on every non-default cell) and what it would take if you had instead just used the trivial CSS presented above.

IMHO this shows quite convincingly exactly what I suspected: that CSS is the better solution here.

This is _especially_ true, IMHO, because there is, it seems, no difference between some of the other styles used (backgrounds, borders, border radii, fonts, colors, padding) and alignment. They can all be trivially described in terms of CSS. In fact, in one case (the slides example above) you even have a style rule that is triggered based on the align attribute!


EDITOR'S RESPONSE: This is an Editor's Response to your comment. If you are satisfied with this response, please change the state of this bug to CLOSED. If you have additional information and would like the editor to reconsider, please reopen this bug. If you would like to escalate the issue to the full HTML Working Group, please add the TrackerRequest keyword to this bug, and suggest title and text for the tracker issue; or you may create a tracker issue yourself, if you are able to do so. For more details, see this document:
   http://dev.w3.org/html5/decision-policy/decision-policy.html

Status: Rejected
Change Description: no spec change
Rationale: Using CSS for this has all the advantages that using CSS has in other cases  easier maintenance, smaller file sizes, easier to restyle, more control  and has no additional disadvantages. It doesn't even require new skills, since CSS is already used for styling these tables and since the additional rules are trivial in complexity.