tags:

views:

141

answers:

3

Is there a measuring unit in CSS (either planned or already in existence) for setting the padding and margins based on the width of the font being used?

I know that em is supposed to be the height of the upper-case M of the font the browser uses, which is really handy for adding a clean double-spacing. But I sometimes want the side-margins of inline lists to be the width of a normal non-breaking space, or the width of an upper-case A. With some fonts, using em is vary unreliable.

+1  A: 

I'm afraid no. CSS does not offer a way to reference fonts properties.

But you can always get away by inserting   in the extra first and last list elements.

Developer Art
+3  A: 

Funny, but it seems that nobody cares about width of typeface elements. Everything that's measured, is the height:

alt text

If this is the case in "classical typography", then there is even less hope in web typography which is a subclass of the former.

EDIT: Actually there is a measurement named En which refers to " width of a lowercase letter "n"." However, I haven't seen this used in web.

naivists
This is especially odd, I think, since typesetting spends a lot of time on the topic of leading, kerning, word-spacing, letter-spacing,etc, which all seem to deal with how letters are layed out vertically. You'd think at least one of these would have evolved a "distance of actual character-width".
Anthony
Well, the width of a lowercase letter "n" will be of limited usefulness, since the letters are of variable width (unless it is a monospace font).
awe
I see in the Wikipedia article you refer to that **en** is defined as half of 1 em, which means that you can use `0.5em` instead of `1en` (I don't think *en* is supported as unit in css). The article says that *it is also traditionally the width of a lowercase letter "n"*.
awe
+1  A: 

The W3C specifications for css3 defines a unit that is the width of the font's "0" character.

See css3-values, and chapter 3.4.2. Relative length units.

awe