Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CSS font-weight numbers: how do they work?

Tags:

html

css

fonts

I'm trying to use font-weight to adjust how bold the font is. From what I understand, value 500 is the normal font weight, and value 700 is the default font weight for bold.

However, when I put 599, it did not change the font-weight at all. But when I put 600, it jump to the default font weight of bold. Same results from value 600-900. Then when you go over 900, the font weight reverts back to the normal font weight. Why is this happening?

#fontStyle {
    border: 1px solid black;
    font-weight: 599;
}
<div id="fontStyle"> fontStyle </div>
like image 851
frosty Avatar asked Feb 18 '16 02:02

frosty


People also ask

How do font weights work?

What is Font Weight? Font weight is the “value” placed on your font that will determine how bold or light your text will appear. There are many “values” that you can use that provide a great deal of flexibility towards creating the font weight that works best for how you want to display your text.

What does font weight do in CSS?

The font-weight CSS descriptor allows authors to specify font weights for the fonts specified in the @font-face rule. The font-weight property can separately be used to set how thick or thin characters in text should be displayed.

What is font weight 300?

normal (weight=lighter) - bold. Font weight progression: 100 (extra light) - 200 - 300 - 400 (normal) - 500 - 600 - 700 (bold) - 800 - 900 (extra bold)


2 Answers

The details of how numeric values are mapped to font weights are covered in the spec which states:

The values '100' to '900' form an ordered sequence, where each number indicates a weight that is at least as dark as its predecessor. The keyword 'normal' is synonymous with '400', and 'bold' is synonymous with '700'. Keywords other than 'normal' and 'bold' have been shown to be often confused with font names and a numerical scale was therefore chosen for the 9-value list.

'599' is not a valid value for the font-weight property

like image 161
jandersen Avatar answered Sep 20 '22 04:09

jandersen


Default font weight is 400, and fonts work in multiples of 100. 300 is light (if your font supports it), 400 is regular, 600 is semibold and 700 is bold. You can't use the numbers in between.

like image 36
yts Avatar answered Sep 18 '22 04:09

yts