The vertical-align property controls how inline elements sit next to text — perfect for icons, badges, subscripts, and table cells.
01
Inline align
Icons beside text.
02
Syntax
Keywords and lengths.
03
baseline
Default value.
04
middle
Center with text.
05
Tables
Cell alignment.
06
Limits
Not for block boxes.
Fundamentals
Introduction
The vertical-align property in CSS controls how inline elements are aligned vertically relative to their parent element or to the line box.
This property is particularly useful for aligning text and other inline elements within a line of text or within a table cell.
Definition and Usage
Apply vertical-align to inline-level elements (such as span, img, and input), inline-block elements, or table cells (td, th). It adjusts position along the vertical axis within a line or cell — not the whole block on the page.
💡
Beginner Tip
vertical-align does not center a block-level div inside its parent. For that, use flexbox (align-items: center) or grid. Use vertical-align when something sits inline next to text or inside a table cell.
Foundation
📝 Syntax
The syntax for the vertical-align property is straightforward. It can be applied to inline or table-cell elements, and you can specify various alignment values.
syntax.css
element{vertical-align:baseline | sub | super | text-top | text-bottom | middle | top | bottom | <length> | <percentage>;}
Basic Example
vertical-align.css
.inline-img{vertical-align:middle;}
Syntax Rules
Works on inline, inline-block, and table-cell elements.
One keyword, length, or percentage value at a time.
Length and percentage values shift the element relative to the baseline.
For table cells, top, middle, and bottom refer to the cell box.
The property is not inherited.
Related Properties
line-height — controls line box height around inline content
text-align — horizontal alignment (often paired in tables)
display — change to inline-block or table-cell when needed
align-items — flexbox alternative for block-level vertical centering
Defaults
🎯 Default Value
The default value of vertical-align is baseline, which aligns the baseline of the element with the baseline of its parent.
Cheat Sheet
⚡ Quick Reference
Question
Answer
Default value
baseline
Icon beside text
vertical-align: middle;
Subscript / superscript
vertical-align: sub; or super;
Table cell center
vertical-align: middle; on td
Applies to
Inline, inline-block, table-cell
Inherited
No
Reference
💎 Property Values
The vertical-align property accepts keyword values, lengths, and percentages.
Value
Example
Description
baseline
vertical-align: baseline;
Aligns the baseline of the element with the baseline of its parent.
top
vertical-align: top;
Aligns the top of the element with the tallest element on the line (or top of the cell in tables).
middle
vertical-align: middle;
Aligns the middle of the element with the middle of the parent element’s font (or center of the cell in tables).
bottom
vertical-align: bottom;
Aligns the bottom of the element with the lowest element on the line (or bottom of the cell in tables).
sub
vertical-align: sub;
Aligns the element as subscript relative to the baseline.
super
vertical-align: super;
Aligns the element as superscript relative to the baseline.
text-top
vertical-align: text-top;
Aligns the top of the element with the top of the parent element’s font.
text-bottom
vertical-align: text-bottom;
Aligns the bottom of the element with the bottom of the parent element’s font.
<length>
vertical-align: 4px;
Raises or lowers the element by a fixed distance from the baseline.
<percentage>
vertical-align: 10%;
Raises or lowers the element as a percentage of the line-height.
On table cells, keywords refer to the cell box rather than the text line, giving predictable top, center, and bottom placement.
A11y
♿ Accessibility
Prefer semantic tags — Use <sub> and <sup> for meaningful subscripts and superscripts when appropriate.
Keep readable line height — Extreme vertical-align offsets can make text harder to read for low-vision users.
Alt text on inline images — Decorative icons should use empty alt (alt=""); meaningful icons need descriptive alt text.
Do not rely on alignment alone — Ensure meaning is clear from text content, not just visual position.
Companion
vertical-align + display
If an element is block-level by default, change its display before vertical-align can take effect inline. For whole-component centering, flexbox is usually the better tool.
Keywords like baseline, middle, or top define the alignment point.
Rule
3
Browser shifts the element
The inline box moves up or down relative to siblings in the line.
Render
=
✅
Balanced inline layout
Icons, text, and badges sit neatly on one line.
Compatibility
Browser Compatibility
The vertical-align property is well-supported across all major browsers, including Chrome, Firefox, Safari, Edge, and Opera. It behaves consistently across different platforms.
✓ Modern browsers · Widely supported
Inline and table alignment
All major browsers support vertical-align for inline content and table cells.
99%Browser support
Google ChromeAll versions · Desktop & Mobile
Full support
Mozilla FirefoxAll versions · Desktop & Mobile
Full support
Apple SafariAll versions · macOS & iOS
Full support
Microsoft EdgeAll versions
Full support
OperaAll versions
Full support
Testing tip
Test icon + text pairs at different font sizes and zoom levels to confirm alignment still looks correct.
vertical-align property99% supported
Bottom line:vertical-align is a reliable choice for inline and table-cell alignment on the modern web.
Wrap Up
Conclusion
The vertical-align property is a versatile tool for aligning inline elements vertically within their container.
Whether you’re aligning text alongside images, adjusting the positioning of subscripts or superscripts, or fine-tuning the vertical alignment of table cells, understanding and using vertical-align can significantly enhance the layout and presentation of your web content.
Use vertical-align on table cells instead of HTML valign
Combine with display: inline-block for badges and chips
Prefer <sub> and <sup> for semantic formulas when possible
Test at multiple font sizes and zoom levels
❌ Don’t
Expect vertical-align to center block-level containers
Overuse pixel offsets when a keyword value works
Forget that table and inline contexts interpret some keywords differently
Sacrifice readability for tiny vertical tweaks
Summary
Key Takeaways
Knowledge Unlocked
Five things to remember about vertical-align
Use these points when aligning inline content.
5
Core concepts
📚01
Inline only
Not for block centering.
Purpose
🕐02
baseline
Default value.
Default
🔀03
middle
Icons + text.
Pattern
🔒04
Tables
Cell alignment.
Layout
🌐05
99% support
All browsers.
Compat
❓ Frequently Asked Questions
vertical-align controls how inline-level and table-cell elements are positioned vertically relative to their line box or table cell.
The default value is baseline, which aligns the element's baseline with the parent line's baseline.
vertical-align applies to inline-level and table-cell elements. Block elements like div do not respond to it unless you change display to inline-block or table-cell.
middle aligns with the middle of the parent font. text-bottom aligns with the bottom of the parent font, not the bottom of the line box.
No, vertical-align is not inherited. You must set it on each element that needs a different alignment.