Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Vertically center align text

Tags:

html

css

Ok, here's what this HTML elements looks like right now:

enter image description here

I'd like the text to be centered with the image. The image is 32x32px.

Here's my code:

<style>
div.interface {
    line-height: 32px;
    float: left;
    margin: 10px;
    width: 450px;
    font: 14px/27px 'CalibriRegular', Arial, sans-serif;
    color: #646464; text-shadow: 1px 1px 1px #fff;
    padding-right: 10px;
}
</style>

<div class="interface"><img src="assets/icons/interface.png" />Filled with fun animations and eye-candy!  Complete with Retina graphics.</div>
like image 240
sudo rm -rf Avatar asked Feb 10 '11 03:02

sudo rm -rf


People also ask

Does vertical-align work for text?

The vertical-align property can be used in two contexts: To vertically align an inline element's box inside its containing line box. For example, it could be used to vertically position an image in a line of text. To vertically align the content of a cell in a table.


1 Answers

To center text vertically set the line-height to the same as the height, for example:

img{ height: 30px; }
#text{ line-height: 30px; }

And set vertical-alignment to middle:

#text{ line-height: 30px; vertical-align:middle; }
like image 128
JCOC611 Avatar answered Oct 18 '22 09:10

JCOC611