Most of a web page is text, so a handful of text properties do a lot of the work.
| Property | What it does | Example |
|---|---|---|
font-family | The typeface | font-family: Georgia, serif; |
font-size | How big the text is | font-size: 20px; |
font-weight | How bold | font-weight: bold; |
text-align | Left, center or right | text-align: center; |
line-height | Space between lines | line-height: 1.6; |
Font families
A visitor only sees a font if it is on their device, so font-family takes a list. The browser uses the first one it has:
body {
font-family: Arial, Helvetica, sans-serif;
}
Always end the list with a general family: serif (letters with small feet, like in books), sans-serif (plain letters) or monospace (every letter the same width, like code).
Inheritance
Notice that rule is on body. Text properties are inherited: elements inside the body use the same font unless a rule says otherwise. Setting the font once on body styles the whole page.
Line height
A line-height of about 1.5 to 1.7 makes paragraphs much easier to read. The number is a multiple of the font size and has no unit.
Your Task
- Give the
bodyafont-familylist that ends insans-serif. - Center the
<h1>withtext-align. - Make the paragraph text
18pxwith aline-heightof1.6.
- The
bodyrule sets afont-familythat ends insans-serif - The paragraph uses the same font as the body
- The heading is centered
- The paragraph text is
18pxwith a line height of1.6
Lesson complete!
Next Lesson: Colors and Backgrounds