What ways of vertical text centering inside a div contaner do you know?
Asked
Active
Viewed 116 times
2 Answers
1
text-align:center
;margin:0 auto;
//tag needs to have a with

amosrivera
- 26,114
- 9
- 67
- 76
-
Not OP, but what is the difference between 'margin: 0 auto 0 auto' and 'margin: 0 auto'? – Jan 15 '11 at 07:00
-
And what about *vertical* text? – Sarfraz Jan 15 '11 at 07:01
-
there is no difference, using margin:0 auto; is the short-hand version see: http://www.dustindiaz.com/css-shorthand/ – amosrivera Jan 15 '11 at 07:01
-
@kevin: `margin: A` becomes `margin: A A A A`. `margin: A B` becomes `margin: A B A B`. `margin: A B C` becomes `margin: A B C B`. – Steven Jan 15 '11 at 07:04
0
If a single line of text, setting the line height of the div to be the height of the div.
If the height of the content is known, position it absolutely - top: 50%, margin-top: -(half the height of the content) pixels.

sevenseacat
- 24,699
- 6
- 63
- 88