CSS Typography · Astro Tech Blog

Typography

Beyond fonts, CSS offers many properties to control how text looks and reads.

Demo: Typography Properties
HTML
<p class="demo1">Line height and letter spacing</p>
<p class="demo2">Text align and transform</p>
<p class="demo3">Text decoration and shadow</p>
<p class="demo4">White space wrapping behavior with a very long line of text that goes on and on</p>
CSS
.demo1 {
line-height: 1.8;
letter-spacing: 2px;
font-size: 1.125rem;
}
.demo2 {
text-align: center;
text-transform: uppercase;
font-weight: bold;
color: #6366f1;
}
.demo3 {
text-decoration: underline wavy #f59e0b;
text-shadow: 2px 2px 4px rgba(0,0,0,0.2);
font-size: 1.25rem;
}
.demo4 {
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
background: #f1f5f9;
padding: 8px;
border-radius: 4px;
}
Live Output Window

Typography Properties

PropertyWhat It Does
line-heightVertical space between lines
letter-spacingSpace between characters
word-spacingSpace between words
text-alignHorizontal alignment (left, center, right, justify)
text-transformCase control (uppercase, lowercase, capitalize)
text-decorationUnderline, overline, line-through
text-shadowShadow behind text
white-spaceControls wrapping and whitespace
text-overflowHow overflow text is indicated
word-breakHow words break at line endings
directionText direction (ltr, rtl)

Good typography makes content easier to read and more professional.