I want a table to be centered in the center of the page

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • JennfierParker
    New Member
    • Jan 2012
    • 1

    I want a table to be centered in the center of the page

    My code,
    Code:
    <table align="center" bgcolor="lightblue">
                            <tr>
                                <td>UserName</td>
                                <td><input type="text" name="user"/></td>
                            </tr>
                            <tr>
                                <td>PassWord</td>
                                <td><input type="password" name="pwd"/></td>
                            </tr>
                            <tr align="center">
                                <td colspan="2"><input type="submit" value="Login"/></td>
                            </tr>
                        </table>
  • C CSR
    New Member
    • Jan 2012
    • 144

    #2
    You can use this below and DIVs. If your tables a childNode, find its parent.

    Code:
    <body>
    <CENTER>

    Comment

    • lgm001
      New Member
      • Jan 2012
      • 9

      #3
      Arghhh... Don't use <center></center>... its been deprecated...

      Okay... set a width on your table...
      <table style="width: 800px; margin: 0 auto;">
      ...
      </table>

      what this does is it makes the top and bottom margin 0, and sets the left and right to whatever is left. Thus you get a centered div or image or whatever.

      Comment

      • C CSR
        New Member
        • Jan 2012
        • 144

        #4
        Okay. You caught me. Thanks for the "wake up!"

        Comment

        Working...