Another option, although it has its limitations:
<!DOCTYPE html> <html> <head> </head> <body> <div style="height:150px; text-align: center;"> <img src="/centerme.jpg" style="position: relative; top: 50%; margin-top: -25px;" /> </div> </body> </html>
Negative margin should be half the height of the image. Thus, the following image will be concentrated in the above HTML:

This makes the centering dynamic if you have a div that changes height. This may be a little difficult with relative positioning, because the image is taken out of the normal layout stream.
source share