Jump to content

cellpadding & cellspacing


skym

Recommended Posts

table {padding: value;border-collapse: collapse/separate; /* if separate, declare border-spacing as well */border-spacing: length length; /* horizontal spacing and vertical spacing */}http://www.w3schools.com/css/css_reference.asp#table:)

Link to comment
Share on other sites

Thanks for the answer.

<html><head><style>table {border: 1px solid #000000;}td {border: 1px solid #ff0000;padding: 0px;}table.one {/*padding: 0px;*/border-collapse: collapse;}</style></head><body><table class="one"><tr><td>1</td><td>2</td></tr></table><br><table cellpadding="0" cellspacing="0"><tr><td>1</td><td>2</td></tr></table></body></html>

Still the result is not the same as for the cellpadding&cellspacing, in IE the border-collapse: collapse; makes the <td> borders to dissapear, and in FF it makes the <table> border to dissapear. With cellpadding&cellspacing all borders are still in place.

Link to comment
Share on other sites

Border-collapse: collapse; is apparently not the same as cellspacing="0", no. You'll have to use border-collapse: separate; with border-spacing: 0 0;

<html><head><style>table {border: 1px solid #000000;}td {border: 1px solid #ff0000;padding: 0;}table.one {padding: 0;border-collapse: separate;border-spacing: 0 0;}</style></head><body><table class="one"><tr><td>1</td><td>2</td></tr></table><br><table cellpadding="0" cellspacing="0"><tr><td>1</td><td>2</td></tr></table></body></html>

That should give you the same result in Firefox and Opera, but not in IE, because IE quite frankly has lousy CSS 2.1 support at best. IE7 will have better CSS 2.1 support, but until then, I don't know if it's possible to get the same result in IE with css and html attributes. To be honest, I don't know that much about table formatting with css, because I seldom use tables when making sites. I use div's for layout, and have rarely use for displaying tabular data.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...