What is the difference between font-weight: bolder;
and font-weight: bold;
styles?
I never met such style until today, when I found it in our project's CSS file. Result is the same visually (tested on Ubuntu 10.10, Firefox 3.6.15).
What is the difference between font-weight:bold and font-weight:bolder you might ask? The 'bolder' and 'lighter' values select font weights that are relative to the inherited (parent) font weight where as the 'bold' value simply change the font's weight to bold.
400 – Normal. 500 – Medium. 600 – Semi Bold (Demi Bold) 700 – Bold.
bold. Font weight progression: 100 (extra light) - 200 - 300 - 400 (normal) - 500 - 600 - 700 (bold) - 800 - 900.
To bold the text in HTML, use either the strong tag or the b (bold) tag. Browsers will bold the text inside both of these tags the same, but the strong tag indicates that the text is of particular importance or urgency. You can also bold text with the CSS font-weight property set to “bold.”
bolder
is a relative font weight:
The 'bolder' and 'lighter' values select font weights that are relative to the weight inherited from the parent
bolder
and lighter
are even part of the official spec. How they are interpreted and displayed is up to the browser.
The fact that they appear the same visually is because most browsers don't properly support font weight variations beyond bold
and normal
.
Here's a question with background info: Are all CSS font-weight property's values useful?
First we need to understand the difference between specified weight, computed weight and rendered weight.
For bold
, the specified weight is "bold", the computed weight is "700" and the rendered weight depends on the font, and the only guarantee is that it won't be lighter than elements with lower computed weights. (i.e. Since "normal" equates to "400", "bold" will never be rendered lighter than "normal" is (though it could be rendered identically.)
For bolder
, the specified weight is "bolder" and the computed weight is "400" if the container element has a computed weight of less than or equal to 300, otherwise "700" if the container element has a computed weight of less than or equal to 500, otherwise "900" The rendered weight again depends on the font with the same guarantee.
Since typefaces typically only natively support normal
and bold
weights, this often means that font-weight:bold
and font-weight:bolder
get rendered identically even if they have different computed weights.
But it doesn't have to be the case, even if the font only supports those two weights. In particular, if the container element has a computed weight less than "400", then "bolder" will compute to a weight of "400" and render the same as an element with a specified weight of "normal".
To illustrate this, see this JsFiddle: http://jsfiddle.net/UgAa5/ ¹
p { font-weight:300; font-size:2em } #scenario1 b { font-weight:bolder; } #scenario2 b { font-weight:bold; }
<p id="scenario1"> <span>plain</span> <b>bold?</b> </p> <p id="scenario2"> <span>plain</span> <b>bold?</b> </p>
¹ Current versions of IE, Firefox, Chrome and Opera all demonstrate this correctly. Older browsers, such as Safari 5.1 do not.
² The HTML5 spec says that the <b>
element should have a default font-weight of "bolder". Firefox and IE do that, but webkit/blink based browsers default to "bold", and normalize.css applies a font-weight:bold
setting to the <b>
element for all browsers.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With