Jessica Posted January 26, 2007 Share Posted January 26, 2007 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>? Quote Link to comment https://forums.phpfreaks.com/topic/35878-css-equivalent-of-cellspacing0/ Share on other sites More sharing options...
obsidian Posted January 26, 2007 Share Posted January 26, 2007 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. Quote Link to comment https://forums.phpfreaks.com/topic/35878-css-equivalent-of-cellspacing0/#findComment-170103 Share on other sites More sharing options...
Jessica Posted January 26, 2007 Author Share Posted January 26, 2007 Thanks obsidian. That's what I do now, just the cellspacing part, since the rest can be controlled via CSS.If anyone knows of anything besides JS, please share ;) Quote Link to comment https://forums.phpfreaks.com/topic/35878-css-equivalent-of-cellspacing0/#findComment-170108 Share on other sites More sharing options...
bibby Posted January 28, 2007 Share Posted January 28, 2007 jesirose, look at border-spacing andborder-collapse .[url=http://www.w3.org/TR/REC-CSS2/tables.html#separated-borders]http://www.w3.org/TR/REC-CSS2/tables.html#separated-borders[/url] Quote Link to comment https://forums.phpfreaks.com/topic/35878-css-equivalent-of-cellspacing0/#findComment-170900 Share on other sites More sharing options...
lando Posted February 1, 2007 Share Posted February 1, 2007 IE does not support border-spacing and border-collapse... Quote Link to comment https://forums.phpfreaks.com/topic/35878-css-equivalent-of-cellspacing0/#findComment-174982 Share on other sites More sharing options...
jcombs_31 Posted February 2, 2007 Share Posted February 2, 2007 As far as I know you just have to set it in the table declaration. I usually like a 1px space however and have only changed it on rare occasion. Quote Link to comment https://forums.phpfreaks.com/topic/35878-css-equivalent-of-cellspacing0/#findComment-175647 Share on other sites More sharing options...
neylitalo Posted February 4, 2007 Share Posted February 4, 2007 You might be able to use something like[code]table{ border-collapse:collapse;}[/code]I believe border-collapse:collapse; forces cells to share borders. Quote Link to comment https://forums.phpfreaks.com/topic/35878-css-equivalent-of-cellspacing0/#findComment-176940 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.