Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

CSS Forum


You are currently viewing our CSS Forum as a guest. Please register to participate.
Login



Reply
Can anyone prove that CSS layouts are better than tables?
Old 01-23-2009, 03:08 PM Can anyone prove that CSS layouts are better than tables?
yarrgh's Avatar
Skilled Talker

Posts: 82
Trades: 0
I have worked as a web developer for two years now, and yet I still have not found a satisfactory solution to the problem of table-less layouts. Table-less layouts always end up needlessly complicated or full of CSS and other hacks.

Here is the challenge for you all. I have a very simple table layout with header, left nav, main content, and footer:
I am trying to figure out if there is a way to replace the table with CSS stuff only while meeting all of the following requirements:
  1. Must be a simple solution with as few HTML elements as possible.
  2. Must look and behave the same as the example table. Thus:
    1. When the content area is taller than the left nav, the blue of the left matches the height of the content exactly, and the footer drops down nicely below.
    2. When the left nav area is taller than the content area, the green of the content area matches the height of the left nav exactly, and the footer drops down nicely below.
  3. The solution uses new HTML and new CSS only... not looking for a javascript solution or something else.
  4. Do not make use absolute positioning: in case I need to center it or do some other fluid thing later. Also avoiding relative positioning would be great too.
  5. Do not make use of CSS hacks or any other hacks. All code must be valid.
  6. Must work flawlessly in every browser, just as the table does.
Basically, I don't think it's possible to meet all of those requirements, which means that layout tables are better. Please prove me wrong!
__________________
no sig.

Last edited by yarrgh; 01-23-2009 at 03:12 PM..
yarrgh is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 01-23-2009, 03:32 PM Re: Can anyone prove that CSS layouts are better than tables?
chrishirst's Avatar
Missing! presumed drunk.

Posts: 42,371
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
Quote:
Table-less layouts always end up needlessly complicated or full of CSS and other hacks.
Only when you still think in tables and then try to build using HTML/CSS.
__________________
Chris. ->>
Please login or register to view this content. Registration is FREE
<<-

A foolish consistency is the hobgoblin of little minds
Thought for today:- Is SEO the only industry where all the cowboys are Indians?
chrishirst is offline
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 01-23-2009, 03:41 PM Re: Can anyone prove that CSS layouts are better than tables?
wayfarer07's Avatar
Poo on You

Latest Blog Post:
Introducing WowWindow
Posts: 3,987
Name: Abel Mohler
Location: Asheville, North Carolina USA
Trades: 0
***sigh***
You must not have learned very much in those two years.
__________________
I build web things. I work for the startup
Please login or register to view this content. Registration is FREE
.
wayfarer07 is online now
Reply With Quote
View Public Profile Visit wayfarer07's homepage!
 
Old 01-23-2009, 03:42 PM Re: Can anyone prove that CSS layouts are better than tables?
yarrgh's Avatar
Skilled Talker

Posts: 82
Trades: 0
Quote:
Originally Posted by chrishirst View Post
Only when you still think in tables and then try to build using HTML/CSS.
What else would I try to build in?
__________________
no sig.
yarrgh is offline
Reply With Quote
View Public Profile
 
Old 01-23-2009, 03:44 PM Re: Can anyone prove that CSS layouts are better than tables?
wayfarer07's Avatar
Poo on You

Latest Blog Post:
Introducing WowWindow
Posts: 3,987
Name: Abel Mohler
Location: Asheville, North Carolina USA
Trades: 0
Why tables for layout is stupid
__________________
I build web things. I work for the startup
Please login or register to view this content. Registration is FREE
.
wayfarer07 is online now
Reply With Quote
View Public Profile Visit wayfarer07's homepage!
 
Old 01-23-2009, 03:52 PM Re: Can anyone prove that CSS layouts are better than tables?
yarrgh's Avatar
Skilled Talker

Posts: 82
Trades: 0
Quote:
Originally Posted by wayfarer07
***sigh***
You must not have learned very much in those two years.


Quote:
Originally Posted by wayfarer07 View Post
I know the reasons. Hence this post.
__________________
no sig.
yarrgh is offline
Reply With Quote
View Public Profile
 
Old 01-23-2009, 04:32 PM Re: Can anyone prove that CSS layouts are better than tables?
stevej's Avatar
Professional Multitasker

Posts: 996
Location: Not positive
Trades: 0
You have been proven wrong.

CSS
Code:
.container {width: 790px;}
.header {height: 100px;   background-color: #C5C;}
.main {width: 100%; background-color: #5CC; overflow: auto;}
.leftnav {width: 250px; float: left;}
.content {width: 540px; float: right; background-color: #5C5;}
.footer {height: 100px;   background-color: #CC5;}
HTML Code:
<div class="container">
    <div class="header">
        This is the header.
    </div>
    <div class="main">
        <div class="leftnav">
            This is the Left Nav.
        </div>
        <div class="content">
            This is the Main Content. 
        </div>
    </div>
    <div class="footer">
        This is the footer.
    </div>
</div>
For data, there is nothing wrong with tables. But when it comes to layout...

- Steve

Last edited by stevej; 01-23-2009 at 04:47 PM..
stevej is offline
Reply With Quote
View Public Profile
 
Old 01-23-2009, 04:38 PM Re: Can anyone prove that CSS layouts are better than tables?
wayfarer07's Avatar
Poo on You

Latest Blog Post:
Introducing WowWindow
Posts: 3,987
Name: Abel Mohler
Location: Asheville, North Carolina USA
Trades: 0
Both columns need to be equal though, or at least appear equal. Faux columns
One of the most annoying things about tables is that you are FORCED to have equal columns, hence all the nasty nested tables which are used to compensate for this. Of course, equal sides is perfect for data, which is why tables work like this.
__________________
I build web things. I work for the startup
Please login or register to view this content. Registration is FREE
.

Last edited by wayfarer07; 01-23-2009 at 04:40 PM..
wayfarer07 is online now
Reply With Quote
View Public Profile Visit wayfarer07's homepage!
 
Old 01-23-2009, 05:01 PM Re: Can anyone prove that CSS layouts are better than tables?
Junior Talker

Posts: 3
Trades: 0
Quote:
Must be a simple solution with as few HTML elements as possible.
I think you will find with more complex web sites that CSS allows you to use FAR fewer elements. One of the main concepts is to create classes that dictate your style, rather than using inline HTML to style every last detail of a table and its contents.
Table structure may initially seem like a more straightforward approach and easier to grasp the mechanics, but CSS gives you far more control. I'm no CSS purist. I've used tables when the CSS alternative is ridiculously complex and ridden with various browser bugs, but layouts are not one of those things.
Vanhail is offline
Reply With Quote
View Public Profile
 
Old 01-23-2009, 07:24 PM Re: Can anyone prove that CSS layouts are better than tables?
Defies a Status

Posts: 1,606
Trades: 0
Quote:
Originally Posted by stevej View Post
You have been proven wrong.

For data, there is nothing wrong with tables. But when it comes to layout...

- Steve

We have a clear winner here!

and here is the visible proof. I only change the footer height.


I use essentially the same thing in a three column version for most of my sites since I quit using tables.
__________________
Colbyt

Please login or register to view this content. Registration is FREE
colbyt is offline
Reply With Quote
View Public Profile
 
Old 01-23-2009, 09:18 PM Re: Can anyone prove that CSS layouts are better than tables?
chrishirst's Avatar
Missing! presumed drunk.

Posts: 42,371
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
http://www.modtalk.co.uk/_site/demos...al-two-column/

http://www.modtalk.co.uk/_site/demos...-column-image/
__________________
Chris. ->>
Please login or register to view this content. Registration is FREE
<<-

A foolish consistency is the hobgoblin of little minds
Thought for today:- Is SEO the only industry where all the cowboys are Indians?
chrishirst is offline
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 01-23-2009, 11:10 PM Re: Can anyone prove that CSS layouts are better than tables?
johniman7's Avatar
President, JLI Media

Posts: 965
Name: John Irving
Trades: 0
Quite honestly, I don't think it matters much. More of a personal preference. In the very long run CSS would be better because it is more likely to be read the same in different browsers than HTML. I still use tables to align certain columns, but hey it's up to you.
__________________
Cheers, John Irving: My Blog
JLI Media:
Please login or register to view this content. Registration is FREE
| Website Development (Link Coming Soon!)
johniman7 is offline
Reply With Quote
View Public Profile Visit johniman7's homepage!
 
Old 01-24-2009, 10:11 AM Re: Can anyone prove that CSS layouts are better than tables?
chrishirst's Avatar
Missing! presumed drunk.

Posts: 42,371
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
Quote:
Originally Posted by yarrgh View Post
What else would I try to build in?
Nothing else, but you have to adopt a different way of looking at the design when converting it into a page layout.

When you are used to using tables for layout, everything is a cell or group of cells, either vertically or horizontally. For instance: A row of cells would become the header container (or a nested table). The same for navigation, either a column grouping in a row or a single column of grouped rows.
The content container would a group of rows and columns and so on.
So the seemingly natural progression would be continue using the same pattern for CSS styled layouts.

When you decide to move to CSS based layout, you MUST leave that methodology behind you. Thinking in terms of lots of boxes will get you confused and in trouble with cross browser compatibility.

Go back to the principle of "Keeping it simple" and take a holistic approach to the design. Look at the lines of demarcation and how you want the major elements to "flow" away from a left aligned vertical line. It really is a "top down" method of programming.
From there onwards your aim should be to use the minimum amount of markup to achieve the final look.
__________________
Chris. ->>
Please login or register to view this content. Registration is FREE
<<-

A foolish consistency is the hobgoblin of little minds
Thought for today:- Is SEO the only industry where all the cowboys are Indians?
chrishirst is offline
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 01-24-2009, 10:14 AM Re: Can anyone prove that CSS layouts are better than tables?
chrishirst's Avatar
Missing! presumed drunk.

Posts: 42,371
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
Quote:
Originally Posted by johniman7 View Post
In the very long run CSS would be better because it is more likely to be read the same in different browsers than HTML. I still use tables to align certain columns, but hey it's up to you.
??

HTML is the structure of the page, CSS is the means of styling the structure.
__________________
Chris. ->>
Please login or register to view this content. Registration is FREE
<<-

A foolish consistency is the hobgoblin of little minds
Thought for today:- Is SEO the only industry where all the cowboys are Indians?
chrishirst is offline
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 01-24-2009, 08:05 PM Re: Can anyone prove that CSS layouts are better than tables?
LadynRed's Avatar
Defies a Status

Posts: 10,017
Location: Tennessee
Trades: 0
Web standards - where the ROI is : - http://visitmix.com/Articles/Web-Sta...ere-the-ROI-is
__________________
Web Goddess & Web Standards Evangelist :) - Tables Be Gone !!

Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE

LadynRed is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Can anyone prove that CSS layouts are better than tables?
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.70129 seconds with 12 queries