www.webdeveloper.com
Results 1 to 5 of 5

Thread: valign for contents...help plz

  1. #1
    Join Date
    Dec 2002
    Posts
    12

    Question valign for contents...help plz

    ok this has been a big problem for me and ive been "cheating" my way thru it (by making blank tables)

    how do i vertically center the contents of my site...say its one table 400x400pixels
    w/out using div's (cos i had problems with them grrr)

    anyone have any ideas?

  2. #2
    Join Date
    Dec 2002
    Location
    Switzerland
    Posts
    428
    Try this one:
    <table border="0" width="100%" height="100%"> <!--makes a 100% box //-->
    <tr>
    <td align=center><!--if you don't use the valign attribute the default is valign=middle, you can change it to:top,bottom,middle //-->
    <table border="1" width="400" height="400">
    <tr>
    <td align=center>this should be centered!</td>
    </tr>
    </table>
    </td>
    </tr>
    </table>


    Swon

  3. #3
    Join Date
    Dec 2002
    Posts
    12

    Talking thx

    thanks! that worked perfectly

  4. #4
    Join Date
    Nov 2002
    Posts
    984

    Re: valign for contents...help plz

    Originally posted by dd014

    how do i vertically center the contents of my site...say its one table 400x400pixels
    w/out using div's (cos i had problems with them grrr)
    Do you mean this doesn't work?

    <div style="position:absolute; top:50%; left:50%; width:400px; height:400px; margin:-200px 0 0 -200px;">

    </div>
    // Stefan Huszics

  5. #5
    Join Date
    Nov 2002
    Posts
    984
    Originally posted by swon

    <td align=center><!--if you don't use the valign attribute the default is valign=middle, you can change it to:top,bottom,middle //-->
    No, valign="middle" is definitly NOT the default (even if the HTML spec sais so).
    IE 6, Opera 7b2 and Gecko ALL default to the correct CSS-default {vertical-align:baseline}.
    Mayby there is some old browsers out there still in use that default to middle, but modern browsers don't (unless you use broken code to force them to render the page in non-standards mode).

    You are most welcome to verify that with eg this examplecode

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <meta http-equiv="Content-Script-Type" content="text/javascript">
    <meta http-equiv="Content-Style-Type" content="text/css">
    <title></title>
    <link href="main.css" rel="stylesheet" type="text/css" title="Default" media="screen">
    </head>
    <body>

    <table border="0" width="100%" height="100%">
    <tr>
    <td align=center>
    <table border="1" width="400" height="400">
    <tr>
    <td align=center>this should be centered!</td>
    </tr>
    </table>
    </td>
    </tr>
    </table>

    </body>
    </html>


    The fix is of cource to use eg
    td {vertical-align:middle}
    in your stylesheet.
    Last edited by Stefan; 12-30-2002 at 12:42 AM.
    // Stefan Huszics

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles