Arrangement of font shorthand in css

97 Views Asked by At

Why should the shorthand for font property be in this sequence?

font: font-style font-weight font-size font-family

Why should the style and weight come before the size?

1

There are 1 best solutions below

0
jeffjenx On

The answer might not be what you're looking for, but it is an answer nonetheless.

The reason why is because that is how the specification defines the font property.

Value:      [ [ <'font-style'> || <'font-variant'> || <'font-weight'> ]? <'font-size'> [ / <'line-height'> ]? <'font-family'> ] | caption | icon | menu | message-box | small-caption | status-bar | inherit

The specification states that font-style, font-variant, and font-weight must come before font-size.

The specification further states:

The syntax of this property is based on a traditional typographical shorthand notation to set multiple properties related to fonts.

So, while many short-hand properties typically only require a specific order when the values are of a similar type, the font shorthand is defined in a specific order because they wanted to keep consistency with how other applications and software had defined font properties.