Forum Moderators: not2easy

Message Too Old, No Replies

css tables

trivial question

         

ktwilight

2:43 am on Jun 30, 2004 (gmt 0)

10+ Year Member



i've come across this 'problem' while updating my personal site. consider this code

<table width=100% border=0>
<tr><td colspan="2">title description</td></tr>
<tr><td style="width:70%">foo</td><td>bar</td>
</table>

my question is, only one <td> is assigned a width...will the rest of <td>s lay accordingly? i.e. will the page be displayed as

<tr><td colspan="2" width="100%">title description</td></tr>
<tr><td style="width:70%">foo</td><td style="width:30%">bar</td>

i'm trying to cut down the number of bytes, and thought this might work. i've tested on FF, and it does seem to work well. but...is this the correct way? or is it even right to do so?

D_Blackwell

3:58 am on Jun 30, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



table {
width: is the biggie. It determines the width of the entire table.

In the second example, the width of your top row will be 100%; but 100% of what? Move the 100% to <table>, as in the first example, and the two examples will display identically.

For the second row of the second example, you only need to give the width for one of the two cells. The other will be calculated automatically.

ktwilight

4:43 pm on Jul 4, 2004 (gmt 0)

10+ Year Member



Thanks for correcting me! I was really thinking when I wrote that out. lol
you only need to give the width for one of the two cells. The other will be calculated automatically.

That's exactly what I'm looking for. Thanks!

Time to cut down the bytes. :D

createErrorMsg

7:56 pm on Jul 4, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



If you move all that stuff (widths, etc) into a stylesheet it cuts down on your page size even more. Browsers cache the stylesheet when your first page is loaded, which means subsequent pages using the same external stylesheet don't have to download it at all.

Is it a whopping difference? Probably not, but if you're looking to trim it down you may as well go all the way...

D_Blackwell

8:04 pm on Jul 4, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



It takes a ton of text to make much difference. Watch the images. Just one can easily be bigger than your whole page.

ktwilight

7:43 pm on Jul 5, 2004 (gmt 0)

10+ Year Member



True enough. I just like everything trimmed down to the minimum at my best knowledge. And since the my site uses the same stylesheet throughout, it's perfect.

Thanks again! :D