SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Zealot
    Join Date
    Aug 2004
    Location
    CA
    Posts
    141
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question Why isn't this centering?

    Can someone tell me why image.gif is not centering here:

    <html>
    <head>
    <title>Test</title>
    <style>
    body {text-align:center}
    div.title {text-align:center;border-width:.5em;border-color:#000000;border-style:solid;width:50%}
    </style>
    </head>
    <body>
    <div class="title"><img src="image.gif"></div>
    </body>
    </html>

    I'm stumped.

    - Grant

  2. #2
    Non-Member
    Join Date
    Jan 2005
    Location
    Netherlands
    Posts
    4,300
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hello

    margin:0 auto; a proper DTD and a width and height for the image

    PS validating your code saves a lot of hassle

    Code:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
    <html>
    <head>
    <title>Test</title>
    <style type="text/css">
    <!-- 
    body{text-align:center}
    .title {border-width:.5em;border-color:#000000;border-style:solid;width:50%;margin:0 auto;}
     -->
    </style>
    </head>
    <body>
    <div class="title"><img src="image.gif" width="100%" height="100" alt=""></div>
    </body>
    </html>

  3. #3
    SitePoint Zealot
    Join Date
    Aug 2004
    Location
    CA
    Posts
    141
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ok, {margin:auto} is a new one to me. I thought {text-align:center} was for centering stuff.

    - Grant

  4. #4
    Non-Member
    Join Date
    Jan 2005
    Location
    Netherlands
    Posts
    4,300
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hello

    Yes for IE 5 5.5 and IE 6 in quirksmode


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •