Text Styling
๐ Covered in this chapter:
font-size ยท line-height ยท letter-spacing ยท word-spacing ยท text-align ยท text-decoration ยท text-transform ยท text-indent ยท text-shadow ยท white-space ยท text-overflow ยท ellipsis ยท Readability ยท Typography Scale
Welcome to Chapter 17: Text Styling โ part of the CSS Complete Roadmap. This lesson covers all subtopics with clear explanations, code examples, and best practices used in professional web development.
1Font Size, Line Height & Spacing
CSS โ Readable Textโถ Try in Editor
.description {
max-width: 65ch;
line-height: 1.6;
color: #4b5563;
font-size: 1rem;
letter-spacing: 0.01em;
word-spacing: normal;
}
Readability: Body text line-height: 1.5โ1.7, max width 65ch, sufficient contrast.
2Text Alignment, Decoration & Transform
CSS
h1 { text-align: center; text-transform: capitalize; }
a { text-decoration: none; }
a:hover { text-decoration: underline; }
.label { text-transform: uppercase; letter-spacing: 0.05em; }
.quote { text-indent: 2rem; }
3Text Shadow, White Space & Ellipsis
CSS
.hero-title {
text-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}
.truncate {
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
.preserve {
white-space: pre-wrap;
}
4Typography Scale
CSS โ Type Scale
:root {
--text-xs: 0.75rem;
--text-sm: 0.875rem;
--text-base: 1rem;
--text-lg: 1.125rem;
--text-xl: 1.25rem;
--text-2xl: 1.5rem;
--text-3xl: 1.875rem;
--text-4xl: 2.25rem;
}
Consistent modular scale โ design system lo headings and body harmonious ga untayi.