Click to See Complete Forum and Search --> : Would like to center this text vertically with respect to image


M123
11-23-2009, 02:20 AM
Please let me know how I can center the following text to the image that is beside it.

<div style="float:left">
<img src="http://upload.wikimedia.org/wikipedia/commons/thumb/c/c1/Square-symbol.svg/50px-Square-symbol.svg.png"/> &nbsp;&nbsp;
</div>
Text
<br/>
Text

(can be tested with http://www.w3schools.com/html/tryit.asp?filename=tryhtml_intro)

mordauk
11-23-2009, 11:32 AM
I'm entirely sure what you are asking, but if you want the image and text to be center left-and-right on the page, then all you need to do is remove float: left; from your div style and add margin: 0 auto; instead.

mordauk
11-23-2009, 11:35 AM
Sorry, after rereading I realized what you were asking.

Put this in your style

div {
line-height:8em;
}
img {
vertical-align:middle;
}

Modify line-height until you are satisfied.

M123
12-28-2009, 11:25 PM
Thanks for the help.
Sorry for the late reply, I ended up using what you suggested in my solution, but forgot to reply...