Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

CSS layouts offer a whole host of advantages over their ancient table-based brethren. Historically, there has been a lot of discussion on this, but the conversation has basically been concluded with CSS layouts overwhelmingly recognized as the best option.

A CSS layout lets your site be flexible, scalable and semantically pure. When you do a table-based layout, you're basically locked into that presentation unless you choose to overhaul all your files, and chances are good that you've also partially destroyed the semantics of your document, which ruins accessibility and can be bad for SEO. Tables were basically a layout hack that let designers solve a presentation problem for which adequate tools didn't exist; their true purpose is to display tabular data. When browser support for CSS became relatively ubiquitous, people gradually switched over because there was no longer any reason to suffer the inherent inadequacy of table-based layouts.

Once you learn the syntax and the basics of how the box model works, CSS makes everything faster, easier, and more precise. By all accounts, it's the standard for web design nowadays.

I think the proof is in the pudding though; csszengarden.com is a shining example of the benefits of CSS. Surf there, and you can select different stylesheets to be applied to the page. Same HTML, different CSS, hundreds of designs.

alistapart.com is a great resource for discussion on the benefits of web standards and how to apply them. quirksmode.org has technical tips, and w3cshools.com has quick descriptions and examples of most almost everything web-design related.



That sounds kind of snobby, in that it's largely theoretical but just doesn't work in the real world. It's like trying to explain to someone why a good Napa Cabernet is so much better than the $5 Merlot they like.

"Well, it was grown from the Carneros region, fermented in French Oak barrels, then cellared for 10 years."

"Yeah, but this Carlo Rossi Paisano tastes better."

(and I say this as a devoted wine snob.)

CSS is one of those things that sounds great "it lets you separate presentation" but just kinda sucks for some purposes. The problem is, all of the theory is just generally not how it functions in the real world. In the real world, if you're running one site and redesigning it, you're doing just as much changes anyway. You're not just changing some colors and some background images and voila. You're moving things around drastically. (If you could do absolute positioning, it would function a lot better in that regard, but then your page will look crappy because it will be left-aligned in browsers rather than centered.)

CSS doesn't really seem to be meant to do layouts anymore than tables were, as evidenced by all of the hacky kludges you have to use to get it to work that way. Every time I find myself typing style="clear:both" I wonder why the hell I'm doing it. Still I did, grudgingly because guys like you tell me I should, and I wanted to learn .

Don't get me wrong, CSS is great for some things. Defining fonts, sizes, colors, hovers, etc. But for layouts, tables are often easier to implement, easier to maintain, and equally hard to change later. Even though I'm highly competent with CSS, I don't think I'd do it that way in the future.


>>> "You're moving things around drastically."

Funnily enough I just altered two sites this week by moving columns around. One was a simple CSS change, the other was one altered margin declaration and one moved div - I also get to see the alterations as they will appear live in a browser (FF).

>>> " Every time I find myself typing style="clear:both" I wonder why the hell I'm doing it."

Because of IE?

>>> "equally hard to change later"

It depends what you're trying to achieve, if you require a pixel based layout that renders identically in all browsers and completely misunderstands the original web paradigm (accessibility of information, not accessibility of design) then yeah, tables .. though you'd probably be more comfortable with Flash or just going the whole hog and printing it out on paper and pasting it to your screen.

When columns finally arrive in CSS3 (http://www.w3.org/TR/css3-multicol/) across the major UA will you still use tables for non-tabular data?


No, columns are awesome, and CSS3 in general looks like it does a lot more to make CSS useful for layouts. HTML 5 + CSS3 is going to be a designer's dream.




Consider applying for YC's Fall 2026 batch! Applications are open till July 27.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: