Link to home
Start Free TrialLog in
Avatar of workflow80
workflow80

asked on

how to center an image

Hi
I want to center an image . Here is part of my code :

<body>
test
<div><img src="image.jpg"  align="center"> </div>
</div>

It is always on the left. I want the image in the center of my html page.

Thanks for your help
Avatar of Tom Beck
Tom Beck
Flag of United States of America image

You could try this, but it may affect other elements on the page.

<body style="margin:0 auto;padding:0;">
test
<div><img src="image.jpg"  align="center"> </div>
</div>
try this

<div style="width: 50%; margin: auto;"><img src="image.jpg"></div>

Open in new window

Maybe for kicks and giggles....
   Add :
align to the div:
<body style="margin:0 auto;padding:0;">
test
<div align="center"><img src="image.jpg"  align="center"> </div>
</div>
SOLUTION
Avatar of Paul Sauvé
Paul Sauvé
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
oh and btw - I built a head and closed the body and head in my test, just to make sure it was reading it proper.  Just FYI.