verticle center with CSS Tables

Allen Pitts
Allen Pitts used Ask the Experts™
Hello expert,

Working on vertically aligning some text in a CSS <div>.
I found a site that claims to provide a solution using
CSS tables.

 <div style="display: table; background: yellow;">
 <div style="display: table-cell; background: blue; color: white; height:62px; width: 162px; vertical-align: middle;">
 some text text text</div>

But this does not vertically center the text.

Am I doing something wrong.


Allen in Dallas
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Owner (Aidellio)
Most Valuable Expert 2015
Works fine for me:,css,output

You were missing a closing </div> tag though in your example above.
Marco GasiFreelancer
Top Expert 2010

Maybe in your page you have some other rule which breaks the layout...

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial