Jump to content

CSS equivalent of cellspacing="0"?


Jessica

Recommended Posts

I know that in order to mimic the table property cellpadding="0" you can have this in your css:
[code]tr, td{
padding: 0;
margin: 0;
}[/code]

You'd think that the margin: 0 would make the cellspacing 0 as well. However, it doesn't. (Unless I seriously screwed something else up?)

Does anyone know of a CSS way to make a table have no cellspacing, so you don't have to put cellspacing="0" in every <table>?
Link to comment
Share on other sites

I've made it a practice to always have cellpadding="0" cellspacing="0" border="0" within the opening tag of every table I'm going to style. That way, I can do the styling from scratch, for the very reason you mentioned. That cellspacing thing really gets to me. I haven't found a way around it except for playing with the DOM and looping through every table and dynamically removing the cellspacing attribute, but that seemed kind of hokey to me.

In addition, one way I've gotten past some of the spacing issues and/or differences between FF and IE is to put the following at the top of my CSS pages:
[code]
* {
  margin: 0;
  padding: 0;
}
[/code]

This actually defaults every DOM element to 0 margin and padding and allows you to literally build your page up from scratch. IE still tends to render text slightly differently, but it gets rid of all the funny default padding on individual block elements.
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.