Topic: CSS vs Tables in Rails [The Debate]

I have seen many sites that do not render CSS/DIV's properly the first time you hit the site. You have to refresh the page to get the page to display correctly (what a pain).

I don't see this problem using tables.

Which is better to use in Rails for web sites? CSS or Tables?

smile

Re: CSS vs Tables in Rails [The Debate]

Tables are good for tabular data. CSS is good for everything else. This isn't a Rails question... this is a best practice web development question. What browser do you use most often?

Re: CSS vs Tables in Rails [The Debate]

CSS for layouts, I have no problems viewing them in IE, Firefox, Opera, or Safari.

Tables are fine for grids and other tabular data though.

vinnie - rails forum admin

Re: CSS vs Tables in Rails [The Debate]

What about CSS/DIV breaking in web sites?
How do you make it more consistant?

smile

Re: CSS vs Tables in Rails [The Debate]

Until a few days ago I was all for using tables to lay out my sites. I had trouble getting CSS to render properly in IE and Firefox and so I returned to tables, which is rendered the same in most browsers. You can view the source of http://www.railshostinginfo.com to see how much I'm using tables.

But a couple of days I discovered the Yahoo UI Library http://developer.yahoo.com/yui/ and its grids css (a 2.5Kb file), which makes it dead simple to layout your site. And until this day I haven't had a problem with it in IE or Firefox. So I guess I have to do a small rewrite of my site to remove all the tables and replace them with divs sad

Kind regards,

Nick Snels
http://www.railshostinginfo.com
Review and compare Rails hosting companies

Re: CSS vs Tables in Rails [The Debate]

CSS can be challenging when you first make the switch because when your learning and don't understand how CSS works then it can be very frustrating but once you overcome these issues you will find CSS allows you much more control over your design. Just practice, practice, practice..

Last edited by sydneyfx (2007-01-31 20:25:25)

Re: CSS vs Tables in Rails [The Debate]

The reason you see differences in how CSS is displayed is because not all browsers interprit the CSS model the same way - though they should and hopefully one day will...

In general though, once you understand CSS you can make those minor changes needed in order to get things to display consistently accross the board. The yahoo yui is a great place to start - especially the two css layouts the reset a lot of properties (like margins, etc.) to their default zero positions. This makes obtaining consitency a lot easier and releases you from understanding the intracacies of each browser at the start.

Like sydney said, practice. It's well worth the trouble - you'll end up with more fluid, flexible, and adaptable designs - not to mention much nicer looking. You simply can do a lot with CSS that you can't with tables. And if you ever need your site to function on say a mobile device it doesn't require a complete redesign, just a seperate style sheet...

Re: CSS vs Tables in Rails [The Debate]

Tables are good for tabular data. CSS is good for everything else. This isn't a Rails question... this is a best practice web development question.

Yes....

Not having a CSS based layout work properly across multiple browsers is the result of either a lack of knowledge on the subject or lazy coding. It can generally always be achieved, and usually without the need for hacks, alternate styles, periods of homicidal rage, etc.

Re: CSS vs Tables in Rails [The Debate]

I'm going to double post this, because I'm so excited by the prospect of sane standard compliant CSS coding, including the ability to use alpha-channel png's:

See this link here: http://dean.edwards.name/IE7/

The point of this is a javascript helper script that allows you to code to a CSS standard so you don't have to worry about different CSS implementations.  I've not yet used it, but it looks quite promising.

Re: CSS vs Tables in Rails [The Debate]

I started using tables after finding that IE7 doesn't display css display properties like table, table-row or table-column properly. I don't think IE7 even rexognizes this behavior.

Re: CSS vs Tables in Rails [The Debate]

er... table, table-row and table-column aren't CSS properties....

Re: CSS vs Tables in Rails [The Debate]

CSS for sure. HTML is a markup language, not a layout language. Ideally, there shouldn't be a single line of layout related markup in your HTML. I'm a purist in that regard.

Granted the current state of CSS does not make this entirely possible, but you can get real close.

When you take out the stylesheets from my sites, they drop down to a mere listing from top to bottom of pure HTML. This is great because I can then style my sites for anything: the wii, PSP, cell phones, print, text readers, whatever.