Text Styling & Wrapping
Shape how text looks and flows, from underlines to perfectly balanced headlines.
What it is
Text styling in CSS goes beyond picking a font and a size. It covers how text is decorated (text-decoration), capitalized (text-transform), aligned (text-align), and how it wraps at the end of a line (text-wrap).
While older properties like text-align have been around forever, modern CSS has introduced powerful new tools like text-wrap: balance to give developers layout-engine-level control over typography.
Why it matters
Good typography shapes the reading experience. A headline that wraps awkwardly with one word on the second line looks unprofessional.
In the past, developers tried to fix wrapping issues by hardcoding <br> tags into HTML. But when the screen size changed on a mobile device, those hard breaks caused even worse layout issues. CSS wrapping properties solve this responsively.
How it works
You apply these properties directly to the text container.
text-transform: uppercase changes the casing visually, leaving the original HTML text intact (which is better for screen readers than typing in ALL CAPS).
text-decoration adds lines (underline, line-through) and can be styled with color and thickness.
The modern text-wrap property gives the browser hints on how to break lines: balance makes lines roughly equal in width (ideal for headlines), while pretty prevents a single word from sitting alone on the last line (ideal for paragraphs).
Try it
See how modern text wrapping and styling shape the reading experience.
Adjust container width
280pxSlide to see how text reflows, wraps, and truncates dynamically at different widths.
balanced headlines
text-wrap: balance
A Very Long Headline That Wraps Awkwardly
A Very Long Headline That Wraps Awkwardly
pretty paragraphs
text-wrap: pretty
This is a responsive text block demonstrating the wrapping behavior when a container gets too narrow.
This is a responsive text block demonstrating the wrapping behavior when a container gets too narrow.
text truncation
three-property ellipsis truncation
Check yourself
Pick an answer to lock it in, then read why. Getting one wrong is part of how it sticks.
Remember this
- Use
text-transformfor casing instead of typing in all caps. text-wrap: balancemakes headline lines equal in width.text-wrap: prettyprevents single-word orphans in paragraphs.- Never use
<br>tags just to make a headline look better on your specific screen size.
Done with this concept?
Mark it complete to track your progress. No login needed.