...

View Full Version : Centering Text in CSS.



macmonkey
02-11-2005, 06:47 PM
What's the appropriate way to vertically center a line of text inside a css <div>

I realize that <center></center> doesn't validate.

Thanks

JW

Brandoe85
02-11-2005, 07:10 PM
I believe its: text-align: center;

chilipie
02-11-2005, 08:36 PM
He said to vertically center text...

Say you have a div that is 500px high. This is how you would get the text in the center (horizontally and vertically).

CSS:


div.500 {
height: 500px;
width: 500px;
}

p.centered {
text-align: center;
line-height: 500px;
}


HTML:


<div class="500">
<p class="centered">Centered text.</p>
</div>

rmedek
02-11-2005, 08:39 PM
How to vertically align something? I wonder if this has been asked before...

* harp music and a slow fade to.... *

http://codingforums.com/showthread.php?t=52120

:)



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum