verticle center with CSS Tables

Allen Pitts
Allen Pitts used Ask the Experts™
on
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.

http://www.vanseodesign.com/css/vertical-centering/

 <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.

Thanks.

Allen in Dallas
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Owner (Aidellio)
Most Valuable Expert 2015
Commented:
Works fine for me: http://jsbin.com/jiceje/edit?html,css,output

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

Commented:
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