471,583 Members | 1,515 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,583 software developers and data experts.

Can't get <img> to align center?

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
3 3523
drhowarddrfine
7,435 Expert 4TB
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
thanks for that, someone suggusted <center></center> which also did the trick.

Thanks again.
Oct 12 '07 #3
drhowarddrfine
7,435 Expert 4TB
<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.

Similar topics

15 posts views Thread by Philipp Lenssen | last post: by
5 posts views Thread by MyndPhlyp | last post: by
2 posts views Thread by R.A.M. | last post: by
4 posts views Thread by bgold12 | last post: by
reply views Thread by XIAOLAOHU | last post: by
reply views Thread by leo001 | last post: by
1 post views Thread by lumer26 | last post: by
reply views Thread by lumer26 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.