CSS vertical-align Property Explained

What the CSS vertical-align property does, with an example.

Published November 7, 2026

vertical-align aligns inline, inline-block and table-cell elements relative to the line or cell: baseline, middle, top, bottom, sub, super or a length.

How it works

It does not work on block elements: use flexbox or grid to align those.

Images in text sit on the baseline by default, leaving a small gap beneath; vertical-align: middle or display: block removes it.

Values and effects

vertical-align: baseline; → default
vertical-align: middle; → centre with text
vertical-align: top; → top of line
vertical-align: sub/super; → subscript/superscript

Practical examples

Icon next to text

.icon { vertical-align: middle; }

Remove gap under images

img { vertical-align: bottom; }

Table cell alignment

td { vertical-align: top; }

Common mistakes

  • Expecting it to centre block elements.
  • Mysterious gaps below inline images.
  • Mixing line-height and vertical-align hacks.

Key takeaways

  • vertical-align in one line: vertical-align aligns inline, inline-block and table-cell elements relative to the line or cell: baseline, middle, top, bottom, sub, super or a length.
  • Inspect it live in DevTools → Styles.
  • Test across browsers and screen sizes.

FAQ

How do I centre a block vertically?

Use flexbox or grid (align-items: center).

Is vertical-align supported in all browsers?

Yes in all modern browsers; check caniuse.com for edge cases.

More CSS articles