Can't get <img> to align center?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • divina11
    New Member
    • Aug 2007
    • 55

    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>Te st</h1><br><br>
    <img src="italy.jpg" align=center height=160 width=240 border=4>
    </body>[/HTML]
  • drhowarddrfine
    Recognized Expert Expert
    • Sep 2006
    • 7434

    #2
    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:a uto">

    Comment

    • divina11
      New Member
      • Aug 2007
      • 55

      #3
      thanks for that, someone suggusted <center></center> which also did the trick.

      Thanks again.

      Comment

      • drhowarddrfine
        Recognized Expert Expert
        • Sep 2006
        • 7434

        #4
        <center> was deprecated many years ago. Use CSS.

        Comment

        Working...