Topic: table borders for each cell in css (Page 1 of 1) Pages that link to <a href="https://ozoneasylum.com/backlink?for=10866" title="Pages that link to Topic: table borders for each cell in css (Page 1 of 1)" rel="nofollow" >Topic: table borders for each cell in css <span class="small">(Page 1 of 1)</span>\

 
acidbox
Bipolar (III) Inmate

From: purgatory
Insane since: Mar 2001

posted posted 12-02-2002 23:44

Is there any way to specify that each cell have a border in the table tag of a CSS file? For instance, if i specify that a table have a 1px border in the css file, it only shows around the outer edges of the table. If I do a border=1 in the actual html table tag, it puts a border around each cell in the table. How can I do this in CSS?

Rooster
Bipolar (III) Inmate

From: the uterus
Insane since: Nov 2002

posted posted 12-02-2002 23:57

You need to specify that the actual cells have a border, like this...

TD {
border: 1px solid black;
}


..
~Existence is a mere pattern.~

acidbox
Bipolar (III) Inmate

From: purgatory
Insane since: Mar 2001

posted posted 12-03-2002 00:13

I tried doing that, but when you put a bunch of cells up against each other, it makes a 2px border instead of a 1px border.

brucew
Paranoid (IV) Inmate

From: North Coast of America
Insane since: Dec 2001

posted posted 12-03-2002 01:06

Add this to your CSS-- border-collapse: collapse;

I've found it works equally well on both table and td. I tend to put it on table just from force of habit. Doesn't work in Netscape 6 and other early Gecko browsers.

Rooster
Bipolar (III) Inmate

From: the uterus
Insane since: Nov 2002

posted posted 12-03-2002 02:40

If you only want a 1px border throughout the table you could do something like this....

TABLE {
border-left: 1px solid black;
border-top: 1px solid black;
}
TD {
border-right: 1px solid black;
border-bottom: 1px solid black;
}


..
~Existence is a mere pattern.~

[This message has been edited by Rooster (edited 12-03-2002).]

brucew
Paranoid (IV) Inmate

From: North Coast of America
Insane since: Dec 2001

posted posted 12-03-2002 04:28

Rooster: Have you actually looked at that CSS on a table? It gives a horrible illusion of what I think acidbox is looking for. The corners don't line up and the gaps between the cells show plain as day. Besides, even if it worked, it's an ugly, bloated kludge of a solution.

Trust me on this,

TABLE {
border: 1px solid #000;
border-collapse: collapse;
}
http://www.w3.org/TR/CSS2/tables.html#propdef-border-collapse

Simple, neat, effective and no embarassing gaps or overruns. Ask for it at your pharmacy by name.

Slime
Lunatic (VI) Mad Scientist

From: Massachusetts, USA
Insane since: Mar 2000

posted posted 12-03-2002 04:29

Brucew: While Rooster's solution requires a few more CSS properties or HTML attribute to close up the gaps you mentioned, I have seen it work and used it myself in the past. Nonetheless, you are right that border-collapse is the correct way to handle this.

Rooster
Bipolar (III) Inmate

From: the uterus
Insane since: Nov 2002

posted posted 12-03-2002 04:53

Hey, I'm just saying you ~could~ do that. Do whatever you think is best for the situation. I'm really not going to twist anyone's arm; I'm simply throwing out options. An option that could be made to work with earlier browser versions, as opposed to the "collapse" style which as you said is only implemented in later versions.

And yes, if your not trying to write code for earlier browser versions (< IE 5.0), "collapse" ~is~ the proper style to use.


..
~Existence is a mere pattern.~



Post Reply
 
Your User Name:
Your Password:
Login Options:
 
Your Text:
Loading...
Options:


« BackwardsOnwards »

Show Forum Drop Down Menu