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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

CSS and Tables

Status
Not open for further replies.

jchastai

Programmer
Oct 11, 2001
31
US
How do I do the following HTML tag in CSS?

<TABLE BORDER=0 CELLPADDING=0 CELLSPACING=0>

---
If I setup my style sheet as follows ...

TABLE
{
border: 0px;
margin-bottom: 0px;
margin-left: 0px;
margin-right: 0px;
margin-top: 0px;
padding-bottom: 0px;
padding-left: 0px;
padding-right: 0px;
padding-top: 0px;
}

I am not getting a border, but I still have padding around the table and cells.

Slightly different, how do I setup the following HTML using CSS ...

<TABLE BGCOLOR=#0000FF BORDER=0 CELLPADDING=0 CELLSPACING=1>

... which gives me a one pixel, solid border around both the table and each cell?


Thanks
Jeff Chastain
 
That border comes from the background showing thru the cellspacing. frame-box produces same effect with borders only.

why don't you give every cell a border?

[bb]
 
For the first question try

TABLE { border-collapse: collapse;
etc
}

For the second part
to specify background colour just add

background: #0000FF

Not sure about cell spacing, if you set the code (margins + padding) as you have above for TD as opposed to TABLE then you will get some cell spacing but no padding outside. Try it and see how you get on.

cya
É enzo@endamcg.com
 
Hi jchastai,
this is what I can suggest you:

Try to assign this class:
.nogap { padding: 0px; margin: 0px; border: solid #0000FF 1px; }

to a table: <table class=nogap>

Also create several classes (or IDs - it doesn't matter):

#noleft { border-left: none}
#yesright { border-right: solid #0000FF 1px;}

and assign them to aproppriate table cells:
<td id=noleft> or <td id=yesright>

IDs are better here because you can combine them with classes: <td class=... id=...>

They are necessary to avoid extra borders for table cells (very left and very right ones). Probably you'll have to add padding: 0px; margin: 0px; to it - it depends how you'll apply them.

Now you'll have to play a while to combine these classes and IDs applying them to tables/cells to get the result you need. It will take some time, but it really worth it - you'll see many interesting things!

It will work fine in Opera 5+, N6, IE5+, but will probably not work (or work not correctly) in NN4.x

good luck
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top