1

Possible Duplicate:
Why not use tables for layout in HTML?

i know that using tables as layout is a big problem..Why don’t professional web designers use tables for layout anymore? and what are the alternatives in CSS that i can use and will be the best alternative to tables??

Community
  • 1
  • 1
Anyname Donotcare
  • 11,113
  • 66
  • 219
  • 392

4 Answers4

5

1) as soon as a browser sees an opening table tag, it will stop rendering until it sees the closing tag, since it has no way of even guessing what the table structure will look like. Because of that, tables will dramatically increase the wait time between when the user starts the request, and when they can actually use your page.

2) tables require 3 nested tags to define a cell, which is a hell of a lot of noise in an already incredibly verbose language (xml)

3) semantically, a table is for tabular data. using it for layout means your html doesn't make sense when you read it.

Matt Briggs
  • 41,224
  • 16
  • 95
  • 126
  • 1
    I'd just like to add that tables are **meant** for data, so they are perfectly accepted for displaying data. It is **only** layout for which (good) developers are against using them. An alternative is to use divs for layout - I, personally, found it hard to get the hang of div layouts, but once you get the hang of floats and clears they really are easy to make them do what you want. It is time well spent learning this technique in my opinion. It will hold you in good stead with other developers. – ClarkeyBoy Dec 15 '10 at 13:45
  • thank u so much ,, what the book u recommend to learn the Divs ,, i feel it is so hard to use rather than tables..it is so easy to use.. – Anyname Donotcare Dec 15 '10 at 13:49
  • 1
    Basically what I do is use a relative div with 2 - 3 nested divs which are set to `float: left` and have a width set. The width must sum up to less than 100%. Make sure you set the widths as otherwise they will be 100% by default. You then bung another nested div in which is set to `clear: both`. This makes the parent div wrap around the floated divs. If you want a div to align at the right hand side then use `float: right`. If you want to apply padding or margin to any of these nested divs, bung another div inside those with the padding / margin applied. Continued... – ClarkeyBoy Dec 15 '10 at 13:56
  • 1
    This is because the padding / margin / border is added to the width of the div. For example if you have two divs which add up to 100%, and you give them both padding, their actual widths will be the width you gave them **+** padding. Instead just apply the padding to a div inside those and it won't be added to the width of the floated divs. – ClarkeyBoy Dec 15 '10 at 13:57
  • 1
    @user418343: Unfortunately I learned css incrementally over the last 8 years or so, so I don't have a book for you. This looks like a beginners book though, and is very highly reviewed on amazon http://www.amazon.com/CSS-Missing-David-Sawyer-McFarland/dp/0596802447/ref=sr_1_1?ie=UTF8&qid=1292421543&sr=8-1 – Matt Briggs Dec 15 '10 at 14:00
  • 1
    After a quick Google I found these: http://css.maxdesign.com.au/floatutorial/; http://www.quirksmode.org/css/clearing.html; http://www.tizag.com/cssT/float.php. Not sure if they are any good - simply took several of the results from Googling "floats and clears" and "floats and clears tutorial". Hope this helps. – ClarkeyBoy Dec 15 '10 at 14:00
  • thank u so much this is really a great help.. – Anyname Donotcare Dec 16 '10 at 07:37
1
  1. Discussed here - Why not use tables for layout in HTML?

  2. CSS doesn't provide 'alternatives' to tables. It is used to style HTML elements including tables.

Community
  • 1
  • 1
dheerosaur
  • 14,736
  • 6
  • 30
  • 31
1

Try to learn using div tag and giving style to it using css..it has more effect in look

bharath
  • 141
  • 8
1

I would definitely suggest using CSS and XHTML to layout pages.

I think there are far too many benefits to go into here. Ranging from accessibility, SEO, ease of coding to future proofing. I think blog posts and articles on the subject will be able to provide more information on why and how you should use CSS instead of table to layout pages.

One book I would suggest is Web Standards Solutions: The Markup and Style Handbook by Dan Cederholm This book will tell you everything you need to know about using CSS and HTML in a web standards compliant way.

One thing to keep in mind is that HTML5 is starting to gain widespread usage there are a few differences and added features that differ from XHTML

splatio
  • 504
  • 4
  • 12