How do I align text and image with CSS?


I had a problem while aligning some text before an image.

Image

My Code:

<div align=’center’>
<span style=”vertical-align:middle”>Thank you for contacting us! We’ll get in touch with you shortly.</span>
<img src=”A.jpg” alt=”Thank You” style=”width: 60px; height: 60px; ” />
</div>

Tried many alterations and finally came to a solution!

Actually, in this case, i was applying vertical align to the text since it’s all in one line, it’s really the image I want aligned, not the text.

So, final code:

<div align=”center”>
<span>Thank you for contacting us! We’ll get in touch with you shortly.</span>
<img src=”A.jpg” alt=”Thank You” style=”width: 60px; height: 60px; vertical-align: middle;” />
</div>

Checked on IE 7,8 and FF 3, and it’s working great 🙂

Image

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s