Help - Search - Members - Calendar
Full Version: Tables Vs Div For Page Layout
OverclockersClub Forums > Operating Systems & Software Support > Programmer's Corner
d3bruts1d
I'm debating on how I want to code a new website that I'm working on. As anyone with HTML experience knows, there are really three ways to accomplish a standard 3 column layout, such as the one used here on OCC and many other sites.

The first option is to use tables, like OCC and my own personal site. The code is ugly and complex, but it gets the job done. If someone tries to shrink the browser window down, the site format still holds together pretty good.

The next option, which is gaining popularity is to use "div" tags, which is short for divisions. Slashdot.org just moved to this method. This leads to a lot simpler code, but things can get pretty ugly when a user tries to change the browser size.

The third "option" which, to be honest, hasn't been a true option since the late 80's is to use frames. This just sucks anyway you look at it.

Styling will be done using CSS regardless of how the layout is done.... Tables vs. Div


Just wanted to get some feedback from others on what they prefer when creating or maybe even viewing a page.
Nerm
I love tables! Every site I do uses the table method. smile.gif
hardnrg
tables give you ultimate control imo... nested tables... millions of tables like a fractal made up of tables... that's what you want lol...

i've never got anything else to keep the layout exactly right when extending AND reducing beyond/below the intended viewing size with anything else apart from tables...

tables... and image slicing... smile.gif
Vasto
I use tables, mostly because I never cared for the restrictions of div.
94Camaro
Well I don't code websites, but I'll throw in my opinion.
I absolutely hate sites that are coded so they are always 800x600 or something no matter the size of the window. I run a much higher res, so these sites are ridiculously tiny! I guess my vote is for tables as well.
kanbeki
Tables have had their run, div has been the new hotness for some time, plus you can layer em to get cool effects and if you're worried about resize distortion just use percentages instead of fixed pixel values
CmpFreak88
Hm... I haven't really looked at sites lately and I'm a loyal follower for tables. I'll have to look up Div's and see how they work, advantages and disadvantages, but I'm a table person. Yeah it may get confusing but how are you coding? For me I'll code it with a program, Evrosft 1stPage and it has a cool table feature which is really easy, then I just add comments so I know which table is what and it makes it soooooo mcuh easier. But from the above post, it looks like I need to look into Div's...
BiPolar
i'm loyal to tables mostly because i understand them. however, I know that div's are the new 'thing' and if you can get htem to do what you want, use them.
d3bruts1d
Tables are the easy route to go, that's for damn sure. I've been playing around with div tags and CSS formatting for the last couple of days, and things are finally starting to take shape (pardon teh pun).

I'm still not 100% convinced I'll use divs. Going to have to do a bit of cross browser testing. IE5 tends to screw everything up. laugh.gif
ShadowPaktu
Use divs.

For starters.

Tables were never designed to be used for a method of design, they were designed for statisticle data, usually out of a database.

Tabels are inflexible, in the end of the day, require more coding and tags than the DIV and SPAN tags.

The problem you mentioned with DIV's and resizing windows is in my opinion nonsence. Of all the sites i have designed (for my own personnal use and now in my job for the Police Force's Intranet) I scale my layouts so they fit nicley, no matter what the window width is.

I believe dropping tables for DIV's would be the best thing you do for website design and layout. There are not really many major cross browser issues to do with using DIV's for design, apart from a few missfitts here and there. As i have moved on to Possitional CSS, you will be amazed at what can be done with this technology, and how fluid it has become. There are thing i do in PCCS that are impossible to do with the use of tables alone.

If you ever do decide to go with PCSS, there is one word of advise i shall give: Make sure you plan your stylesheet and tags at the start of your project. It is a major factor and it wil ltake time, BUT, that said, when you do get your style sheets complete, it is just a matter of knocking out pages with ease.

Im not the best of speakers (as you may tell), and im not that great at getting my point across about one method or another, but ill put it this way: Using DIV's can be MORE flexible than using tables with minimal PCCS experiance.

Puck
Nested tables and gutters are the way to go IMO. Hold together real nice when using percents if the window is resized.
DrAwesomePhD
Use divisions!!!

The whole movement towards CSS is a positive one , dont get caught behind!!

It loads a whole lot faster, and is a lot more dynamic... theres a few website but i cant remember them... anyway, there was this guy who convinced windows to change over to CSS too, and he had this elaborate presentation, it explained how the loading times a much smaller, the HTML code is much smaller (if i remember it was like 28kb vs. 50kb) and there are a lot less of everything-bad and a lot more of everything-good.

CSS is the way to go, down with tables....

and on the whole resizing of divs... you can define the width of them in terms of pixels... width: 200px... and then you cant resize it it will ALWAYS be 200px wide.

Or, if you want, width: 80%.. a percentage.. its all good. divs = better!

As far as IE messing stuff up, i think theres an error with the "margin" tag in IE.. it interperates the "margin" to be a margin on the INSIDE of the picture, while firefox and everything else interperts it as being a margin on the OUTSIDE of the picture, so if you have a 200x200 picture with margin 10, its 190x190 in IE and 200x200 with a border of width 10 in firefox/opera... (i think , im not too sure about this, just something i heard).

Other than that, i think all CSS works fine with cross-browser.
d3bruts1d
Umm... you can use CSS with tables. wink.gif
DrAwesomePhD
check out css zen garden smile.gif they are professionals and they use div tags, therefore - div tags are good wink.gif thats my logic! also i think theres a spiel about it on that aforementioned slideshow.. http://www.stopdesign.com/articles/throwing_tables/ ... check it out.
ClayMeow
I don't have much experience with CSS or divs, mostly just html (unless u count slight altering of my friendster profile with CSS. But IMO, tables are the shiz! I've been using them forever, since I started making webpages years ago. Hell, I use them for EVERYthing, not just websites. Often I use them in word documents just because they make everything formatted so cleanly. Man, my dad used to hate when I'd do stuff in tables in word and he'd go to print it out in wordperfect at work (at least back then it didn't translate well).

But anyways, tables are great smile.gif. I'm not saying divs aren't though, cause I'm not familiar with them, but tables I know...and love tongue.gif
d3bruts1d
QUOTE(ShadowPaktu @ Oct 17 2005, 09:48 AM)
Tabels are inflexible, in the end of the day, require more coding and tags than the DIV and SPAN tags.
[right][snapback]561988[/snapback][/right]

IMO, tables are very flexible. I'll agree that it is more code, but at least they'll do exactly what I want across all browsers. That's the key thing to remember here. If it doesn't look relatively the same across all browsers, then it is useless to me.

QUOTE(ShadowPaktu @ Oct 17 2005, 09:48 AM)
The problem you mentioned with DIV's and resizing windows is in my opinion nonsence. Of all the sites i have designed (for my own personnal use and now in my job for the Police Force's Intranet) I scale my layouts so they fit nicley, no matter what the window width is.
[right][snapback]561988[/snapback][/right]

That's funny. Try putting a 3 column layout together with the left and right sides fixed at 166px. Make the middle section fluid, and then place a 468 px image in it. Looks great, unless you set your resolution to 800x600. At that point, the layout doesn't stick... now, you can use the 'min-width' CSS value for the middle column. Setting it to something like 470 px will hold the layout in all browsers except for IE. That's just testing on IE6 for Windows. You get into IE5.x for Mac, and things get really FUBAR.

Personally, I don't care about IE. I'd be happy to it the middle finger and be on my way. However professionally, I can't do that. Even with my own personal site, IE6 is the 2nd most used browser. And my site isn't advertised anywhere. The site I'm working on will be advertised, and I'm sure will get a lot more IE users...

QUOTE(Puck @ Oct 17 2005, 10:10 AM)
Nested tables and gutters are the way to go IMO. Hold together real nice when using percents if the window is resized.
[right][snapback]561991[/snapback][/right]


Yup. I've been doing it that way for.... oh, I don't know... eight or so years now. tongue.gif


QUOTE(DrAwesomePhD @ Oct 27 2005, 04:18 PM)
check out css zen garden smile.gif they are professionals and they use div tags, therefore - div tags are good wink.gif thats my logic! also i think theres a spiel about it on that aforementioned slideshow.. http://www.stopdesign.com/articles/throwing_tables/ ... check it out.
[right][snapback]567520[/snapback][/right]


Yeah, I know all about CSS Zen garden. Talked to the guys on the Opera forums, as well as read the book. They are professionals, but guess what; there are many other professionals out there that don't use DIVs or even CSS.... that must mean DIV's are bad. blink.gif

Sorry, that argument doesn't hold any weight. What they've accomplished is amazing, however it's useless for what I'm doing. tongue.gif See my reply above to ShadowPaktu for examples. smile.gif
suchuwato
I like tables, but more people seem to be switching to div. It's all really down to personal preference.
ShadowPaktu
QUOTE
That's funny. Try putting a 3 column layout together with the left and right sides fixed at 166px. Make the middle section fluid, and then place a 468 px image in it. Looks great, unless you set your resolution to 800x600. At that point, the layout doesn't stick... now, you can use the 'min-width' CSS value for the middle column. Setting it to something like 470 px will hold the layout in all browsers except for IE. That's just testing on IE6 for Windows. You get into IE5.x for Mac, and things get really FUBAR.


Yup, that is right, and your comment on compatabilty across ALL browser's is however true, tables ARE easier to use. You need to be slightly more creative when designing a page using PCSS, than tables. You need to readup and learn all about IE Box model, hacks, possitioning techniques, cross browser functions.

The min-width function doesn't work on IE (spec Mac), and this is where some creative planning can be thrown into the mix. You can either work around it by using a mix of different features, or you can just use the IE Ignore hack to ignore certain parts of your CSS, and run other parts that would have buggered up in other browser, but look fine in IE. Little more work, but same effect.

And if you need the code for your example, itl'l be here the next time i browse by these boards, i even have the PDA, print, and projecter stylesheets so you can display the page on those mediums (yes, it is possible!).

That last comment didn't make it sound too good smile.gif

Lets not forget what CSS was meant for, content styling. The idea behind CSS (as to what i have learned) is this: It is a way of seperating out the stylng, from the content. Although you have to spend more work on PLANNING your css design for mstart, before you even touch the keyboard, that fact that you can use this one file, in EVERY file on your site, to get the exact same look and feel that we come to see, when we view sites on the web today.


An example was given above for CSS Zen gardens, fantastic bit of work, but it's not a good resourse for someone like you, that wants to know if they should use tables or divs to design a site. It's more of a "Wow look at that isn't it amazing!". It sure is, but it would be wasted in a commercial product.

The site you should be going to, is the site belonging to, what i would call, the father of the CSS revolution, as it were. He has been kicking of the CSS train for 12 years now, has seminars weekly accross the US and other parts, and does live demonstrations on reworking a live site, on the WWW, to a CSS compliant one. One such exemple he did was our beloved microsoft dot com. I belive he reworked the backend in an hour or so (may have forgotten the time frame), ripped out all the tables (note, that ms uses two or more different files for displaying their site on different browser's/resolution's!).

Anywho, his name is Eric Meyer, go check his site at: www.meyerweb.com

Im enjoying this 'debate' now, i hope you reply back on this with some conter points so i can address them the next time i'm here!

As a side note, i have a fully featured CSS file set for my force's Intranet now, that i can use on the majority of projects i do. This fact, in itself saves me about 15% - 35% of the time it takes to work my sites smile.gif

This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.