473,513 Members | 2,505 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Borders For Tables Hack

I've been trying to figure out a good way to make a CSS layout with
nice-looking 1-pixel borders around the table cells.

The only broadly compatible way to do this I know of is to have

* the border of the table set to zero
* the cellspacing of the table set to one
* the background color set to black
* the table cell background color set to white

which looks nice in most modern browsers.

However in Netscape four, the table has no borders at all, making it a
little awkward for users to understand columns, rows etc.

So here's my workaround:

<html>
<head>
<style type="text/css" >
table
{
background: black;
border-width: 0px;
border-style: none;
}
td
{
background: white;
}
</style>
</head>
<body>
<table border="1" bordercolor="#ffffff" cellspacing="1"
cellpadding="5">
<tr>
<td> blah </td>
<td> blah </td>
<td> blah </td>
</tr>
</table>
</body>
</html>

This is kind of a hack, but it means that IE sees one-pixel borders
and Netscape four and older see old-fashioned raised-type gray
borders.

It doesn't look so great in Netscape 7/Mozilla though, because they
don't recognise the bordercolor thing.

Also, bordercolor is not valid HTML.

Does anyone know a good way to achieve 1-pixel borders which works in
Netscape 4 and recent CSS-compatible browsers? I'd be interested to
see any other approaches -- I've been juggling different style sheets
and HTML combinations for a while now...

The only other way I know is the way they do it at Salon, which
involves lots of empty table cells with spacers in them and that's
just overkill.
Jul 20 '05 #1
2 3445
DU
Hostile17 wrote:
I've been trying to figure out a good way to make a CSS layout with
nice-looking 1-pixel borders around the table cells.

The only broadly compatible way to do this I know of is to have

* the border of the table set to zero
* the cellspacing of the table set to one
* the background color set to black
* the table cell background color set to white

which looks nice in most modern browsers.

However in Netscape four, the table has no borders at all, making it a
little awkward for users to understand columns, rows etc.

So here's my workaround:

<html>
<head>
<style type="text/css" >
table
{
background: black;
border-width: 0px;
border-style: none;
}
td
{
background: white;
}
</style>
</head>
<body>
<table border="1" bordercolor="#ffffff" cellspacing="1"
cellpadding="5">
<tr>
<td> blah </td>
<td> blah </td>
<td> blah </td>
</tr>
</table>
</body>
</html>

This is kind of a hack, but it means that IE sees one-pixel borders
and Netscape four and older see old-fashioned raised-type gray
borders.

It doesn't look so great in Netscape 7/Mozilla though, because they
don't recognise the bordercolor thing.

Also, bordercolor is not valid HTML.

Does anyone know a good way to achieve 1-pixel borders which works in
Netscape 4 and recent CSS-compatible browsers? I'd be interested to
see any other approaches -- I've been juggling different style sheets
and HTML combinations for a while now...

The only other way I know is the way they do it at Salon, which
involves lots of empty table cells with spacers in them and that's
just overkill.


The nr 1 problem with your request is NS 4.x. People are switching to NS
7.1 or to Mozilla-Firebird you know and a large majority of them are not
reverting back. Trying to control layout and rendering on old and
non-compliant browsers is a bad idea. As long as content is accessible
on such old and non-compliant browsers, I do not recommend trying to do
anything more.

FWIW, Dynamic table formatting for DOM 1 browsers:
http://www10.brinkster.com/doctorunc...ormatting.html

DU
--
Javascript and Browser bugs:
http://www10.brinkster.com/doctorunclear/
- Resources, help and tips for Netscape 7.x users and Composer
- Interactive demos on Popup windows, music (audio/midi) in Netscape 7.x
http://www10.brinkster.com/doctorunc...e7Section.html

Jul 20 '05 #2
Hostile17 wrote:
I've been trying to figure out a good way to make a CSS layout with
nice-looking 1-pixel borders around the table cells.

The only broadly compatible way to do this I know of is to have

* the border of the table set to zero
* the cellspacing of the table set to one
* the background color set to black
* the table cell background color set to white

How about:

table { border-collapse: collapse; }
th, td { border: 1px solid black; }

However in Netscape four


Hmm, did you say Netscape 4... that's no fun.
Jul 20 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
3454
by: Hostile17 | last post by:
I've been trying to figure out a good way to make a CSS layout with nice-looking 1-pixel borders around the table cells. The only broadly compatible way to do this I know of is to have * the...
7
5088
by: Stan Brown | last post by:
http://www.acad.sunytccc.edu/instruct/sbrown/stat04/qz05_.htm A table comes near the beginning of the page. I have the <td> of row 1 column 1 styled in line with border-top:none and...
0
2398
by: Phil Evans | last post by:
URL: http://philevans.com/tabletest.html A boring table, but one which illustrates my problem. I'm writing a large PHP app which outputs data tables. Users of the app can configure their...
4
1932
by: NeverLift | last post by:
I've searched around and don't find the following incident discussed specifically. First, a comment from an experience programmer new to JavaScript: While I am new to javascript, I've...
4
8914
by: Konrad Viltersten | last post by:
As it isnow i have to use a syntax for my tables as: <table class = "some" border> and/or <table class = "some" noborder> Now, what i'd like to do is to make that border-thingy...
32
2690
by: Simon Dean | last post by:
Duh... Not another one... Hopefully simple though, I hate the way *I* (and it might be a CSS trait) can't intermix fixed width divisional elements with a variable auto expanding div??? The...
9
2918
by: Michael Redbourn | last post by:
Hi, I just switched from FP to DW and am very very happy ! So whilst I'm mastering Dreamweaver (gonna be a while yet :-) - I thought that I'd try and find out how to add borders for browers...
0
1573
by: LStewart | last post by:
Hi Guys, I am having some trouble with some tables. What I want to do is make it so that the table prints out on paper with the table borders. The borders are there on the web page in the...
0
1743
by: Fonix | last post by:
I'm trying to make table border with pyExcelerator. As i can see there is only cell formating!? If i'm wrong pls tell me what is method to make more then one cell to have same format, other then...
1
3405
by: jacob navia | last post by:
Everybody knows that hash tables are fast. What is less known is that perfect hash tables are even faster. A perfect hash table has a hash function and a table layout that avoids collisions...
0
7260
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7384
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7539
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
7101
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
5686
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5089
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4746
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3222
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1596
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.