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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how do i vertical align text with an image using css?

Status
Not open for further replies.

pushyr

Programmer
Jul 2, 2007
159
GB
i've tried and searched and still no success! i'm trying to vertical align text with an image so they are both vertically centered.

Code:
#textcenter {
vertical-align: middle;
}



<ul>
<li><img src="img.gif"><div id="textcenter">text</div></li>
</ul>

what am i doing wrong?



 
Hi

[ol]
[li]Is not enough to align only one of them[/li]
[li][tt]div[/tt] is block element so by default can not be aligned with anything[/li]
[/ol]
Code:
li img,li div {
  vertical-align: middle;
}
li div {
  display: inline;
}

Feherke.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top