...

View Full Version : cellpadding in css?



qwertyuiop
01-25-2004, 01:45 AM
How do you adjust the cellpadding of a table in css? I've tried using:

table {padding: 10px;...}

but, it doesn't work

Grant Palin
01-25-2004, 02:22 AM
You need to put the padding style on the cell, not the table

table td {
padding:10px;
}

cg9com
01-25-2004, 02:24 AM
cellpadding and cellspacing are valid.

qwertyuiop
01-25-2004, 04:02 AM
what exactly does adding the td to the css do? when i add it, the css on my page dissappears... :confused:

Antoniohawk
01-25-2004, 07:18 AM
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.

me'
01-25-2004, 09:53 AM
Originally posted by cg9com
cellpadding and cellspacing are valid. But are presentational markup.

rmedek
01-25-2004, 12:55 PM
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.

ReadMe.txt
01-25-2004, 01:50 PM
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.

me'
01-25-2004, 02:50 PM
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.

zoobie
01-25-2004, 07:18 PM
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. :D

rmedek
01-25-2004, 10:06 PM
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 (http://www.m-w.com)). 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

rmedek
01-25-2004, 10:34 PM
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

ReadMe.txt
01-25-2004, 11:49 PM
tables are not presentational, they may seem that way - but you probably aren't using them properly.

eg. non table:


<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


<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.

rmedek
01-26-2004, 10:22 AM
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:


<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

ronaldb66
01-27-2004, 08:52 AM
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.

rmedek
01-27-2004, 09:43 AM
Structure and presentation

HTML distinguishes structural markup such as paragraphs and quotations from rendering idioms such as margins, fonts, colors, etc. How does this distinction affect tables? From the purist's point of view, the alignment of text within table cells and the borders between cells is a rendering issue, not one of structure. In practice, though, it is useful to group these with the structural information, as these features are highly portable from one application to the next. The HTML table model leaves most rendering information to associated style sheets. The model presented in this specification is designed to take advantage of such style sheets but not to require them.
... from www.w3c.org (http://www.w3.org/TR/html401/appendix/notes.html#notes-tables) . They kind of agree with all of us :)
I agree with everyone that CSS should be the way to go. But remember that the table model for HTML was heavily based on publishing tools (for magazines, desktop publishing, etc.) due to the extreme flexibility in layout. So I don't think using cellspacing or cellpadding-- occasionally-- is unjustifiable.

ronaldb66
01-27-2004, 12:31 PM
Looks like in the case of tables, seperating content from presentation is going to require brute force! :D

me'
01-27-2004, 06:20 PM
remedek said:
So, are you saying lists could also just as easily be tables? Be careful, or you'll start a semantic revolution! No, I'm claiming tables could be presented as lists.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum