Home  /  Questions  /  Question



121   96.7
May 10, 2013


How to set table cellspacing="0" and cellpadding="0" in CSS?

When I code a table with cellpadding and cellspacing in Visual Studio 2012 I get red squiggly underlines. 

<table cellpadding="0" cellspacing="0" border="0">
  <tr> ... </tr>
  <tr> ... </tr>
  <tr> ... </tr>
</table>

So, clearly it wants me to move these settings to CSS. But what do I put there?
I don't think padding:0px and spacing:0px will do the job. 

Thanks,
Des



50   50
Jun 28, 2013
Des,

Here's the CSS that will achieve what you need.

 2 comments
 
table, tr, th, td { border-collapse:collapse; border:none; } th, td { padding: 0; /* Use of px not necessary */ } --- Norman Bell  Jun 28, 2013
 
Sorry, see the CSS in the comments. --- Norman Bell  Jun 28, 2013