Aligning text to the bottom of images

I am aligned to the bottomThis text is at the bottom!

The sentence above is aligned with the bottom of the image. To make this happen we need to make use of our CSS file and our image tag and also pay some attention to how much space we have to work with.

The CSS

Let's make a class in our CSS file called "bottom"...

img.bottom {
vertical-align:baseline;
}

The image tag

For the image we want centered we have to add the class "center"...

CSS code:
<img src="images/yourimagefile.jpg" class="bottom" />

That's it! You are done. (methods are described in detail below)



Techniques described

if you weren't sure what to do...

Here is a more detailed description of the above methods. We will explain everything.

Using CSS for aligning text to the bottom of an image.

A CSS file contains instructions that your web pages use to display items in particular ways. In order to use CSS techniques, we must change both the CSS file and the HTML document.

First you must update your CSS file and add the following code...

img.top {
vertical-align:baseline;
}

In CSS this is called creating a "class". It is an instruction of how to display your image whenever that class is called. The name of this particular class is "bottom".

Once you have added this to your CSS file, you must tell the image what instructions to use. To do this, go to the image tag of the image you want to center and change it so that it knows what instructions to follow...

<img src="images/yourimagefile.jpg" class="bottom" />

In the above code you can see that we added a "class" and that it's name is "bottom". Now the image knows where to find instructions.

Once the CSS file and the HTML image tag is updated, the text next to the image will be aligned to the bottom of that image.