CSS: Text Styling & Lists

Control how text looks and how lists are presented.

text-align

text-align controls the horizontal alignment of inline content (text, images) inside a block element.

text-align

text-align sets where text sits horizontally within its container. It only affects inline and inline-block content, not the block element itself.

  • left: default for LTR languages; text starts from the left edge
  • right: text starts from the right edge
  • center: text is centered within the container
  • justify: text is stretched so each line fills the full width

text-align

Four alignment values in action.

text-decoration

text-decoration adds lines to text, underlines, strikethroughs, and overlines. It is also used to remove the default underline from links.

text-decoration

text-decoration is a shorthand for text-decoration-line, text-decoration-color, and text-decoration-style. Most commonly used to underline text or remove link underlines.

text-transform

text-transform changes the capitalisation of text visually, without changing the actual HTML content.

text-indent and letter-spacing

text-indent moves the first line of a paragraph inward. letter-spacing adjusts the space between each character.

word-spacing and white-space

word-spacing adjusts the space between words. white-space controls how the browser handles spaces, tabs, and line breaks in HTML.

line-height (Leading)

line-height sets the vertical space between lines of text. A comfortable reading value for body text is between 1.5 and 1.7.

text-shadow

text-shadow adds a shadow behind text. You can stack multiple shadows by separating them with commas.

list-style-type, list-style-position, list-style-image

These three properties control the marker (bullet or number) shown next to each list item. They can be combined using the list-style shorthand.

Styling Ordered and Unordered Lists

Beyond the marker type, you can style the entire list and individual items with any CSS property: spacing, colors, borders, and custom counters.

Removing Default List Styling

Browsers apply default styles to lists: bullets, indentation, and spacing. When building navigation menus or custom lists, you usually need to reset all of these first.