Font size, weight and style
Definition and purpose
Font size sets the scale of text, weight requests its boldness, and style selects normal, italic or oblique faces. These are independent choices.
Size and emphasis
<!doctype html><html lang="en"> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <title>CSS practice</title> <style> html { font-size: 16px; } #a { font-size: 1.5rem; font-weight: 700; } #b { font-size: 1rem; font-style: italic; } </style> </head> <body> <div id="a">Sample A</div> <div id="b">Sample B</div> </body></html>A is 24px and bold; B requests italic at the root size.
Syntax and mental model
font-size: 1.25rem; font-weight: 600; font-style: italic; requests size, weight and style separately. Numeric weights range from 1 to 1000; available faces determine actual appearance. Rem follows the root font size.
Independent weight and style
<!doctype html><html lang="en"> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <title>CSS practice</title> <style> #a { font-weight: 400; font-style: italic; } #b { font-weight: 700; font-style: normal; } </style> </head> <body> <div id="a">Sample A</div> <div id="b">Sample B</div> </body></html>Italic is not the same as bold.
Common mistakes
Do not use bold for semantic headings instead of heading elements. A requested weight may map to an available nearby face; a computed value does not prove that face exists.
Practice and next steps
After trying the examples, complete the linked coding exercise and review questions. Predict the result before running your code. Prerequisite: Font families and fallback. Next lesson: Line height and spacing.
Check Your Understanding
Solidify your learning with the interactive assessment directly below this lesson.
Concept Quiz & Questions
Font size, weight and style — knowledge check
Five questions on font size, weight and style.
What does font-weight control?
At a 16px root, 1.5rem equals?
Which requests italic?
Does weight 650 guarantee an exact face?
Which provides semantic heading structure?