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.
Page 1 of 2 12 LastLast
Results 1 to 15 of 18
  1. #1
    Regular Coder
    Join Date
    Jan 2004
    Location
    USA
    Posts
    364
    Thanks
    12
    Thanked 6 Times in 6 Posts

    Question cellpadding in css?

    How do you adjust the cellpadding of a table in css? I've tried using:

    table {padding: 10px;...}

    but, it doesn't work

  • #2
    Regular Coder
    Join Date
    Jun 2002
    Location
    Victoria, BC, Canada
    Posts
    962
    Thanks
    0
    Thanked 1 Time in 1 Post
    You need to put the padding style on the cell, not the table

    table td {
    padding:10px;
    }

  • #3
    Senior Coder
    Join Date
    Jul 2002
    Posts
    1,628
    Thanks
    0
    Thanked 0 Times in 0 Posts
    cellpadding and cellspacing are valid.

    Moderator: General web building

    Get out from under them, resist and multiply.
    Get out from under precipice and see the sky.

  • #4
    Regular Coder
    Join Date
    Jan 2004
    Location
    USA
    Posts
    364
    Thanks
    12
    Thanked 6 Times in 6 Posts
    what exactly does adding the td to the css do? when i add it, the css on my page dissappears...

  • #5
    Senior Coder
    Join Date
    Aug 2002
    Location
    Kansas City, Kansas
    Posts
    1,518
    Thanks
    0
    Thanked 2 Times in 2 Posts
    Hmm... It shouldn't dissappear. What that td says is that for every table with a child td tag, give it a padding of 10px on all sides. Maybe if you show us your code we could help.

  • #6
    me'
    me' is offline
    Senior Coder
    Join Date
    Nov 2002
    Location
    Warwickshire, England
    Posts
    1,229
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Originally posted by cg9com
    cellpadding and cellspacing are valid.
    But are presentational markup.
    David House - Perfect is achieved, not when there is nothing left to add, but when there is nothing left to take away. (Antoine de St. Exupery).
    W3Schools | XHTML Validator | CSS Validator | Colours | Typography | HTML&CSS FAQ | Go get Mozilla Now | I blog!

  • #7
    Senior Coder
    Join Date
    Nov 2003
    Location
    Minneapolis, MN
    Posts
    2,879
    Thanks
    2
    Thanked 65 Times in 56 Posts
    Originally posted by me'
    But are presentational markup.
    I don't see where that's so bad, considering that a table, and tabular data as a whole, is presentational. Besides, it's going to take just as long to make any cell padding changes in the CSS as it is the HTML.

  • #8
    Regular Coder
    Join Date
    Jun 2002
    Location
    Sheffield, UK
    Posts
    552
    Thanks
    0
    Thanked 0 Times in 0 Posts
    i dont see how you can follow that at all.

    Tabular data is just that, tabular - it's in a table cause if you wrote it out in paragraphs it wouldn't make sense.

    and changing
    td {
    padding: 10px;
    }
    to
    td{
    padding: 7px;
    }
    once is a fair bit quicker than changing
    cellpadding="10" to cellpadding="7" on every single table you have.
    "To be successful in IT you don't need to know everything - just where to find it in under 30 seconds"

    (Me Me Me Me Me Me Me Me Me)

  • #9
    me'
    me' is offline
    Senior Coder
    Join Date
    Nov 2002
    Location
    Warwickshire, England
    Posts
    1,229
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Originally posted by rmedek
    I don't see where that's so bad, considering that a table, and tabular data as a whole, is presentational. Besides, it's going to take just as long to make any cell padding changes in the CSS as it is the HTML.
    That's an interesting proposition, but I would argue that <table> is a way of grouping elements that naturally occur together, and/or providing lists of values for certain variables. The fact that tradition says they should be laid out in rows and columns isn't relevant. They just as easily could be a list.
    David House - Perfect is achieved, not when there is nothing left to add, but when there is nothing left to take away. (Antoine de St. Exupery).
    W3Schools | XHTML Validator | CSS Validator | Colours | Typography | HTML&CSS FAQ | Go get Mozilla Now | I blog!

  • #10
    Senior Coder
    Join Date
    Jun 2002
    Location
    ColoRockyz
    Posts
    1,649
    Thanks
    1
    Thanked 0 Times in 0 Posts
    If the css is in an external sheet, it would be cached...and other table styles would display a bit quicker on other pages. I'm not political...but I vote css.
    Zoobie or not Zoobie...That is the problem.
    <body onUnload="flush( ! )">

  • #11
    Senior Coder
    Join Date
    Nov 2003
    Location
    Minneapolis, MN
    Posts
    2,879
    Thanks
    2
    Thanked 65 Times in 56 Posts
    Whew! I knew that would start something...

    ReadMe.txt (and me')- tabular data is presentational, by definition: a systematic arrangement of data into rows and columns (I got that here). The only time it would be in a list or another format is when the word is used more for a title (i.e., table of contents). And as far as changing padding for tons of tables, I would use CSS, too. But if I had only one? Well...

    Zoobie- I totally agree with you. In fact, I have one or two tables on my own website, and CSS controls every aspect of them.

    I think what you guys are misunderstanding is that I am all for CSS, and separation of style and content. But sometimes it seems as if the "letter of the law" is taken a little too strictly... things get more creative when you step out of the box every now and then.

    -Rich

  • #12
    Senior Coder
    Join Date
    Nov 2003
    Location
    Minneapolis, MN
    Posts
    2,879
    Thanks
    2
    Thanked 65 Times in 56 Posts
    Originally posted by me'
    That's an interesting proposition, but I would argue that <table> is a way of grouping elements that naturally occur together, and/or providing lists of values for certain variables. The fact that tradition says they should be laid out in rows and columns isn't relevant. They just as easily could be a list.
    So, are you saying lists could also just as easily be tables? Be careful, or you'll start a semantic revolution!

    -Rich

  • #13
    Regular Coder
    Join Date
    Jun 2002
    Location
    Sheffield, UK
    Posts
    552
    Thanks
    0
    Thanked 0 Times in 0 Posts
    tables are not presentational, they may seem that way - but you probably aren't using them properly.

    eg. non table:
    Code:
    <p>Name: ReadMe, Arguement: Tables are not presenational</p>
    <p>Name: me', Argument: Tables are not presentational, that they are laid out in columns is coincidental</p>
    <p>Name: rmedek, Arguement: Tables are a form of presentational data</p>
    Notice something? the 'headings' are repeated

    eg. tabular
    Code:
    <table>
      <tr>
        <th scope="column">Name</th>
        <th scope="column">Arguement</th>
      </tr>
      <tr>
        <td>ReadMe</td>
        <td>Tables are not presenational</td>
      </tr>
      <tr>
        <td>me'</td>
        <td>Tables are not presentational, that they are laid out in columns is coincidental</td>
      </tr>
      <tr>
        <td>rmedek</td>
        <td>Tables are a form of presentational data</td>
      </tr>
    </table>
    Now as you can see the headings are no longer repeated but are arranged in such a way that it can be seen what they apply to (scope attr) A visual user agent may choose to lay this out using rows and columns, but an aural user agent wont, it will read the tabular data out in the same way as the paragraphed version would.
    "To be successful in IT you don't need to know everything - just where to find it in under 30 seconds"

    (Me Me Me Me Me Me Me Me Me)

  • #14
    Senior Coder
    Join Date
    Nov 2003
    Location
    Minneapolis, MN
    Posts
    2,879
    Thanks
    2
    Thanked 65 Times in 56 Posts
    good point, but I think we're thinking along the same lines in a way.

    On my website, I use a table to display a list of dates I am playing. I could say this:

    "On January 24, I play with Grams and Krieger at the Old Pueblo. Then, on January 25, I play with Teddy Morgan at Janos."

    Instead, I thought this info was a perfect example of tabular data (data that could be displayed in an arrangement of rows and colums. Such as:

    Code:
    <table>
    <thead>
    <tr><th class="when">Date</th><th class="who">With</th><th>Location</th></tr>
    </thead>
    <tbody>
    <tr><td class="when">January 24</td><td class="who">Grams and Krieger</td><td>Old Pueblo Grille, Tucson, AZ</td></tr>
    <tr><td class="when">January 25</td><td class="who">Teddy Morgan</td><td>private party, Tucson, AZ</td></tr>
    </tbody>
    </table>
    (See, I used CSS ) So, I used a table to, um, present data.

    I don't think tables should be used as presentation, as in layout, or non-tabular data. But you can see why I think a table is, in itself, presentational.

    -Rich

  • #15
    Senior Coder
    Join Date
    Jun 2002
    Location
    The Netherlands, Baarn, Ut.
    Posts
    4,252
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Terminology

    I think you confuse presentation with structure; a table structures data in a tabular fashion. Presentation is about how it looks on the screen, or sounds out of a speaker. Cellpadding and -spacing have nothing to do with content or structure, only with presentation, and should therefore ideally be kept out of the document source itself. CSS would be the preferred route.

    Having said that, some think that there can never be full seperation of content / structure and presentation, since structure in many ways determines, or at least directs, how presentation affects the end result. But that's a different discussion altogether.
    Regards,
    Ronald.
    ronaldvanderwijden.com


  •  
    Page 1 of 2 12 LastLast

    Posting Permissions

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