Vertical Alignment of Images

This example demonstrates how to set the vertical align of an image in a text:

HTML file: Displayed by browser:
<style>
img.top {
    vertical-align: text-top;
}
img.bottom {
    vertical-align: text-bottom;
}
img.center {
    vertical-align: text-middle;
}
</style>
<body>
<p>
An <img src="../html_beg/images/submit.gif" alt="Submit" width="48" height="48"> image with a default alignment.
</p>
<p>
An <img class="center" src="../html_beg/images/submit.gif" alt="Submit" width="48" height="48"> image with a text-middle alignment, which is the same as the default.
</p>
<p>
An <img class="bottom" src="../html_beg/images/submit.gif" alt="Submit" width="48" height="48"> image with a text-bottom alignment. The image is slightly lower than the default -- maybe aligned to the bottom of the g, j, p, q, and y characters?
</p>
<p>
An <img class="top" src="../html_beg/images/submit.gif" alt="Submit" width="48" height="48"> image with a text-top alignment.
</p>
</body>

An Submit image with a default alignment.

An Submit image with a text-middle alignment, which is the same as the default.

An Submit image with a text-bottom alignment. The image is slightly lower than the default -- maybe aligned to the bottom of the g, j, p, q, and y characters?

An Submit image with a text-top alignment.

The vertical-align replaces the valign attribute.

Back buttonTable of ContentsNext button