1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

How to center a table in a post

Discussion in 'WordPress' started by mpak11, Apr 25, 2011.

  1. #1
    So if you have a table code like the ones below in wordpress, how do you center it in the post? because by default they are left aligned, I want them in the center...what code should I add to do that?
    thanks in advance!


    <table>
    <tbody>
    <tr>
    <td> 1</td>
    <td>1</td>
    <td>1</td>
    </tr>

    <tr>
    <td>2</td>
    <td>2</td>
    <td> 2</td>
    </tr>
    </tbody>
    </table>
     
    mpak11, Apr 25, 2011 IP
  2. ayekaye01

    ayekaye01 Peon

    Messages:
    214
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    hi!

    try this,

    <table align="center">
    <tbody>
    <tr>
    <td> 1</td>
    <td>1</td>
    <td>1</td>
    </tr>

    <tr>
    <td>2</td>
    <td>2</td>
    <td> 2</td>
    </tr>
    </tbody>
    </table>

    hope this one will help you!
     
    ayekaye01, Apr 26, 2011 IP
  3. brandon93s

    brandon93s Active Member

    Messages:
    798
    Likes Received:
    12
    Best Answers:
    0
    Trophy Points:
    85
    #3
    Get used to CSS. IF you have a CSS document, add this:

    table
    { 
    margin-left: auto;
    margin-right: auto;
    }
    Code (markup):
    It tells the browser to load the table tag with the left and right margins set to auto, which will make them equal, and thus center your table.
     
    brandon93s, Apr 26, 2011 IP
  4. deepesh2002

    deepesh2002 Peon

    Messages:
    24
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    both post are correct you can do with editing html or css.. your choice...
     
    deepesh2002, Apr 26, 2011 IP
  5. joshuthomas

    joshuthomas Well-Known Member

    Messages:
    595
    Likes Received:
    9
    Best Answers:
    1
    Trophy Points:
    140
    #5
    Basically identify what you want to center and go to the HTML mode of the new post window in wordpress and use the below code:

    replace the "content to center" with the stuff you want to center.

    cheers
    Josh
     
    joshuthomas, Apr 26, 2011 IP
  6. brandon93s

    brandon93s Active Member

    Messages:
    798
    Likes Received:
    12
    Best Answers:
    0
    Trophy Points:
    85
    #6
    Assuming you'd want all tables centered and not just this one, the CSS fix will automatically center them all in the future without having to add any additional code.
     
    brandon93s, Apr 26, 2011 IP