190

I'm seeing the following CSS declaration in a stylesheet:

font: 12px/18px ...

What does the 12px/18px part mean exactly?

Wes
  • 3,978
  • 4
  • 24
  • 45
Ben
  • 60,438
  • 111
  • 314
  • 488
  • 2
    It was incorrect to close this as too localized. The question is simple, and so is the answer, but it is clearly something that people ask often, and has a good answer. – Jukka K. Korpela Nov 16 '12 at 14:22

2 Answers2

209

12px is the font size, 18px is the line height.

The syntax is based on typographical notation for specifying the respective sizes, and is only applicable to the font shorthand property. In other words, the above declaration simply expands to the following:

font-size: 12px;
line-height: 18px;

As always, if you set the line height to a relative value (e.g. percentage or ems), it's calculated relative to the font size.

W3C CSS2.1 font property reference
W3C CSS3 Fonts Module font property reference (the syntax carries over from CSS2.1)

keyser
  • 18,829
  • 16
  • 59
  • 101
BoltClock
  • 700,868
  • 160
  • 1,392
  • 1,356
66

It's equivalent to:

font-size: 12px;
line-height: 18px;
BoltClock
  • 700,868
  • 160
  • 1,392
  • 1,356
poke
  • 369,085
  • 72
  • 557
  • 602