[webkit-dev] Your opinion on a CSS proposal

Windy Road tom at windyroad.org
Tue Jun 5 21:29:48 PDT 2007


On 06/06/07, David Hyatt <hyatt at apple.com> wrote:
> I don't quite understand the proposal.  width can be defined in terms
> of font-size.... therefore it's impossible to define font-size in
> terms of width.  For example, width:50em, font-size:auto would be
> undefined, since each would depend on the other.

Take a block element who's width is auto, generally speaking it's
width will be determined by the parent, the parent's padding and the
element's margins.  A block element with a font relative width and a
font-size of auto would have it's width calculated in the same way as
the block element with a width of auto.  Once the width is calculated,
the font-size (in px) is determined by the following formula:

    font-size = calculated_width_in_px / font_relative_width

For example, just say we have a block element with a width of 50em,
the font-size is auto and the browser calculates it's width as 1024px.
 In this case the calculated font-size would be

   font-size = 1024 / 50 = 20.48

If the browser calculates it's width as 640px, then

  font-size = 640 / 50 = 12.8

Cheers,

-- 
Tom Howard
http://windyroad.org



More information about the webkit-dev mailing list