Information about cookies on this page

Our website uses cookies to ensure the functionality of the website, to collect and analyze information about the performance and usage of the website. Privacy Policy

  • Courses
    • Discord
    • Twitter
    • Linkedin
    • Facebook
    • Instagram
  • Pricing
  • English
  • Čeština
  • Deutsch
  • Русский
Sign inStart free
  • Courses
  • Pricing

Community

Sign in
  
  • Courses
    • Discord
    • Twitter
    • Linkedin
    • Facebook
    • Instagram
  • Pricing
  • English
  • Čeština
  • Deutsch
  • Русский
Sign inStart free
  • Courses
  • Pricing

Community

Sign in

Font Size

The font-size property sets the size of the text. You already know pixels:

h1 {
	font-size: 40px;
}

For text, however, we usually use another unit: rem. 1rem is the browser's base font size, normally 16 pixels. So 2rem is 32 pixels and 0.5rem is 8 pixels (decimal numbers with a dot, as always in CSS).

Why not just pixels? People who don't see well often set a larger base font size in their browser settings. Sizes in rem grow with it, so the whole page stays readable and keeps its proportions. Sizes in pixels stay the same, whatever the visitor has set.

Ordinary text is 16 pixels (1rem) by default, and browsers make headings bigger: an h1 heading is 32 pixels and an h2 heading 24 pixels.

Instructions

  1. 1

    In the rule for #title, add font-size: 3rem (48 pixels).

  2. 2

    In the rule for h2, add font-size: 1.75rem (28 pixels).

Back

3/8

  1. 1. Font Family
  2. 2. Font Weight and Italics
  3. 3. Font Size
  4. 4. Line Height
  5. 5. Text Alignment
  6. 6. Uppercase and Letter Spacing
  7. 7. Web Fonts
  8. 8. Summary
Next

Try it yourself

Do this exercise right here in your browser. No account needed.