Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

valign in Div ? 1

Status
Not open for further replies.

safra

Technical User
Jan 24, 2001
319
NL
Hi,

I have some div's of a certain height (14 px). How can I make sure that text inside the div appears in the middle (vertically)? I tried valign="middle" but didn't work.

regards,

Ron
 
As long as the DIV has a position attrib, then this code will do as you ask -

<span style=&quot;position: absolute; top: 50%;&quot;>Hello</span>

If the DIV does not have position, then it will do 50% from the body element instead.

I used position: relative for the DIV and it worked a treat in IE5.5 Dean Owen
 
Thanks Dean!

'Relative' didn't work and &quot;position: absolute; top: 50%;&quot; did affect the vertical position more than 50% but after changing the percentage I got it the way I want it.

regards,

Ron
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top