Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Align text with an image [duplicate]

Tags:

html

css

Possible Duplicate:
How do I vertically align text next to an image with CSS?

I am having trouble on aligning my texts and an image.

the texts and image are like

texts  ---------
      | image   |
       _________ 

I want the texts to be middle of the div instead of align to top.

I have:

<div id='test'> tests <img src='/images/logo.png'/> </div>

I have used the following css but still no luck

#test{
    margin-left: 10px;
    vertical-align: middle;
}

How do I align my text to the middle with image. Thanks so much!

like image 557
FlyingCat Avatar asked Oct 16 '12 23:10

FlyingCat


1 Answers

The vertical-align:middle should be on the image, not the container.

like image 187
Niet the Dark Absol Avatar answered Oct 26 '22 01:10

Niet the Dark Absol