Re: [CSS3-Values] Get Width of Styled Text

On Wednesday 31 March 2010 03:12:23 John Daggett wrote:

> I think it's really, really hard to make something like this work
> properly, since the width of text is affected by both a large set of
> style properties *and* the actual content of the text itself.

> ----- Original Message -----
> From: "Christoph Päper" <christoph.paeper@crissov.de>
> To: "W3C Emailing list for WWW Style" <www-style@w3.org>
> Sent: Wednesday, March 31, 2010 7:06:54 AM
> Subject: [CSS3-Values] Get Width of Styled Text
>
> Some basic Latex package provides the command \widthof{} which
> returns the width of its argument using the local font properties
> etc. Could we get something similar into CSS?
>
> There are several ways to specify this:
[...]
>  A   width: "String";
[...]

They are not the same as what you describe, but the following two 
proposed features may solve some of the same use cases:

There is proposal to extend the 'width' and 'height' properties with 
keywords 'available', 'max-content', 'min-content' and 'fit-content'. 
The 'max-content' in particular is close to what you suggest, 
because 'width: max-content' makes the element just wide enough that it 
doesn't cause any line breaks in its contents. (The actual definition 
is complex, because it has to deal with child elements, stretchable 
white space, etc., but you get the idea.)[1]

Another use case, I think, is when you want to set the width of a column 
of boxes to the width of one of them (the widest, usually). If those 
boxes form a column of a table, you can get that effect, but in general 
you cannot align arbitrary boxes. But the proposed Template Layout[2] 
may do the trick, because it allows elements to be aligned in a column, 
just as in a table, without requiring table-like mark-up.

[1] (No published draft, because we haven't actually succeeded in 
defining the keywords yet...)
[2] http://www.w3.org/TR/css3-layout/



Bert
-- 
  Bert Bos                                ( W 3 C ) http://www.w3.org/
  http://www.w3.org/people/bos                               W3C/ERCIM
  bert@w3.org                             2004 Rt des Lucioles / BP 93
  +33 (0)4 92 38 76 92            06902 Sophia Antipolis Cedex, France

Received on Thursday, 29 April 2010 13:38:14 UTC