Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4

Thread: table padding

  1. #1
    Regular Coder
    Join Date
    May 2004
    Posts
    391
    Thanks
    76
    Thanked 0 Times in 0 Posts

    table padding

    How do I set padding around the outside of a table on all four sides. I ried the below with my css with no luck.

    padding: 10px;

  • #2
    Master Coder Excavator's Avatar
    Join Date
    Dec 2006
    Location
    Alaska
    Posts
    9,675
    Thanks
    22
    Thanked 1,827 Times in 1,811 Posts
    Hello nikko50,
    I'm not much for tables so I'm sure someone else here knows better than I...
    Just taking a guess though, I'd say you need to use either a margin or a border instead of padding.

    CSS Margin Properties
    The CSS margin properties define the space around elements.
    http://www.w3schools.com/css/css_margin.asp

    CSS Padding Properties
    The CSS padding properties define the space between the element border and the element content.
    http://www.w3schools.com/css/css_padding.asp
    Validate often DURING development - Use it like a splelchecker | Debug during Development |Write it for FireFox, ignore IE
    Use the right DocType | Validate your markup | Validate your CSS | Why validating is good | Why tables are bad

  • #3
    Senior Coder Arbitrator's Avatar
    Join Date
    Mar 2006
    Location
    Splendora, Texas, United States of America
    Posts
    3,338
    Thanks
    29
    Thanked 282 Times in 276 Posts
    In the separated borders model (border-collapse: separate), Internet Explorer does not treat table padding correctly. Firefox and Opera will add the padding but Internet Explorer will not.

    In the collapsed borders model (border-collapse: collapse), the table element doesn’t exhibit padding. Firefox and Internet Explorer get this right, but Opera puts the combined left and right padding to the right of the table for some reason.

    If you need this effect, you may find it more reliable to put the table element into a div element and apply the border to the div instead.

    Test Document:
    Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
      "http://www.w3.org/TR/html4/strict.dtd">
    
    <html lang="en-US">
      <head>
    
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <meta name="Author" content="Patrick Garies">
        <title>CF 106927 Table Padding</title>
    
        <style type="text/css">
          * { margin: 0; }
          html { padding: 1em; }
          table, td { border: 1px solid; }
          table { margin: 0 auto; padding: 1em; background-color: #eee; }
          table#separated { border-collapse: separate; /* default */ }
          table#collapsed { border-collapse: collapse; }
        </style>
    
      </head>
      <body>
    
        <table id="separated">
          <tr>
            <td>Cell 1</td>
            <td>Cell 2</td>
            <td>Cell 3</td>
          </tr>
          <tr>
            <td>Cell 4</td>
            <td>Cell 5</td>
            <td>Cell 6</td>
          </tr>
          <tr>
            <td>Cell 7</td>
            <td>Cell 8</td>
            <td>Cell 9</td>
          </tr>
        </table>
    
        <table id="collapsed">
          <tr>
            <td>Cell 1</td>
            <td>Cell 2</td>
            <td>Cell 3</td>
          </tr>
          <tr>
            <td>Cell 4</td>
            <td>Cell 5</td>
            <td>Cell 6</td>
          </tr>
          <tr>
            <td>Cell 7</td>
            <td>Cell 8</td>
            <td>Cell 9</td>
          </tr>
        </table>
    
      </body>
    </html>
    For every complex problem, there is an answer that is clear, simple, and wrong.

  • #4
    Regular Coder
    Join Date
    Sep 2004
    Posts
    230
    Thanks
    1
    Thanked 0 Times in 0 Posts
    box model states that:
    padding occurs INSIDE the border...
    margins occur OUTSIDE the border...
    IF I DID GOOD THROW ME A REP POINT


  •  

    Posting Permissions

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