CSS Page Layout Strategies
If you’ve been struggling with CSS based page layouts (as apposed to using tables) and you’ve been smacking your head against the wall to get things to work … believe me, you’re not the only one!
No, you’re not stupid … CSS for page layout is.
What?! CSS is flawed?
Indeed. CSS for page layout sucks hard because the logic behind CSS page layout is weak at best, and perhaps, even flawed. I can say this with experience in other languages like Java and even VB. Not that I am saying CSS is a programming language.
Anyway …
For web designers used to the craziness of CSS layouts, they would be flabbergasted at how easy creating layouts/views/screens are in VB or even Java when compared to CSS.
What’s the main problem with CSS?
The main problem with CSS (and HTML) is that it was not conceived as a user interface technology. Rather, it was considered and engineered as a document/page technology.
Think about it, we talk about web pages and not web user interfaces.
Despite the original intention of the Web being a bunch of documents, today the Web is largely a bunch of user interfaces. Yes, most web sites these days are much more like a user interface that we see in software than they are simple ‘pages’. So therein lies the core of the problem:
CSS was designed to style pages and not to build user interfaces.
-
So what has happened?
Well, because web designers realized the advantages of CSS for laying out pages, they figured out how to bend, stretch and sometimes break the very limited CSS technology to create modern web pages.
The problem is that you have a bunch of methods and practices that don’t really make much sense … logically speaking. That’s why when you are new to CSS, it is hard as heck to create many common layouts as compared to doing it in tables.
Think about it, a center aligned liquid layout with three columns is a snap to do with HTML tables. With CSS though, it took the community a long time to figure out how to get this to work.
… It shouldn’t take the efforts of a community to get common layouts to work. That is a sure sign of a broken technology.
Even the CSS nerds know it.
Like most human beings, nerds are loath to admit when they’ve screwed up. So it’s pretty telling when you see the invention of CSS tables. Yes, CSS tables are basically tables created with CSS rather than with HTML.
CSS nerds finally realized that for user interfaces, you need a grid structure sometimes … tables are essentially grids. Problem is that CSS tables are not YET widely supported in the major browsers.
So why not use HTML tables if they are so easy?
Because you would be missing out on the two big reasons for using CSS for page layout:
- CSS based pages are much easier to update and maintain.
- CSS based pages are much more likely to work any many devices like iPhones, PDA’s, your printer etc…
I want to comment on the touted advantages of CSS. First, most devices today have powerful browsers that can read just about any type of web page (CSS or not) … so you have to question the 2nd argument. You also hear other arguments about why you should use CSS:
- Your pages will be lighter in KB’s.
- Your pages will be forward compatible.
… Both these arguments have proven to be what I said they were years ago: total crap. So forget them.
So if HTML tables should not be used and CSS is crappy for page layout, what is a nerd to do? As always, I try to come to you with real solutions. Check it out …
The Big Two CSS strategies:
- Use templates
- Use IE conditional comments
Comments:
Since nerds have already gone through the trouble of figuring out the nuances of CSS, you don’t need to reinvent the wheel! Use a template and just build out from there.
If any issues should pop up where Internet Explorer is not working handling/displaying the CSS like FireFox, then just use IE Conditional Comments to solve the problem.
Thanks for reading,
Stefan Mischook (a.k.a.: The web design heretic)
www.killersites.com
September 14th, 2008 at 9:55 am
I am surprised to see, that You suggest to use templates. I thought I am one of the nerds just using templates and modifying them.
Nice post, made me to think.
September 14th, 2008 at 2:27 pm
Dainis,
Back in the late 90’s and early 2000’s, I was using my own in house templates for all our web projects.
I realized back then that most websites require one of a handful of layouts, so we put together a small collection and always started from there.
Doing things this way saves a lot of time and headaches. In fact, in time the quality of our web sites improved because we kept refining our templates so they were bug free and easy to work with.
… Remember, this was back in the day when commercial templates were simply not used.
Note: When I talk about templates, they don’t necessarily have to be complete with images and fonts etc … they can be simple structural templates that save you the hassle of having to create basic layouts that work cross browser.
You can find these all over the web (http://www.webshapes.org) and in programs like Dreamweaver that come with a nice set of web templates.
Stefan
September 15th, 2008 at 10:01 am
I’ve got this WordPress rant that I’ve put to one side for the while about layout limitations. Or the path from what should have been an easy journey for most beginners to take in which to create a simple 2-Column layout before moving on to the can’t be much, more harder, 3-Column variety. *Rolls eyes in disgust*
I’m glad I put it on the back burner, mostly because of your revelation that CSS was originally intended to style simple web pages, not to incorporate software-like user interfaces into the mix. Great article there Stefan.
Btw, when you said that CSS tables were as yet not accepted in the majority of browsers, did you mean that there is now some sort of resurgence or underground swell of renewed interest among folks now for tables to make a come back?
September 15th, 2008 at 10:24 am
Hi,
With regards to CSS tables, please be clear that I am NOT talking about HTML tables. CSS tables are a totally different beast. Check out my previous post:
http://www.killersites.com/blog/2005/what-are-css-tables/
I think only Firefox supports CSS tables at this time.
Stefan
September 15th, 2008 at 11:25 pm
I’m just surprised nobody talks about fireworks how one can quickly mock up a template.
September 16th, 2008 at 9:19 am
Juice,
I have no preference for the tools you choose to use. If you prefer Fireworks … go for it.
Stefan
September 16th, 2008 at 11:22 am
I think it’s also worth mentioning Blueprint. My last three projects have used the blueprint CSS framework and it really cuts down on the pain of laying out content:
http://code.google.com/p/blueprintcss/
September 23rd, 2008 at 3:50 pm
Great post. So I’m not going crazy. I do see the benefits of CSS, though. Two important ones that are missing are search indexing and page load performance.
Although nested tables were easy to use, too much nesting used to cause big problems with page loads.
I don’t use them anymore, but I still much preferred HTML programming with tables than with CSS.
October 7th, 2008 at 7:13 pm
What kind of IE conditional comments do you suggest?
October 7th, 2008 at 10:06 pm
Hi Lee,
You can learn all about conditional comments here:
http://www.killersites.com/blog/2006/ie-conditional-comments-video/
Stefan
October 27th, 2008 at 12:34 pm
Nice post, lot of work need to do fit table less layout in all the browsers/OSx.