I have a font with three weights: light, regular, bold. I would like to use light-weight for normal text and bold-weight for bold text.
Using font-weight: lighter
doesn’t work in this case because it forces bold text to regular-weight, thus breaking bold functionality.
What is the correct CSS to achieve this?
<html>
<style>
p {
font-weight: lighter;
}
</style>
<body>
<p>Light weight, <b>bold weight</b></p>
</body>
</html>
2
Answers
CSS:
You may also re-map your fonts to the desired default font-weights by custom
@font-face
rules:In the above example we map the actual Poppins light/300 to regular/400. You can extend this concept e.g to tweak the default weight for by default boldened elements like
<strong>
or headings like<h1-5>
(e.g when you find the default bold weight to thick or to thin).Besides, I recommend to avoid relative font-weights like
lighter
orbolder
as they are not very intuitive (See mdn docs: "Meaning of relative weights"). Related post "Bolding text is not working in different devices"