

If you can meet these assumptions, then this method is for you: The following example makes two (non-trivial) assumptions. You probably want to know how to do it properly. If you are reading this page, you're probably not as interested in why what you were doing is wrong.

So how do I vertically-center something?! When the novice developer applies vertical-align to normal block elements (like a standard ) most browsers set the value to inherit to all inline children of that element. Technically, this CSS attribute doesn't go on any other kinds of elements. Vertical-align:text-bottom as an example.

Vertical-align:middle and display:inline-block In this paragraph, I have a cute little display:inline-block In this paragraph, I have two images- and -as examples. Shown in your browser, the above (with appropriate wrappers) display as: In a modern, standards-compliant browser, the following three code snippets do the same thing: When used in table cells, vertical-align does what most people expect it to, which is mimic the (old, deprecated) valign attribute.
