1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
|
---
title: font-weight
slug: Web/CSS/font-weight
translation_of: Web/CSS/font-weight
---
<div>{{CSSRef}}</div>
<p>The <strong><code>font-weight</code></strong> <a href="/uk/docs/CSS" title="CSS">CSS</a> property specifies the weight (or boldness) of the font. The font weights available to you will depend on the {{cssxref("font-family")}} you are using. Some fonts are only available in <code>normal</code> and <code>bold</code>.</p>
<div>{{EmbedInteractiveExample("pages/css/font-weight.html")}}</div>
<h2 id="Syntax">Syntax</h2>
<pre class="brush:css no-line-numbers">/* Keyword values */
font-weight: normal;
font-weight: bold;
/* Keyword values relative to the parent */
font-weight: lighter;
font-weight: bolder;
/* Numeric keyword values */
font-weight: 100;
font-weight: 200;
font-weight: 300;
font-weight: 400;
font-weight: 500;
font-weight: 600;
font-weight: 700;
font-weight: 800;
font-weight: 900;
/* Global values */
font-weight: inherit;
font-weight: initial;
font-weight: unset;
</pre>
<p>The <code>font-weight</code> property is specified using a single keyword value from the list below.</p>
<h3 id="Values">Values</h3>
<dl>
<dt><code>normal</code></dt>
<dd>Normal font weight. Same as <code>400</code>.</dd>
<dt><code>bold</code></dt>
<dd>Bold font weight. Same as <code>700</code>.</dd>
<dt><code>lighter</code></dt>
<dd>One font weight lighter than the parent element (among the available weights of the font).</dd>
<dt><code>bolder</code></dt>
<dd>One font weight heavier than the parent element (among the available weights of the font).</dd>
<dt><code>100</code>, <code>200</code>, <code>300</code>, <code>400</code>, <code>500</code>, <code>600</code>, <code>700</code>, <code>800</code>, <code>900</code></dt>
<dd>Numeric font weights for fonts that provide more than just <code>normal</code> and <code>bold</code>.</dd>
</dl>
<h3 id="Fallback_weights">Fallback weights</h3>
<p>If the exact weight given is unavailable, then the following heuristic is used to determine the weight actually rendered:</p>
<ul>
<li>If a weight greater than <code>500</code> is given, the closest available heavier weight is used (or, if there is none, the closest available lighter weight).</li>
<li>If a weight less than <code>400</code> is given, the closest available lighter weight is used (or, if there is none, the closest available heavier weight).</li>
<li>If a weight of exactly <code>400</code> is given, then <code>500</code> is used. If <code>500</code> is not available, then the heuristic for font weights less than 400 is used.</li>
<li>If a weight of exactly <code>500</code> is given, then <code>400</code> is used. If <code>400</code> is not available, then the heuristic for font weights less than 400 is used.</li>
</ul>
<p>This means that for fonts that provide only <code style="font-style: normal;">normal</code> and <code style="font-style: normal;">bold</code>, <code style="font-style: normal;">100</code>-<code>500</code> are <code>normal</code>, and <code style="font-style: normal;">600</code>-<code style="font-style: normal;">900</code> are <code>bold</code>.</p>
<h3 id="Meaning_of_relative_weights">Meaning of relative weights</h3>
<p>When <code>lighter</code> or <code>bolder</code> is specified, the following chart shows how the absolute font weight of the element is determined:</p>
<table class="standard-table">
<thead>
<tr>
<th>Inherited value</th>
<th><code>bolder</code></th>
<th><code>lighter</code></th>
</tr>
</thead>
<tbody>
<tr>
<th>100</th>
<td>400</td>
<td>100</td>
</tr>
<tr>
<th>200</th>
<td>400</td>
<td>100</td>
</tr>
<tr>
<th>300</th>
<td>400</td>
<td>100</td>
</tr>
<tr>
<th>400</th>
<td>700</td>
<td>100</td>
</tr>
<tr>
<th>500</th>
<td>700</td>
<td>100</td>
</tr>
<tr>
<th>600</th>
<td>900</td>
<td>400</td>
</tr>
<tr>
<th>700</th>
<td>900</td>
<td>400</td>
</tr>
<tr>
<th>800</th>
<td>900</td>
<td>700</td>
</tr>
<tr>
<th>900</th>
<td>900</td>
<td>700</td>
</tr>
</tbody>
</table>
<h3 id="Common_weight_name_mapping">Common weight name mapping</h3>
<p>The numerical values (<code>100</code> to <code>900</code>) roughly correspond to the following common weight names:</p>
<table class="standard-table">
<thead>
<tr>
<th scope="col">Value</th>
<th scope="col">Common weight name</th>
</tr>
</thead>
<tbody>
<tr>
<td>100</td>
<td>Thin (Hairline)</td>
</tr>
<tr>
<td>200</td>
<td>Extra Light (Ultra Light)</td>
</tr>
<tr>
<td>300</td>
<td>Light</td>
</tr>
<tr>
<td>400</td>
<td>Normal (Regular)</td>
</tr>
<tr>
<td>500</td>
<td>Medium</td>
</tr>
<tr>
<td>600</td>
<td>Semi Bold (Demi Bold)</td>
</tr>
<tr>
<td>700</td>
<td>Bold</td>
</tr>
<tr>
<td>800</td>
<td>Extra Bold (Ultra Bold)</td>
</tr>
<tr>
<td>900</td>
<td>Black (Heavy)</td>
</tr>
</tbody>
</table>
<h3 id="Interpolation">Interpolation</h3>
<p>A <code>font-weight</code> value is interpolated via discrete steps (multiples of 100). The interpolation happens in real number space and is converted to an integer by rounding to the nearest multiple of 100, with values halfway between multiples of 100 rounded towards positive infinity.</p>
<h3 id="Formal_syntax">Formal syntax</h3>
{{csssyntax}}
<h2 id="Examples" name="Examples">Examples</h2>
<h3 id="HTML">HTML</h3>
<pre class="brush: html"><p>
Alice was beginning to get very tired of sitting by her sister on the
bank, and of having nothing to do: once or twice she had peeped into the
book her sister was reading, but it had no pictures or conversations in
it, 'and what is the use of a book,' thought Alice 'without pictures or
conversations?'
</p>
<div>I'm heavy<br/>
<span>I'm lighter</span>
</div>
</pre>
<h3 id="CSS">CSS</h3>
<pre class="brush:css">/* Set paragraph text to be bold. */
p {
font-weight: bold;
}
/* Set div text to two steps heavier than
normal but less than a standard bold. */
div {
font-weight: 600;
}
/* Set span text to be one step lighter
than its parent. */
span {
font-weight: lighter;
}</pre>
<h3 id="Result">Result</h3>
<p>{{EmbedLiveSample("Examples","400","300")}}</p>
<h2 id="Specifications">Specifications</h2>
<table class="standard-table">
<thead>
<tr>
<th scope="col">Specification</th>
<th scope="col">Status</th>
<th scope="col">Comment</th>
</tr>
</thead>
<tbody>
<tr>
<td>{{SpecName('CSS3 Fonts', '#font-weight-prop', 'font-weight')}}</td>
<td>{{Spec2('CSS3 Fonts')}}</td>
<td>No change.</td>
</tr>
<tr>
<td>{{SpecName('CSS3 Transitions', '#animatable-css', 'font-weight')}}</td>
<td>{{Spec2('CSS3 Transitions')}}</td>
<td>Defines <code>font-weight</code> as animatable.</td>
</tr>
<tr>
<td>{{SpecName('CSS2.1', 'fonts.html#propdef-font-weight', 'font-weight')}}</td>
<td>{{Spec2('CSS2.1')}}</td>
<td>No change.</td>
</tr>
<tr>
<td>{{SpecName('CSS1', '#font-weight', 'font-weight')}}</td>
<td>{{Spec2('CSS1')}}</td>
<td>Initial definition.</td>
</tr>
</tbody>
</table>
<p>{{cssinfo}}</p>
<h2 id="Browser_compatibility">Browser compatibility</h2>
<p>{{Compat("css.properties.font-weight")}}</p>
|