Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

CSS file with cellspacing property for table ?

Status
Not open for further replies.

777axa

Technical User
Jul 30, 2002
48
US
How to create stand-alone CSS file with the properties for the table SIMILAR to cellspacing & cellpadding?
Someone recommended margin:0; padding:0; but it doesn't work!
I'd like to be able to control cellspacing & cellpadding for all the tables in my project from one place.

Thanks
 
Hi 777axa,
Presumably you know how to link a stylesheet, so in the style sheet all you need to do is specify which of the following you require:

td {padding-left:*px; padding-right:*px; padding-top:*px; padding-bottom:*px;}

(where * is your unit)

Or you can do it all in one by doing
td {padding: 1.5cm}

That will apply to all your cells on the page.
Hope that helps

Pete
 
In my experience setting padding and margins on table cells doesn't work...
Code:
<html>
<head>
<style>
td{
	border:1px solid #000000;/* So we can see cells*/
	padding:50px;/* enough to be obvious*/
	margin:5px;/*to replace cellspacing*/
}
</style>
</head>
<body>
<table cellspacing=&quot;0&quot; cellpadding=&quot;0&quot;>
<tr>
<td>cell 1L</td>
<td>cell 1R</td>
</tr>
<tr>
<td>cell 2L</td>
<td>cell 2R</td>
</tr>
</table>
</body>
</html>

Am I doing something consistently wrong, or is my take on this correct?

-Tarwn Experts are only people who have realized how much they will never know about a language.
________________________________________________________________________________
Want to get great answers to your Tek-Tips questions? Have a look at faq333-2924
 
Hi Tarwn
The padding definately works on IE4 anyway (thats all i have at work), altering the value will see more space either side between the text and the border as you would with cellpadding.
As for the margin, i think this only applies to text, i.e the <p> tags etc, and using it as such in the table cells would just have the same effect as the padding. I'm not sure exactly how you would emulate the cellspacing. There is 'border-spacing' (which works along side 'border-collapse') for IE5 but i dont know if it works in the same way.
I'd like to know this myself so any more help?

Pete
 
Thank you Sheltered,
td {padding-left:*px; padding-right:*px; padding-top:*px; padding-bottom:*px;}
- doesn't work for me for some reason

I'm trying to create a stand-alone CSS file for managing all the tables in the solution I generate in CodeCharge ASP project. All the tables have default settings and there are hundreds of them (tables).
Changing them all in Dreamweaver is not my &quot;dream job&quot;.
I think that I'll write a script which will search for <table> tag in all pages and insert into it cellspacing & cellpadding with the values I supply.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top