Centering image links using CSS

Posted by Alpha Sun, 30 Dec 2007 21:05:58 GMT

It took me no small amount of time to figure out how to horizontally and vertically center image links, so here it is for posterity’s sake. Note that this doesn’t work in IE and is rather specific to my purposes in creating thumbnail links for a bunch of pictures.

HTML:
<div class="thumbnail">
    <a href=/some/link>
        <img src=/some/image>
    </a>
</div>
CSS:
.thumbnail {
    height:150px;
    width:150px;
    line-height:150px;
    text-align:center;
}

.thumbnail img {
    vertical-align:middle;
}

Posted in ,  | no comments | no trackbacks

Comments

Trackbacks

Use the following link to trackback from your own site:
http://blog.kejadlen.net/trackbacks?article_id=centering-image-links-using-css&day=30&month=12&year=2007

(leave url/email »)

   Comment Markup Help Preview comment