HTML – center an image vertically & horizontally

<body>
  <table id="table-foo">
    <tr><td>
        <img sr="foo.png" /> 
    </td></tr>
  </table>
</body>
<style type="text/css">
  html, body {
    height: 100%;
  }
  #table-foo {
    width: 100%;
    height: 100%;
    text-align: center;
    vertical-align: middle;
  }
  #table-foo img {
    display: block;
    margin: 0 auto;
  }
</style>
This entry was posted in Others and tagged , . Bookmark the permalink.

One Response to HTML – center an image vertically & horizontally

  1. Sean says:

    Please let me know if you’re looking for a author for your weblog. You have some really good posts and I feel I would be a good asset. If you ever want to take some of the load off, I’d really like to write some content for your blog in exchange for a link back to mine.
    Please shoot me an email if interested. Regards!

    Review my blog; Sean

Leave a Reply

Your email address will not be published. Required fields are marked *