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

Line Height and Alignment

Each size class sets a line height, but you can choose another one with the leading- classes. The name comes from printing: typesetters used to put thin strips of lead between the lines of metal letters to space them out.

Classline-height
leading-none1
leading-tight1.25
leading-snug1.375
leading-normal1.5
leading-relaxed1.625
leading-loose2

The values are numbers without a unit, so they are multiples of the font size, just like the line-height: 1.6 you wrote in the CSS course. With text-lg (18 px) and leading-relaxed, each line is 18 × 1.625 = 29.25 pixels high. A leading- class always wins over the line height of a size class, so you can write them in any order.

Paragraphs of longer text are easier to read with more space between the lines, for example with leading-relaxed. For big headings, the line height that comes with the size is usually just right.

Text alignment works as in the CSS course: text-left, text-center, text-right and text-justify set text-align to left, center, right and justify. And since text-align is inherited, one class on the header element centers the name, the age and the badge in it.

Instructions

  1. 1

    Add the class leading-relaxed to both paragraphs below the header element: the one that describes Tiger and the one about adoption.

  2. 2

    Add the class text-center to the header element.

Back

9/12

  1. 1. The Color Palette
  2. 2. Shades
  3. 3. Quiz: Shades
  4. 4. Page Colors
  5. 5. Transparent Colors
  6. 6. Font Size
  7. 7. Font Weight
  8. 8. Quiz: Font Weight
  9. 9. Line Height and Alignment
  10. 10. Letter Spacing and Case
  11. 11. Font Family and Underline
  12. 12. Summary
Next

Try it yourself

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