[thelist] Using CSS to disable table tag's cellspacing attribute

Sarah Adams sarahwbs at gmail.com
Fri Feb 27 12:55:32 CST 2009


> Here's what I tried:
> <script type="text/javascript">
> document.getElementsByTagName('table').removeAttribute('cellspacing');
> </script>
> 
> ...and also your code below, but couldn't get either to work. 
> 
> There's no class name for the table, so I'm not sure I could target it using
> your method, which seems much simpler.

You'll need to explicitly loop through all of the tables, like this:

tables = document.getElementsByTagName('table');
for (i = 0; i < tables.length; ++i) {
  table = tables[i];
  table.removeAttribute('cellspacing');
}

Another option would be to set the cellspacing to 0 rather than removing it.

HTH

-- 
sarah adams
my son: http://clarkeadams.com
twitter: http://twitter.com/sarahwbs
portfolio: http://sarah.designshift.com



More information about the thelist mailing list