Day 2 - CSS Typography
Typography properties allow you to control the look and feel of text explicitly.
1. Font Family
Specifies the font for an element. Always provide fallback fonts.
- Serif: Fonts with small lines at the ends (e.g., Times New Roman).
- Sans-serif: Fonts without lines (e.g., Arial). Clean and modern.
- Monospace: All characters have the same width (e.g., Courier). Used for code.
Code:
Output:
This is a Serif font.
This is a Sans-serif font.
This is a Monospace font.
2. Font Size
Sets the size of the text. Common units are px (pixels)
and rem (relative to root).
Code:
Output:
Small Text (12px)
Medium Text (16px)
Extra Large Text (32px)
3. Font Weight
Controls the boldness of the text.
Code:
Output:
Light Weight (300)
Normal Weight (400)
Bold Weight (700)
Bolder Weight (900)
4. Text Decoration
Used to add or remove decorations like underlines. Often used to remove underlines from links.
Code:
Output:
5. Text Transform
Controls capitalization.
Code:
Output:
uppercase text
LOWERCASE TEXT
capitalize this text
6. Text Alignment
Controls the horizontal alignment of text.
Code:
Output:
Centered Text
Right Aligned Text
7. Line Height
Controls the space between lines of text.
Code:
Output:
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed do eiusmod tempor incididunt ut labore.
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed do eiusmod tempor incididunt ut labore.
8. Letter Spacing
Controls the space between characters.
Code:
Output:
WIDE SPACING
COMPRESSED SPACING