1

The CSS property font-size can define its "length" in pixels.

What does it describe exactly, is it the width (or the height) of a nominal character (eg, 'm'), is it some attribute in the font file description, is it something else?

I have been unable to locate this piece of information: what I have found, in some accepted answers (in stackoverflow), statements being the height of capital 'H' otherss of capital 'I' and lower 'p' plus some amount.

I would appreciate a link to an actual specification. BTW, http://www.w3.org/TR/CSS2/fonts.html#font-size-props seems to be silent on this aspect.

I am interested in that to know how this metrics relate to monospace typeface's character width.

Infinite Recursion
  • 6,511
  • 28
  • 39
  • 51
user1938578
  • 393
  • 5
  • 20
  • Didn't understood a bit – Mr. Alien Dec 27 '13 at 10:48
  • 1
    You should cite the accepted answers that you mention, so that they can be located and the answers corrected, or at least the errors pointed out. Any statement that says that the font size equals the height of some particular basic Latin letter is certainly false. – Jukka K. Korpela Dec 27 '13 at 11:37
  • @jukka-k-korpela One accepted answer that seems to say that is [link](http://stackoverflow.com/questions/10353761/when-setting-css-font-size-in-pixels-does-the-value-refer-to-the-width-or-heigh?rq=1). If what Quentin says below about an "EM box" is accurate, it seems the question was not well understood. – user1938578 Dec 30 '13 at 00:54

2 Answers2

2

The CSS 3 specification is clearer:

This property indicates the desired height of glyphs from the font. For scalable fonts, the font-size is a scale factor applied to the EM unit of the font. (Note that certain glyphs may bleed outside their EM box.) For non-scalable fonts, the font-size is converted into absolute units and matched against the declared font-size of the font, using the same absolute coordinate space for both of the matched values.

You asked:

what I have found, in some accepted answers (in stackoverflow), statements being the height of capital 'H' otherss of capital 'I' and lower 'p' plus some amount.

It depends on the font. The CSS can only describe the desired height of the em box, but the font author can draw the glyphs anywhere they like inside or outside it. See here for more details.

I am interested in that to know how this metrics relate to monospace typeface's character width.

Only indirectly. Different monospace fonts have different ratios between their height and width.

Quentin
  • 914,110
  • 126
  • 1,211
  • 1,335
  • Thanks for the answer and particularly the doc specs. I have tried to understand re business of "EM box". Am I understanding correctly: (1)what CSS specs and you callEM box is what the document on TrueType calls "EM square", (2) this can be programatically deduced from a grid in the FONT file, (3) browsers use the "imaginary" EM box as a reference for css size "length", thus when set in pixels the height of the box is the amount of pixels. – user1938578 Dec 30 '13 at 00:47
0

I guess something like that ? http://static.splashnology.com/articles/Choosing-the-Best-Units/font-units-large.png ?

Monospace fonts are particular : the width of a character is allways the same (that's why we call it mono-space).

enguerranws
  • 8,087
  • 8
  • 49
  • 97