How to Style Text with CSS. The most common text properties

CSS offers a wide range of properties that allow you to customize the appearance of text. Some properties modify the font, while others focus on spacing, alignment, or decorative elements. When used together, these properties can elevate simple text into well-crafted content.

Let’s look at the text properties you’ll use most often.

Start with the basics

The first step is choosing a font. The font-family property specifies which typeface the browser should use.

CSS example of using font-family property in paragraphs.

You can then adjust the text size with font-size.

Example of using the font-size property in paragraphs.

For responsive designs, many developers prefer relative units such as rem or use the clamp() function to create text that scales smoothly across different screen sizes.

Control the appearance

Once you’ve chosen a font, CSS lets you change its style and weight.

Example of using font-weight, font-style, and text-transform in a heading.

Improve readability

Readable text isn’t only about font size. Spacing also matters.

The line-height property controls the space between lines.

Example of using line-height in paragraphs.

The letter-spacing property adjusts the distance between characters, while word-spacing changes the gap between words.

example of using letter and word spacing in text.

Simple changes can make long articles much more reader-friendly.

Position the text

The text-align property controls horizontal alignment.

Example of text-align property.

The most common values are left, center, right, and justify.

Refine your text

CSS also lets you decorate text.

Example of different text-decoration properties and values.
Example of the text-decoration property on a paragraph.
Here, we decorate text with a wavy, red, underline.

The color property changes the text color, while text-shadow adds a subtle shadow effect.

Example of using text-shadow at a heading.
Example of using text-shadow on a heading.
We can apply a shadow in a heading using the text-shadow property.

Note: Use decorative effects with care. They should support readability, not compete with it.

Final thoughts

Most websites rely on a relatively small set of CSS text properties.

Learning font-family, font-size, font-weight, line-height, text-align, text-transform, text-decoration, letter-spacing, word-spacing, color, and text-shadow gives you the tools to style nearly every piece of text on a page.

Although my blog doesn’t support comments, feel free to reply via email or X.