Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Positioning elements with tables

Status
Not open for further replies.

MikeMCSD

MIS
Jul 12, 2002
107
US
As I analyze web pages I notice that Tables are used for positioning, but vary from page to page in the way they are used.
Ex. 1 Is it better to use 100% (for the main table, like this page) for the width of the page instead of a fixed length like 820? I prefer 100% because it will expand to fit in the browser.

Ex. 2 How do you know to use another <table> instead of another <tr><td>? Is it a matter of style? There are some pages that use a lot of tables inside other tables. Is there such a thing as too many tables? You also have the situation where you have a table, then a <td> and a table inside that cell, then another table, <td> . . . etc. Some of these pages nest the <table> and <td> tags so deep that it is sometimes hard to find the beginning and ending tags.

Are they any basic rules that are considered good practice when using tables?
I would be interested in anyone’s comments.
 
Well, the orthodox answer would be that you shouldn't use tables AT ALL for layout - but use CSS positioning instead. Plenty of articles on this, try for starters.

However, here in the real world, many people - myself included - still find tables convenient for some layout tasks. To address your points in detail:

Ex 1. Whatever suits you. The thinking behind fixed-width sites is (in part) that text is easier to read if you limit how wide the column can be. Personally I prefer a &quot;liquid&quot; layout for my sites.

Ex 2. My advice would be to go for as few (levels of) tables as possible - it's easier for you to maintain and easier for the browser to render. In the bad old pre-css days there were lots of things we used tables for that we can do more easily now - want to put a block on your page with a different background colour? Don't use a one-cell table, just use a <div> with some different styling. You can also use css to vary the border and backgrounds on a per-cell basis, rather than resorting to a nested table.

-- Chris Hunt
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top