954,598 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

A reason to use tables instead of divs

There is now a reason to use tables and css for layout, instead of divs and css.

Employers now prefer the table method. Our technical school instructors are now teaching this, instead of div and css.

Why?

Job performance!

It takes an average of four times as long to create a page using divs and css, compared to using tables and css. This is because the page author must fool around with the div settings until it works. The table always works the first time.

The employer prefers getting more pages per day, as opposed to getting pages that please the W3C.

Simple div structures work, but if the structure contains a list or a table, div messes it up. Then you have to play with height, width, margin, border, padding, and other properties, just to get the structure to hold together in all browsers.

As an example, I wanted to create a simple structure consisting of text on the left and a small table on the right, all surrounded by a border. I tried the following in sequence:

Making a surrounding div for the border:
- I could not get the table to go to the right and stay inside the border.
- It wanted to put the table under the text instead.

Make a surrounding div for the border, with two divs inside:
- The div for the border became small vertically, with both the text and the table sticking out below the bottom border.

Making a surrounding div for the border, two divs inside, and floating the table div right:
- I could not get the table to stay inside the border.
- The div assumed the height of the text.
- Text following the div rendered to the right of the text in the div.

Making a surrounding div for the border, floating the text div left, and the table div right:
- The text and table stayed inside the div.
- The table was to the right, but below the text.
- The beginning of the following p tag was inside the border, below the text div.

Making a surrounding div for the border, and floating both inner divs left:
- The text and table stayed inside the div, in the proper orientation..
- The beginning of the following p tag text appeared to the right of the table, inside the border.

Make a surrounding div for the border, with two divs inside, and displaying them as table cells:
- This worked in both IE and FF, until I tested it with W3C, and discovered a typo.
- When I fixed the typo, it worked in Firefox.
- After the typo was fixed, IE agains started making the div for the border small vertically, with both the text and the table sticking out below the bottom border.

After messing with this for an hour, I replaced the divs with a table, and had it working in 3 minutes.

MidiMagic
Nearly a Senior Poster
3,319 posts since Jan 2007
Reputation Points: 730
Solved Threads: 182
 

I'm not exactly the best student but I've exerted more effort (than usual) in studying how divs behave and I am more comfortable (efficient) working with divs than with tables.

Even if I didn't have that advantage and it's easy to construct a page from scratch (from tables), trying to change the design or structure of a site based on tables is like college without coffee and pizza. Pure hell.

The table's boon (easy to command/ 'bend to your will') is also it's bane:
It's easier to manipulate because there isn't anything much to manipulate. You just tell it to hold some columns, rows, have a background, have paddings, borders, and margins. Be a certain height or width.

Everything is fixed.

Whereas, divs are so much more flexible. Can you imagine what wordpress would be like if it used tables to display its content? Will there be that much diversity to the designs and structures available to us? Can we switch the positions of the body, menu, and other parts of the page with just one CSS file if designs were based on tables?

Maybe. But it won't be that easy. Something about switching the actual contents of each column/row/cell. (I suspect this is the reason why Wordpress is more popular than Joomla)

It takes an average of four times as long to create a page using divs and css, compared to using tables and css. This is because the page author must fool around with the div settings until it works. The table always works the first time.

We seem to agree on that point: Table is quick the first time. But the internet isn't made to be static. It's supposed to change. Constantly. And those tedious table updates are going to add up in the future. Sacrificing the ability to maintain the site smoothly for the swiftness of setting-up is a tempting lure. But it causes a lot of headaches for later.Employers now prefer the table method. Our technical school instructors are now teaching this, instead of div and css. They've been teaching tables for years. Some people are hoping that this trend will die soon. Because it's wrong. You have these fresh graduates who can make table-based sites quickly and don't have the patience to work with divs because they don't see results quickly as compared to tables. However, just because something is quick and easy doesn't mean it's right.

It's our job as web designers or developers to give it our best shot. Learn about divs. Do not get sucked into a comfort zone.

We REALLY should keep up with the standards. It's part of our job. If we can't do it, then maybe we should pause, re-learn, and have another go at life.

kanaku
Posting Whiz
378 posts since Jan 2007
Reputation Points: 70
Solved Threads: 15
 

If you're working in an IT company that keeps up to date, than you will have a programmer working alongside with a designer, so the programmer won't have to worry about this and just follow the guidelines of the designer.

pritaeas
Posting Expert
Moderator
5,484 posts since Jul 2006
Reputation Points: 653
Solved Threads: 875
 
I'm not exactly the best student but I've exerted more effort (than usual) in studying how divs behave and I am more comfortable (efficient) working with divs than with tables.

I keep thinking I have it mastered, but then I go to use it, and it sneaks out and does something else. Or it works on one browser and not another. The worst thing is when a browser update makes the site change the way it displays.Whereas, divs are so much more flexible. Can you imagine what wordpress would be like if it used tables to display its content?

No, because I don't use it.Will there be that much diversity to the designs and structures available to us? Can we switch the positions of the body, menu, and other parts of the page with just one CSS file if designs were based on tables?

I'm not talking about designing an entire page with tables, but positioning two or three stubborn elements that refuse to go into the right places with divs. If there is a real table (a worksheet of numbers) on the page, the divs go crazy.

I am talking about positioning a photo to the right of each paragraph of text, and having all of the photos, and all of the right margins of the texts lined up perfectly.

And I don't WANT the positions of things to change. I want the page to scroll if the window is too small.We seem to agree on that point: Table is quick the first time. But the internet isn't made to be static. It's supposed to change. Constantly.

Maybe that's why the divs don't work. I had several pages that worked on every browser, until I upgraded to IE7. Then I had to rewrite the pages again to work on IE7.

I don't want everything to change constantly. That's one of the things I do not like about the Internet. Every time I go back to a page to get information, they changed it, and I have to hunt for the info all over again.And those tedious table updates are going to add up in the future.

What updates? I'm not publishing a newspaper. I'm presenting educational material that does not change.

It' the tedious div updates I have to make whenever a browser upgrade makes the pages I did write with divs malfunction. They've been teaching tables for years. Some people are hoping that this trend will die soon. Because it's wrong. You have these fresh graduates who can make table-based sites quickly and don't have the patience to work with divs because they don't see results quickly as compared to tables. However, just because something is quick and easy doesn't mean it's right.

They went BACK to teaching tables.

They did this because the EMPLOYERS are sick of employees wasting time failing to get divs to work and rewriting pages after browser upgrades make them fall apart. Employers are not accepting the graduates who are taught divs.

The method they are teaching involves using a table for a row of items that need to be kept together in a horizontal row, not the entire site. Table is a reliable way to do this. Div is totally unreliable at doing this. (If you know how to do this in a way that survives window resizes, different resolutions, and browser upgrades without using pixels or other absolute measures, please tell the rest of us.)It's our job as web designers or developers to give it our best shot. Learn about divs. Do not get sucked into a comfort zone.

Unfortunately, the employer is not going to like wasting his money while the employee learns to make the pages work again after a browser upgrade messes the whole site up. The employer wants the site up and running. He does NOT want the site to be the most elegantly crafted, at the cost of it malfunctioning every time a standard changes or a browser is upgraded. It costs him money.We REALLY should keep up with the standards. It's part of our job. If we can't do it, then maybe we should pause, re-learn, and have another go at life.

Part of the problem is that they won't leave the standards alone. Things that work today fail tomorrow.

I have already had to rebuild my entire private web site of 200+ pages three times, because they won't leave the standards alone:

1. Converting to xhtml and css, conforming to the W3C verifier (most of the time spent changing tags to lowercase, adding closing li tags, and converting br & hr tags to self closing form).

2. Making the site position objects relatively and removing formatting tables where practical (many of the pages were made before css styles were available, when table was necessary to make page margins).

3. Fixing things that changed when Firefox changed to version 2 and IE changed to 7 (mostly the divs that started malfunctioning when they contain tables), while simultaneously fixing a bunch of things the W3C validator started flagging that it allowed before (mostly unescaped quote marks and ampersands in the text).

I may have to redo things again, because I just found out that pt is not the relative font size style (em is).

Tell me how many man-hours are wasted every time the standards change again, or a browser upgrade makes things fall apart.

MidiMagic
Nearly a Senior Poster
3,319 posts since Jan 2007
Reputation Points: 730
Solved Threads: 182
 

Interesting read, thanks for that.

I always use tables and have never found the time to adopt css. But then I've only created web-pages in frontpage.

:-P

iamthwee
Posting Expert
5,950 posts since Aug 2005
Reputation Points: 1,543
Solved Threads: 439
 

I agree, I'm just starting out in web design, at the moment i'm using div's however i admit i find them generally hard to control.

Thanks for the read

Designer_101
Posting Whiz
314 posts since Jul 2007
Reputation Points: 12
Solved Threads: 16
 

Can someone write a set of rules that always works for divs?

MidiMagic
Nearly a Senior Poster
3,319 posts since Jan 2007
Reputation Points: 730
Solved Threads: 182
 
If you're working in an IT company that keeps up to date, than you will have a programmer working alongside with a designer, so the programmer won't have to worry about this and just follow the guidelines of the designer.

The IT companies here want to hire only one employee for both.

MidiMagic
Nearly a Senior Poster
3,319 posts since Jan 2007
Reputation Points: 730
Solved Threads: 182
 

I have over 600 pages on my site php generated from sql tables and includes
changing layouts of all takes about a minute,
changing layout of one page only, takes much longer than changing all of them

almostbob
Posting Sensei
3,149 posts since Jan 2009
Reputation Points: 571
Solved Threads: 376
 
Can someone write a set of rules that always works for divs?

This would be the CSS standard... ;-)

Unfortunately, because of the ever changing way the browsers implement the standard, this would be very hard to do. If they would all comply it would be easy.

pritaeas
Posting Expert
Moderator
5,484 posts since Jul 2006
Reputation Points: 653
Solved Threads: 875
 

This would be the CSS standard... ;-)

Unfortunately, because of the ever changing way the browsers implement the standard, this would be very hard to do. If they would all comply it would be easy.

[indent]
Almost all browsers (including IE since 6) do comply with most of the standards. It is not hard to write CSS that works in all browsers. It means avoiding some things that IE doesn't do correctly, and occasionally letting IE produce a less-than-optimal (but still usable) page.
[/indent]

cfajohnson
Junior Poster
196 posts since Dec 2008
Reputation Points: 25
Solved Threads: 23
 

I'm talking about using div to make a page that doesn't fall apart if someone (or the browser) looks at it wrong.

I'm talking about divs that don't go crazy when you put a list or a table inside.

I'm talking about divs that can be made to expand to fill their containers without using absolute measures.

I'm talking about structures that don't take several hours of tweaking to make them work.

I'm talking about being able to use the same methods and always getting the same results.

MidiMagic
Nearly a Senior Poster
3,319 posts since Jan 2007
Reputation Points: 730
Solved Threads: 182
 
I'm talking about using div to make a page that doesn't fall apart if someone (or the browser) looks at it wrong.

[indent]
Yes, so am I.
[/indent]I'm talking about divs that don't go crazy when you put a list or a table inside.[indent]
Me, too.
[/indent]I'm talking about divs that can be made to expand to fill their containers without using absolute measures.[indent]
If you use absolute measures theycannot expand.
[/indent]I'm talking about structures that don't take several hours of tweaking to make them work.[indent]
Agreed:
[/indent]I'm talking about being able to use the same methods and always getting the same results. [indent]
Agreed:
[/indent]

cfajohnson
Junior Poster
196 posts since Dec 2008
Reputation Points: 25
Solved Threads: 23
 

Why do you want to never use tables and only use divs?

(BTW: no-one ever answers this with a decent -- rarely even an accurate -- answer. infact, most people go and answer a completely different question, and if you dont have an answer to this question because it doesn't apply to you, then contending the original points on whatever grounds is arguing at cross-purposes: because I don't believe that MidiMagic is saying only use tables)

In every other part of software development, heck, in almost every other field, period: people use the tool that best fits the job, and rarely think twice about it. there's no for-loop appreciators club, or cult of the saucepan.. although, come to think of it, there probably is...

the occasional "goto" never really harmed anyone; and likewise, the occasional table is sometimes both 'justifiable' and the 'best choice'.

saucepans work well as as long as you dont try and use them as for loops; divs work well and are totally 'easy': as long as you don't try and make a table-like layout with them. if you do, then you suffer from a lack of one of the following information bridges:

- the one that keeps the column widths the same
- the one that keeps the row heights the same

you can hack in one of those, but not both. it should be evident from the specification of HTML and CSS that you can't.

there's a reason why most (perhaps all?) GUI toolkits have some kind of low-level 'table layout'. if it was possible to compose that functionality via other means, there'd be no need for that low level layout.

..........


but anyway, IMHO, the next HTML should get rid of all of the elements (and their silly names ), create two new elements 'block' and 'inline', and have everything specified by CSS:

<block style="table-rows:2; table-cols:2">
  <block><inline>top left table cell!</inline></block>
  <block style="background-image:'some_image.png;'"/>
  <block><inline>omgz</inline></block>
  <block><inline>bottom right table cell</block>
</block>


solve everyone's problems, huh? if you care to, you could even implement this hot new language yourself (albeit statically) using some clever XSLT.

something for the weekend?

MattEvans
Veteran Poster
Moderator
1,386 posts since Jul 2006
Reputation Points: 522
Solved Threads: 64
 

Tables are perfect for tabular data
You can create a javascript to sort a table and view the info any way you like
tables for layout just for spacing, not so good

almostbob
Posting Sensei
3,149 posts since Jan 2009
Reputation Points: 571
Solved Threads: 376
 

I kind of agree with midimagic even though I don't want to.
Tables were meant to display content: div's were designed to control layout. 2 separate things but not mutually exclusive.
Firstly, I'm sick of hearing that 'change is good'. Who decided that while I slept? Consistency is good, having the time to get really good at something is good, being balanced and feeling secure is good.

Having said that, we are all remember right at the forefront of the internet. It really hasn't been around that long, (The popular interweb I'm talking about) therefore there's bound to be change to some degree until it's decided just what it is. Who says WC3 is correct and MS aren't?

Anyway does it all really matter?

I have created some sites in basic HTML, I've done some in ASP, I've laid them out in tables and CSS, div's and CSS, tables and html and used includes where appropriate and whatever else way I saw fit for each site.

They're all tools to use and I use whichever one of them gets the job done in the same way I sometimes belt something with my heavy pliers, because I can't be bothered to go get the hammer. If the result is how I want it who cares how I achieved it?

If you're going to have standards, then everyone must adhere to them, including those arrogant browser writers. Otherwise, I'll do the best job I can using the most appropriate tools for the job.

boristhemoggy
Newbie Poster
7 posts since May 2006
Reputation Points: 10
Solved Threads: 0
 

I agree that using tables solely for spacing probably isn't the best way to go about things.

But, I firmly believe that using tables for creating robust related columns and rows of any type is 'the right thing to do' (i.e., not just tables of raw, sortable/headed, data): mostly because there is a lack of a viable alternative.

Obviously the 'ideal' is to have one HTML nodeset look completely different and still function for it's original purpose simply by flipping a style... but that only really works in specific, quite simple settings.

MattEvans
Veteran Poster
Moderator
1,386 posts since Jul 2006
Reputation Points: 522
Solved Threads: 64
 
But, I firmly believe that using tables for creating robust related columns and rows of any type is 'the right thing to do' (i.e., not just tables of raw, sortable/headed, data): mostly because there is a lack of a viable alternative.

[indent]
Of course! That's what tablesare for.
[/indent]Obviously the 'ideal' is to have one HTML nodeset look completely different and still function for it's original purpose simply by flipping a style... but that only really works in specific, quite simple settings. [indent]
In fact, it can work with fairly complicated layouts.
[/indent]

cfajohnson
Junior Poster
196 posts since Dec 2008
Reputation Points: 25
Solved Threads: 23
 

Then maybe we are looking for the wrong solution.

The reason the W3C wants tables kept to tabular data is that web readers for the blind announce the row and column of every table cell.

So is there a way to put a style in to get the web reader to shut up about the rows and columns when the table is used to keep a layout from falling apart?

Alternately, we need dtr and dtd tags that behave like the tr and td tags of a table, to get the div ducks all in a row (or column).

MidiMagic
Nearly a Senior Poster
3,319 posts since Jan 2007
Reputation Points: 730
Solved Threads: 182
 
Originally Posted by MidiMagic I'm talking about using div to make a page that doesn't fall apart if someone (or the browser) looks at it wrong.
Yes, so am I.

How is this achieved? When you shrink the browser window, or use a different screen resolution, the divs won't stay put.I'm talking about divs that don't go crazy when you put a list or a table inside.
Me, too.

How is this achieved? Whenever I try it, the list won't stay together, or the table pokes outside the div.I'm talking about divs that can be made to expand to fill their containers without using absolute measures.
If you use absolute measures they cannot expand.

They certainly do not respond to the width and height styles correctly. I had divs inside of table cells to further format the contents. They never would expand beyond the size of the text they contained.

I had to use absolute measures {height: .75in; width: 1.5in;} to get the div to expand to the size of the containing table cell. 100% height and width did not work.

The table cells were of fixed height because one cell in each row contained an image.I'm talking about structures that don't take several hours of tweaking to make them work.
Agreed:

It won't work. Every time I try to make what seems to be a straightforward structure from div tags, something goes blooey in the browser. and it falls apart: Either stuff leaks out of the div, or the object contained in the div is put elsewhere.

I made a simple div just to put a colored box with a border around some text and a table. The table refused to stay inside the div. Either the div got very small and stayed above the table containing the text, or the table stuck out of the div on one side or the bottom. This was WITHOUT any size styles, other than that the table was to be 50 percent wide and aligned right. The div behaved as if only the text was inside it. The code validated with W3C.

It worked right if I substituted a one-cell table for the div, applying the same styles to the table. I'm talking about being able to use the same methods and always getting the same results.
Agreed:

It doesn't work.

I had a nice two-column div structure that stayed together nicely under all circumstances. Then, just to add emphasis, I replaced an ordered list with a small table. I made sure the table would fit into the containing div that used to contain the list. Nothing else changed. But the div structure fell apart.

MidiMagic
Nearly a Senior Poster
3,319 posts since Jan 2007
Reputation Points: 730
Solved Threads: 182
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You