4

I have a div like this

<div id="browsers">
  <h2>Title</h2>
  <p>Text recomending the use of either Chrome or Firefox.</p>
  <a href="http://google.com/chrome/"><img src="img/64-chrome.png" /></a>
  <a href="http://mozilla.org/firefox/"><img src="img/64-firefox.png" /></a>
</div>

and the CSS

#browsers {
  margin:0 auto;
  padding:22px;
  width:500px;
  background:white;
}

and I want to center the two images in the middle of the div. I have managed to center them with

#browsers img {
  margin-left:auto;
  margin-right:auto;
  display:block;
}

however the output is not what I want, since one image is on the top of the other. I want them to be on the same line. What's the best or the usual way to do it?

rberaldo
  • 207
  • 2
  • 8

2 Answers2

4

Usually just #browsers {text-align:center;} and remove what you have in #browsers img {...}

As you have extra stuff in #browsers. You'll need to put your browser icons in a separate div or your extra stuff outside of #browsers.

Eg.

<div class="browser-icons"> ... </div>

Lee Kowalkowski
  • 11,591
  • 3
  • 40
  • 46
0

Your problem is that you are telling the images are blocks in display:block;... try display:inline; instead.

admin
  • 41
  • 1
  • 6
  • I tried this before, it didn't work. With `display:inline;`, although the icons are in the same line, they're flushed to the left for some reason. – rberaldo Nov 21 '11 at 15:46