User Experience Stack Exchange is a question and answer site for user experience researchers and experts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Every time I work on a new project I do not have any problems to center the text using "text-align: center" to center the text, but I have never seen a similar code to center images so I always have hack the code by either centering the images in the HTML (not the cleanest option) or by giving the image a variable width (which does not work on multiple resolutions). Is there any way to accomplish this that I have not tried? And, does any one know if something like this will be implemented in CSS3?

share|improve this question

closed as off topic by Joel Spolsky Sep 18 '10 at 3:27

Questions on User Experience Stack Exchange are expected to relate to user experience within the scope defined by the community. Consider editing the question or leaving comments for improvement if you believe the question can be reworded to fit within the scope. Read more about reopening questions here.If this question can be reworded to fit the rules in the help center, please edit the question.

I dont think so but what I do Is in my HTML file I will add: <center><img src="example.png"/></center> – Micheal Harker Aug 9 '10 at 20:33
I think this belongs on DocType. – Darryl Hein Aug 9 '10 at 20:46
up vote 8 down vote accepted

Set the containing elements style to


set your image style to

share|improve this answer

Sruly's answer hits the nail on the head. the only thing I would consider adding is vertical-align: middle; for the image tag, as follows:

vertical-align: middle;
share|improve this answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.