margins in a table cell

They have: 42 posts

Joined: Dec 2002

Is there some kind of margin code for an individual table cell. The only thing I can think to use is blockquote tags within the cell but that is kind of hacking it.

Also, cellpadding and cellspacing will not work in this situation as it will wreck the rest of the layout.

Megan's picture

She has: 11,421 posts

Joined: Jun 1999

You can just use CSS to add padding to the cell individually, but that messes with the other cells in the table row (try it and see). Might be best to add margins to a div instide the table cell, or to the paragraphs.

They have: 42 posts

Joined: Dec 2002

Ok thanks Megan. One problem, I have no clue how to use CSS. Does that top code go at the start of the page?

Megan's picture

She has: 11,421 posts

Joined: Jun 1999

Sorry, I changed my answer because what I posted just didn't quite work right. It would be better to use div inside the td, I think. That's what I've done in the past, anyway. You should really learn a little bit of CSS - w3schools.com has a good tutorial.

Edit: Like this

<td><div style="margin: 5px;">......

</div></td>
'

Wait! I was wrong. You should be able to just apply the padding to the table cell using. Try that.

Busy's picture

He has: 6,151 posts

Joined: May 2001

different browsers use padding and margin differently, so would be best to use both margin:5px; padding:5px; (adjust to suit).

if you run into problems with the display not going where it should, try wrap the table in a set of empty table tags

They have: 42 posts

Joined: Dec 2002

Thank you both. I ended up using <div style="margin: 20px; padding=:20px;">'

I've been meaning to learn CSS, but right now I am far too busy learning advanced PHP. I'll likely pick up a book, I find it easiest to learn from them.

mairving's picture

They have: 2,256 posts

Joined: Feb 2001

Download a free copy of TopStyle Light . It will teach you quite a bit about css. It is also helpful to look at other stylesheets.

dk01's picture

He has: 516 posts

Joined: Mar 2002

Quote:

That's incorrect. Although it may work in IE (since it debugs everything).

Try this instead:

Should look the same.
-dk

Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.