The font shorthand resets omitted longhands
font-style: italic;
font-weight: 700;
font: 1rem/1.4 serif;A later font shorthand that sets only size, line-height, and family resets style and weight to normal.
- The example uses generic families only. No font file is requested.
<p class="lead">Italic bold lead, then a shorthand.</p>
<p class="lead short">The shorthand resets style and weight.</p>
<style>
.lead {
font-style: italic;
font-weight: 700;
font-size: 1.25rem;
line-height: 1.5;
font-family: sans-serif;
}
.lead.short { font: 1rem/1.4 serif; }
</style>What this markup means
The first paragraph keeps italic, weight 700, 1.25rem, and a unitless 1.5 line-height. The second paragraph also has those longhands, but font: 1rem/1.4 serif then sets size, line-height, and family and resets font-style and font-weight to their initial normal values. The rule is valid because it includes both a size and a family.
Related: Text, CSS tutorial: selectors