What does the forward slash mean in the CSS font shorthand?

CssFonts

Css Problem Overview


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

font: 12px/18px ...

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

Css Solutions


Solution 1 - Css

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)

Solution 2 - Css

It's equivalent to:

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

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionBenView Question on Stackoverflow
Solution 1 - CssBoltClockView Answer on Stackoverflow
Solution 2 - CsspokeView Answer on Stackoverflow