โ๏ธ CSS COURSE โ MODULE 4: TYPOGRAPHY
๐ File: typography.md
โ๏ธ Typography in CSS
๐ Introduction
Typography is how text looks on a webpage.
CSS gives you full control over:
- font style
- size
- spacing
- alignment
๐ Good typography = professional UI ๐ Bad typography = messy website
๐ง 1. Font Family
Defines the type of font used.
p {
font-family: Arial, sans-serif;
}
โ Always include fallback fonts
๐ 2. Font Size
h1 {
font-size: 32px;
}
โ Controls text size
๐ชถ 3. Font Weight
p {
font-weight: bold;
}
Values:
- normal
- bold
- 100 โ 900
๐ 4. Line Height (VERY IMPORTANT)
p {
line-height: 1.5;
}
โ Improves readability โ Used in all professional websites
๐ 5. Letter Spacing
h1 {
letter-spacing: 2px;
}
โ Controls space between letters
๐งพ 6. Word Spacing
p {
word-spacing: 5px;
}
โ Controls space between words
๐ 7. Text Alignment
h1 {
text-align: center;
}
Values:
- left
- right
- center
- justify
๐ค 8. Text Transform
p {
text-transform: uppercase;
}
Values:
- uppercase
- lowercase
- capitalize
๐ฏ 9. Text Decoration
a {
text-decoration: none;
}
โ Removes underline from links
๐ง Important Concept
Good typography = combination of:
font-family + size + spacing + alignment
๐งฉ Real Example
<div class="box">
<h1>Welcome to CSS</h1>
<p>This is a typography example</p>
<a href="#">Learn more</a>
</div>
.box {
font-family: Arial, sans-serif;
}
h1 {
font-size: 36px;
text-align: center;
letter-spacing: 1px;
}
p {
font-size: 16px;
line-height: 1.6;
color: gray;
}
a {
text-decoration: none;
color: blue;
}
โ ๏ธ Common Mistakes
- Using too many fonts โ
- Ignoring line-height โ
- Using default browser spacing โ
- Not using fallback fonts โ
๐งช Mini Exercise
Create a page with:
- A centered heading
- A paragraph with good line height
- A styled link (no underline)
- Use a clean font family
- Add letter spacing to heading