Centering images and text inside an li or div

Found a good fix for this one as well. This will work on LIs or DIVs. Here’s how to do this in IE and FireFox:

li {
  display: inline;
  text-align: center;
}

li img {
  display: block;
  margin: auto;
}

The HTML looks like this:

<ul>
  <li><img src="..."/>Some text</li>
  <li><img src="..."/>Some text</li>
</ul>

4 thoughts on “Centering images and text inside an li or div

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 )

Google photo

You are commenting using your Google 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 )

Connecting to %s