By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,853 Members | 1,015 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,853 IT Pros & Developers. It's quick & easy.

Can't get <img> to align center?

P: 55
Oddly, I can't seem to get the image to align to the center of the page?
I'm using IE 6, tried FireFox 2 still the same! The image just aligns to the right
for same reason. The text aligns to the center fine, see my code below:

[HTML]<body>
<h1 align=center>Test</h1><br><br>
<img src="italy.jpg" align=center height=160 width=240 border=4>
</body>[/HTML]
Oct 11 '07 #1
Share this Question
Share on Google+
3 Replies


drhowarddrfine
Expert 5K+
P: 7,435
There is no such attribute for images as "align". And this makes sense because an image is an inline element, just as text is. <h1>, however, is block level and that's why align is available.

To center the image, you should use CSS.
<img style="margin:auto">
Oct 12 '07 #2

P: 55
thanks for that, someone suggusted <center></center> which also did the trick.

Thanks again.
Oct 12 '07 #3

drhowarddrfine
Expert 5K+
P: 7,435
<center> was deprecated many years ago. Use CSS.
Oct 12 '07 #4

Post your reply

Sign in to post your reply or Sign up for a free account.