tags:

views:

149

answers:

1

I noticed that some stylesheets have something like this:

body { font-size: 62.5%/1.2em; }

I got a warning "unexpected token /" when I wrote this in NetBeans. And if I changed the EM value, say,

body { font-size: 62.5%/1em; }

the computed font-size remained 16px.

My question is, Is it standard compliant to write something like that? And how to computed the actual font-size?

+5  A: 

In CSS2, the font-size property does not allow a value of the form x/y.

What you're using is the font short hand property, which allows x/y as a short-hand of font-size: x; line-height: y;. So either use

body { font: 62.5%/1.2em sans-serif; }
/*                       ^^^^^^^^^^ the font-family is needed. */

or

body {
  font-size: 62.5%;
  line-height: 1.2em;
}
KennyTM
But why not body { font: 62.5% 1.2em sans-serif; } instead of body { font: 62.5%/1.2em sans-serif; }? And seems that in body, 100% = 1em = 16px, right? Because by writing font-size: 62.5% I got computed font-size is 10px. Thx alot!
powerboy
@powerboy: Yes. And whether `1em == 16px` depends on the browser.
KennyTM
@powerboy: *why not body { font: 62.5% 1.2em sans-serif; }* — Historical issue. "The syntax of this property is based on a traditional typographical shorthand notation to set multiple properties related to fonts."
KennyTM