Click to See Complete Forum and Search --> : How do I get a square around a table?
jammer20002
10-14-2003, 10:35 AM
Can someone tell me how I can get a square around a table?
I just can't figure it out!
I saw this simple website: http://www.physiotherapy-specialists.co.uk/
I had a look at the code... and I'm still lost.
They seem to use a tiny gif...
But... I can't figure out how they get the lines?
Any help would be aprpeciated.
Thanks.
Jam
Easily done with CSS:
<table style="border: 1px solid black;">
<tr>
<td>Row One, Cell One</td>
<td>Row One, Cell Two</td>
</tr>
<tr>
<td>Row Two, Cell One</td>
<td>Row Two, Cell Two</td>
</tr>
</table>
Daria
10-14-2003, 11:01 AM
They used a nested table - the outer table has a black (#000000) background, and it has a padding of 1 px. The tiny gif you are thinking of (media/images/pix.gif) is actually a 1x1 px spacer (not relevant to what you are looking for)
Here is a stripped code for tables, so you can see better how they achieved it.
<table width="750" bgcolor="#000000" border="0" cellpadding="1" cellspacing="0">
<tr>
<td>
<table width="748" bgcolor="#ffffff" border="0" cellpadding="0" cellspacing="0">
<tr>
<td></td>
</tr>
</table>
---------------------------
CSS is a much better choice, though, just as pyro suggested.
jammer20002
10-14-2003, 12:06 PM
Thanks for the replies.
I think I'll use CSS.
But...
I was sure u had made a mistake in your coding...
But it seems not.
What is a nested table?
(Em.. I've never come accross it.) :)
A nested table is a table inside of a table. Generally a bad idea.
<table>
<tr>
<td>
<table>
<tr>
<td>blah</td>
</tr>
</table>
</td>
</tr>
</table>
jammer20002
10-14-2003, 12:37 PM
I still don't get it.
Look at Daria's code.
Is it right?
Surely there has to be an errorin there?
Using nested tables, I can't get a line width to be as fine as what I get from Daria's example.
I'm confused.
:(
jammer20002
10-14-2003, 12:38 PM
And why are nested tables frowned on?
I use them all the time.
(Though I didn't know I was using nested tables.) :)
Because you should be using CSS to format your pages... Also, yes, the code that Daria posted [I assume from the site you posted] will work (once you close the open tags) but it is the "suicide" way of doing it... ;)
IncaWarrior
10-14-2003, 09:00 PM
it'll work fine, but all those blind people on palm pilots won't be able to see it (oh and it's just a bad idea to have tables nested 4 deep)
nkaisare
10-14-2003, 10:01 PM
Reasons why nested tables are bad:
1. Usually not search engine friendly
2. Totally ignore other browsers (palm pilot, screen readers etc)
3. Bloated content (CSS-based layout can save 35 to 50% on bandwidth)
4. Difficult to maintain due to the complexity posed by nesting the tables.
In this example, why would you nest tables when
table {border: 1px solid #000}
accomplishes the same task much more easily?
Robert Wellock
10-15-2003, 04:44 AM
Yes, nested tables within XHTML Basic 1.0 are illegal by default for a good reason. Furthermore they don't work too well when linearized.