Forum Moderators: not2easy

Message Too Old, No Replies

Controlling table borders with CSS

         

FeStEr

12:54 pm on Jul 1, 2004 (gmt 0)

10+ Year Member



Hello I thought you lot may be able to help me, you seem full of information :)

I'm new to these forums and also to CSS.

Basically I have the task of building a website for someone. I stated off with just tables, but had a few layout problems so I ventured into the world of css (thinking that would be more controllable). But this didn't go well either and had big problems getting it to be cross browser compatible between IE and FF.

With that I've now gone back to tables again but I want to add a 1px border around the outside of the table, without it being applied to every cell. I'm guessing I can control this with css styles, but I really haven't got a clue where to start and I can't find anything on the web to tell me how to do it.

Any help would be much appreciated :)

fest.

Old_Honky

1:32 pm on Jul 1, 2004 (gmt 0)

10+ Year Member Top Contributors Of The Month



In the stylesheet add

table{
border: 1px solid #000;
}

This gives you a black one pixel border around every table. If you want to use other tables without a border then define it as a class eg.

.bordered{
border: 1px solid #000;
}

Then in the opening tag of your table write

<table class="bordered">

MWpro

1:34 pm on Jul 1, 2004 (gmt 0)

10+ Year Member



The style that you want is: "border: 1px solid #color;"

You can either make that a class or just do something like this

<table style="border: 1px solid #color;">

FeStEr

1:48 pm on Jul 1, 2004 (gmt 0)

10+ Year Member



Cheers thats brilliant, it works :)

I have just one more question and then I'm done...

How would I get a border to go along just one side of a cell within a table? For example, I have the table split into 5 rows. How do I get a border to just go along the top of the middle cell, so that there would appear to be a line going through the middle?

I'm thinking it might not be possible?

thanxs fest.

Old_Honky

1:58 pm on Jul 1, 2004 (gmt 0)

10+ Year Member Top Contributors Of The Month



create a class

.topborder{
border-top: 1px solid #000;
}

then apply that class to all the cells above which you want a line eg.

<td class="topborder">

FeStEr

2:44 pm on Jul 1, 2004 (gmt 0)

10+ Year Member



Thank you very much, it works a treat :)

I can go onto adding the content now.