According to explanations documented on This link:
- HTML layout traditionally was not designed to specify vertical behavior. By its very nature, it scales width-wise, and the content flows to an appropriate height based on the available width. Traditionally, horizontal sizing and layout is easy; vertical sizing and layout was derived from that.
vertical-align
is used to specify two completely different behaviors depending on where it is used
vertical-align in table cells
When used in table cells, vertical-align
does what most people expect it to, which is mimic the (old, deprecated) valign
attribute. In a modern, standards-compliant browser, the following three code snippets do the same thing:
<td valign="middle"> <!-- but you shouldn't ever use valign --> </td>
<td style="vertical-align:middle"> ... </td>
<div style="display:table-cell; vertical-align:middle"> ... </div>
vertical-align on inline elements
When vertical-align
is applied to inline elements, however, it's a whole new ballgame. In this situation, it behaves like the (old, deprecated) align
attribute did on <img>
elements. In a modern, standards-compliant browser, the following three code snippets do the same thing:
<img align="middle" ...>
<img style="vertical-align:middle" ...>
<span style="display:inline-block; vertical-align:middle"> foo<br>bar </span>