W3C home > Mailing lists > Public > www-style@w3.org > November 2012

Re: [css3-text] character-based alignment ambiguously defined

From: Kang-Hao (Kenny) Lu <kanghaol@oupeng.com>
Date: Wed, 28 Nov 2012 21:46:28 +0800
Message-ID: <50B615B4.3060008@oupeng.com>
To: John Daggett <jdaggett@mozilla.com>
CC: www-style list <www-style@w3.org>
(12/11/28 14:50), John Daggett wrote:
> The current editor's draft of the CSS3 Text spec defines a way of
> specifying character-based alignment as an additional property value
> for text-align [1].  It doesn't seem clearly defined at an
> implementation level and I'm not sure I see a strong use case for it. 
> I would suggest this functionality be dropped in the interests of
> moving more important features forward.

I agree with the last statement. I don't quite agree that the spec is
too ambiguous besides the '"." center' case you mentioned.

> There are a number of things that aren't clear from this wording.  In
> the example above, is it the alignment character that's centered?  Or
> the minimum containing rectangle for all the lineboxes in the column?

The relevant part of the spec is this

  # For ‘center’, the UA may center the aligned contents using its
  # extremes, center the alignment axis itself (insofar as possible),
  # or optically center the aligned contents some other way (such as by
  # taking a weighted average of the extent of the cells' contents to
  # either side of the axis).

First of all, I don't like the "may" here, but I don't have a better
suggestion. Does "centering the aligned contents using it extremes" mean
that the containing rectangle is centered? Can this be clarified?

I failed to find a software that has this feature so I couldn't really
test this.

> The example in the spec shows neither of these.  

The weighing function can be very arbitrary so I guess any behavior
falls under that ;)

> Where is the alignment character placed when 'right' or 'left' values
> are used?

I think this is clear enough:

  # when the column is wide enough that the character alignment alone
  # does not determine the positions of its character-aligned contents.
  # In this case the keyword alignment of the first cell in the column
  # with a specified alignment character is used to slide the position
  # of the character-aligned contents to match the keyword alignment
  # insofar as possible without changing the width of the column.

where "character-aligned contents" = "containing rectangle", I suppose.
Relevant feedback: this prose is suffering from the same problem
'text-align' currently has[1]. In other words, it doesn't say what to do
when the column isn't wide enough for the containing rectangle.

> Would the two examples below render with the decimal place at the same
> point?
>   td { text-align: "." right; }
>   <table id="table1">
>   <col width="40">
>   <tr><td> $1.30</td></tr>
>   <tr><td> $85</td></tr>
>   <tr><td> $.05</td></tr>
>   <table>
>   <table id="table2">
>   <col width="40">
>   <tr><td> $85</td></tr>
>   <tr><td> $1.30</td></tr>
>   <tr><td> $.05</td></tr>
>   <table>


> The spec also includes:
>   A keyword value may be specified in conjunction with the
>   <string> value; if it is not given, it defaults to 'right'.
>   This value is used:
>   - when character-based alignment is applied to boxes that
>     are not table cells.
> So the effect of 'text-align: "." center;' on an element that isn't a
> table cell is what exactly?  Is it equivalent to 'text-align: center;'?

Yes, except that 'text-aling: "." center' is what's inherited, I think,
which matters if there's a descendant table cell.

> Is there a use case for left-aligned character alignment?

No idea.

> What happens in the example below?
>   td.a { text-align: "." left; }
>   td.b { text-align: "." right; }
>   <table>
>   <col width="40">
>   <tr><td class="a"> $1.30</td></tr>
>   <tr><td class="b"> $1.30</td></tr>
>   <tr><td class="a"> $85</td></tr>
>   <tr><td class="b"> $85</td></tr>
>   <tr><td class="a"> $.05</td></tr>
>   <tr><td class="b"> $.05</td></tr>
>   <table>

See the above quote. In particular, the "In this case the keyword
alignment of the first cell in the column with a specified alignment
character is used..." part.

> I don't know table algorithms well enough to comment authoritatively
> but it seems like this feature as specified is going to introduce some
> hairy column adjustment code into table implementations.  

I kind of agree, but without this this feature would seem to not be very

> I think the problem is that you're trying to set column-level attributes from
> within individual cells which is funky at best.

But not all tables have <col>s so I don't see an alternative.

Side question: would a 'table-layout: fixed' table subject to this
column width calculation? I suppose not but I am not so sure.

> Overall, I think this is a very awkward way of specifying decimal-alignment 

To be fair, I think this part of the spec has more implementation
details than the average in this module and there are relatively few
undefined cases (or at least those are marked as undefined).

> and it doesn't really seem to fit a natural use case; most numeric
> tables include the same number of decimal places throughout a table
> for consistency.  If there aren't other clear use cases, I suggest
> this be dropped or at least moved to CSS4 Text.

Having said above, I do agree that this feature doesn't seem to have
important use cases or need. I just got confirmed by some Web developers
about this. They just never heard of this need.

As data input, Excel and Open Office don't seem to offer this feature.
Open Office does have 'text-align: <string>' but it's in the text
processing mode and not in the spreadsheet mode (why?). Also, it
requires you to specify a vertical axis where all the "."s are aligned,
unlike the specced behvaior.

Feedback about the current prose:

  # when a character-aligned cell spans more than one column. In this
  # case the keyword alignment value is used to determine which
  # column’s axis to align with: the leftmost column for ‘left’, the
  # rightmost column for ‘right’ and ‘center’, the startmost column
  # for ‘start’, the endmost column for ‘end’.

This seems too smart and doesn't seem useful, but if you are doing this
I think you should let 'center' mean the floor(span / 2)-th cell from
the start side or something.

  # If width constraints on the cell contents prevent full alignment
  # throughout the column, the resulting alignment is undefined.

What case is this and why does this have to be undefined? Is there a
requirement that overflowing to the start side is not allowed, like
'text-align'? Otherwise I don't see why full alignment would ever fail
as long as you allow the text to overflow it's line box.

Web Specialist, Oupeng Browser, Beijing
Try Oupeng: http://www.oupeng.com/
Received on Wednesday, 28 November 2012 13:47:06 UTC

This archive was generated by hypermail 2.3.1 : Monday, 2 May 2016 14:39:06 UTC