Centering Images Using CSS

written by Jerod on July 21st, 2008 @ 09:21 AM

Posting this for my own reference. I always forget how to do this and am sick of looking it up:

   1  <!-- html file -->
   2  <img class="example" src="/path/to/image.png" />
   1  /* css file */
   2  img.example {
   3  display: block;
   4  margin-left: auto;
   5  margin-right: auto;
   6  }

Its the block display setting that I always forget. Not anymore baby!!

Post a comment

Options:

Size

Colors

Clicky Web Analytics