Re: [css3-text] better way to do forced last-line justification

(12/11/28 15:15), John Daggett wrote:
> The CSS3 Text spec includes a new 'text-align-last' property for
> controlling alignment on the last line of a paragraph for example. [1]
> There isn't an example in the spec, but I'm guessing the use case is
> something like this:
> 
>   p {
>     text-align: justify;
>     text-align-last: left;
>   }
> 
> This way if the last line contains just two words they aren't spread
> across the page.

This seems to be the default behavior for 'text-align' so it's not a use
case for 'text-align-last'.

A common request from Chinese developers is that we want to justify just
a line for the purpose of, say, presenting the labels of text inputs in
a nifty way, like:

  姓      名:________
  身份證字號:________
  出  生  地:________
  ...

and 'text-align-last: justify' is sort of the popular way to do it.
However, for browsers that don't have 'text-align-last' (Opera and
WebKit), you need to hack and append an invisible 'inline-block'
pseudo-element to make the label not in the last line.

> But using a new property for this seems like overkill, there seem to
> be lots of combinations that have no real use case.

Agreed, and I quite like the 'justify-all' keyword you just suggested, as

  text-align: justify-all

is two characters shorter than

  text-align-last: justify

. However, 'text-align-last' has been there for many years since IE 5.5
so I don't think it can ever be dropped. We could make it deprecated
though, but that 'justify-all' overrides 'text-align-last' should be
specified, like how 'start end' overrides 'text-align-last'.

(12/11/29 15:15), John Daggett wrote:
> The value covering mandatory breaks is interesting, I'm assuming that
> 'text-align-last' doesn't cover mandatory breaks.

No it doesn't. The spec has

  # This property describes how the last line of a block or a line
  # right before a forced line break is aligned.

and I remember testing this before.

> So I think we could either include values like 'justify-all' and
> 'justify-center-last' in the text-align property or fiddle with it
> within the 'text-justify' property.

I quite like this direction.

(12/11/29 15:15), John Daggett wrote:
> Or how about something like this?
>
>   line-justification: normal | all-lines | center-last
>
> where 'normal' means justify all but the last line, 'all-lines' means
> justify the last line too and 'center-last' means justify all lines
> but center the last line. I think that probably better covers the
> plausible use cases.

I find it confusing to have two property for controlling justification
behavior: 'text-justify' and 'line-justification'. I like 'text-align:
justify-center-last' better, or just 'justify center', like 'start end'.



Cheers,
Kenny
-- 
Web Specialist, Oupeng Browser, Beijing
Try Oupeng: http://www.oupeng.com/

Received on Thursday, 29 November 2012 13:41:29 UTC