Dave Carabetta Blog Banner


December 29, 2005

CSS "Standard"? More of a Suggestion...


One thing I'm trying to get my act together with is better use of CSS for laying out and and formatting my web pages. I moved away from the tag ages ago, but I always stuck with tables (albeit properly accessible) for laying out my pages. However, I'm the Lead Developer here at my company, and I take it upon myself to lead by example rather than dictation. To that end, I've been really trying to use CSS for laying out pages. I've read the numerous articles about Slashdot's redesign and how much they've realized in bandwidth savings, etc. I thought to myself "you know what, it's my responsibility to my company to do the same sort of thing, regardless of how visible it is to our clients."

Well, that noble intention has turned in to a world of hurt and I absolutely loathe CSS. I really do. It's nice for formatting text, but for laying out pages, I think I'll pass. I have spent this entire week trying to redesign one of our core pages and it has been a nightmare of browser inconsistencies, bugs, and words coming out of my mouth that would make even the saltiest person cringe. I've concluded that CSS positioning (aka CSS-P) really only exists for sites like A List Apart to brag that they're CSS masochists and for designers to rake in large consulting fees because they have the patience to handle the various quirks.

Rant aside, I did get to thinking about the W3C and their role in this mess. And the more I thought about it, the more I realized that I don't really understand what purpose they really serve. According to their web site, the W3C "is an international consortium where Member organizations, a full-time staff, and the public work together to develop Web standards." The key word I take from that is "standards." Oh really? Have they ever tried laying out a @#$!^% HTML page according their "standards!"

Now, I know that some of you are thinking about Internet Explorer and how Microsoft (intentionally or not) let it stagnate over the years while updated "standards" have been passed. Hence it is pretty terrible from a CSS-rendering standpoint. Well you know what? Firefox doesn't full follow the spec either. Neither does Opera (although it's apparently close). (I should note that I'm aware that Safari does fully comply from what I've read.) So what's the point of passing a "standard" if nobody's going to follow it? To me, an example of a "standard" is a power supply on a computer. Every power supply I see nowadays on a computer takes a standard three-pronged plug and you can you use any three-pronged cord with it. I don't have to use a Dell cord or a HP cord or a Toshiba cord for their respective machines. The vendors (and I'm guessing the IEEE) decided "hey, instead of fighting with each other, let's be consistent and make our customers' lives easier." (Read: a standard.) Why can't the browser vendors do the same? To me, the W3C's work is largely academic if they can't mandate that a product (in this case, a web browser) function according to what the consortium passed as a "standard." It doesn't have to be immediate, but none of the major browsers have any intention of complying with the spec either due to technical implementation difficulties. (See the IE team's blog entry for this and Robert O'Callahan of Mozilla's blog entry for more info.) That being the case, the W3C's work is nothing more than a "suggestion" and way for some people to feed their egos.

Is the W3C and the passing of a "standard" pointless? Certainly not. They've done some very good work and have at least provided a focal point for the major vendors to strive towards. But this is why the potential of Flex and Xamlon and Laszlo are appealing to me. (Yes, I know there's the forthcoming Windows Presentation Foundation, aka Avalon too, but my understanding is that'll be Windows-only and for Windows XP/Vista only, so vendor lock-in is not a standard to me.) With the other products, I can drag-and-drop my components, use pixel-specific layouts if I have to, and not worry about how Firefox or IE or Opera is going to lay it out. This is all thanks to the Flash player, which, to me, is what Java has strived to be but I think most would agree it failed miserably at: write once, run anywhere. Adobe is working very hard to make Flex 2 fully ECMA-compliant, and I hope they achieve that goal, without exception. Until such time (and the penetration of Flash-based apps becomes acceptable), I'm sticking with tables for my major HTML layouts with targeted use of CSS where either necessary or appropriate.

Remember the redesign I referenced in the beginning of this post? I spent nearly 2 full days trying to lay out the page properly across browsers and less than an hour actually implementing the business logic of the page, which can be pretty complex due to different entitlement levels, etc. What a waste of my time.

What do you think?



Comments
Sami Hoda's Gravatar Dave,

I feel your pain. Its taken me years of reading articles, going through sample sites, hacking good looking websites, to come up with a decent cross browser template of my own for layout.

CSS takes a lot of patience, thats for sure. Stick with it! I'm so used to CSS now, that tables seem "off"... keep looking at the CSS of websites you like, and you'll find ways to solve your problems.

Best of luck!

-Sami Hoda
# Posted By Sami Hoda on 12/29/05 at 1:30 PM
Dave Carabetta's Gravatar Thanks Sami. I definitely hear what you're saying. But should it really be that difficult when I have an easier option available to me? I'm not an advocate of a seven-level nested table by any means, but if it means I'm spending an hour on a layout instead of 2 days, I know where I'm leaning. I've scoured all the sites there are (seemingly), and almost every article has some sort of "you'll need this hack to get it to work cross-browser." That's ridiculous. I just don't get why they call it a "standard" when it's nowhere close to one!
# Posted By Dave Carabetta on 12/29/05 at 1:50 PM
Sami Hoda's Gravatar Dave,

You're absolutely right about that point. I'm hoping we can come closer to this goal with Firefox 2, IE 7, etc in 2006. W3C really needs to step up here as you suggested.

But then, all this started way back when IE supported html tags such as -marquee-, etc which were never a standard. Inconsistant display has been a problem, and existed pre-CSS, and its for the standards orgs to really push for common look and feel (and for developers to continue to demand it!)

Hope it helps to know your not alone on this one.

Sami
# Posted By Sami Hoda on 12/29/05 at 1:58 PM
Patrick Correia's Gravatar Dave-

I feel your pain, but I'd encourage (no, beg) you not to give up at this point. Everyone who makes the transition from table-based designs to css goes through this stage of being so frustrated by inconsistent implementations that they just want to give up. It's a natural reaction to an illogical situation. But if you persist, you will get over this hump.

I've been exactly where you are, but now after practice and study generating a CSS-based layout from scratch is second nature to me, and it will be for you too. When you get a solid understanding of a few key concepts (basically: the float, positioning contexts and the layout rules for line boxes), you realize that the contortions you have to make to accomodate the browser inconsistencies aren't really any more onerous than dealing with spacer GIFs and row/column spans and the other contortions you have to make when you use tables -- it's just that you're familiar with them, so you don't think about it as such a pain. I bet you can look at a Photoshop mockup and just "see" how the table should be set up, where you need to shim it with spacer GIFs in case the content is too short -- everything that would seem just as incomprehensible to a person unfamiliar with table layouts as negative margins, absolute positioning, and floats seem to you now.

I would also encourage you to focus on the reason for switching to CSS layouts. It's not just because CSS is cool -- in fact, I would say it's not even for CSS's sake at all. What you gain when you switch to CSS layout is all the things we had to give up when we started using tables for layout in the first place - semantics, logical content layout, and to a lesser extent, page weight. This is where you start seeing what CSS gets you that tables can't -- higher search engine placement because your actual content takes up more of the page; pages that "just work" in screen readers and small-display browsers; and page maintenance that's a total breeze because the page contains only content.

So, please stick with it -- I promise you'll see the benefits once you're comfortable with CSS.

-Patrick
# Posted By Patrick Correia on 12/29/05 at 3:49 PM
Kay Smoljak's Gravatar Dave, the kinds of comments you're making are the same comments I hear time and time again from people new to CSS - you're not alone in finding it frustrating. The problem is, moving to CSS for layout requires a big change in thinking and approach. It's most definitely possible - I made the same decision as you with regards to the sites my company was putting out about three years ago and I'm proud to say we haven't done a table layout in well over two years - but it was a gradual process, in the beginning. These days, if any of my guys have to work on an older, table-based site they experience the same kind of frustration - they've forgotten all the tricks and hacks and niggly annoyances table layouts had, and CSS layouts now take no longer to do (and are much faster to update). Stick with it - get some help from the mailing lists at webstandardsgroup.org or css-discuss - it's most definitely worth it.
# Posted By Kay Smoljak on 12/29/05 at 7:25 PM
Dave Carabetta's Gravatar Thanks all for the comments (and the encouragement!). My overriding gripe with this whole post is that CSS is proclaimed to be a "standard" when in fact it isn't close. I don't necessarily mind the growing pains of changing my thinking (i.e., pre-CFMX to MX, non-framework to framework, etc.), but the added inconsistencies because browser vendors seemingly pick and choose what's convenient for them to implement makes this "standard" a mere suggestion. I don't intend to fully give this stuff up. Like I said, I need to lead by example. But I can't have my team spending so much time fighting layout bugs because of browser implementation inconsistencies that it takes their focus off the more complex business logic (i.e., CFCs). After posting this entry, I realized that it's back to the drawing board with my refactored page because screen resolution issues on higher-end monitors are causing so of my divs to overlap. ARRRGGGH!!!
# Posted By Dave Carabetta on 12/29/05 at 10:43 PM
Scott Stroz's Gravatar Dave,

One bit of advice I was told a while ago was, 'Code to the standard, or as close as you can, and then go back and tweak what IE breaks'. I try not to use too much exotic stuff as that's where you get into compatability problems.

I echo everyone elses sentiments here. Making the transition to CSS based layout takes a huge leap of faith and a huge cahnge in the way you think about your page layout.

One of the best things you can do is to look at sites that use CSS-based layouts and then disect the page.

Here is a link to something I was working on before I left my previous employer, it may not be perfect, but it looks the same in IE, FF and Opera (or so I have been told) http://www.boyzoid.com/demo/. Keep in mind, I had nothing to do with teh graphics, I was just given the .PSD file so I could cut it up as needed.
# Posted By Scott Stroz on 12/29/05 at 11:01 PM
Scott Stroz's Gravatar Please also keep in mind that I am far from an expert in CSS. If anyone sees something that it way off base, please point it out. Not so I can fix the page I posted (its no longer my responsibility), but so that I may learn from my mistakes.

Thanx!
# Posted By Scott Stroz on 12/29/05 at 11:06 PM
Nando's Gravatar While i agree that moving to CSS layouts is probably a good thing - after heading in that direction on various projects, i began to question the value of it. What value does it bring to my clients? A better question might be, what *perceived* value does it bring to my clients? In many cases, the answer is a simple "none". What value does it bring to my skillset as a developer? In comparison to something like learning Flex? Or Java? Or another framework?

10 minutes ago, i was struggling with a weird CSS layout bug in IE. I copied and pasted working code from one location to another, and for some unknown reason the text disappeared in IE unless i rolled over it with the mouse, as if i had set visibility to hidden on that class, and on hover, set visibility to visible. I of course HADN'T done any such thing, and after 15 minutes of struggling, you know what i did? Emailed css-discuss? Nope. I stuck it in a table and moved on.
# Posted By Nando on 12/30/05 at 8:56 AM
Dave Carabetta's Gravatar Amen Nando. That's where I'm at. It's not a lack of desire or naivety as to the benefits of a CSS-based layout, it's keeping my eye on the larger picture. My clients care whether or not the data my company provides are accurate, not whether I used a table or a div to present that data. HTML just "feels" old-school at this point, and putting lipstick on a pig doesn't make it any prettier. I'd rather tread water for the next year or two and wait for other technologies like Flex/Xamlon/Laszlo/Avalon gain traction and viability (assuming they do) and focus on those technologies.

I love challenges, particularly technical challenges. It's one thing if all I had to better understand was the difference between absolute vs. relative vs. fixed vs. static positioning. But since literally every browser available will treat my tests differently in a lot of cases, it's hard to discern bugs that are mine and those that are browser-related.

Again, I'll keep plodding through. I don't give up that easily. But I wish we'd stop calling things "standards-compliant" when it's clear there isn't much of a standard.

Sandy, thanks for pointing out the discussion groups. I'll certainly browse the archives.

Scott, good idea on the 'code to the standard' approach. I'll keep it in mind, but I'm not seeing much of a standard!!
# Posted By Dave Carabetta on 12/30/05 at 10:02 AM
Patrick Correia's Gravatar For what it's worth, my approach to "code to the standard" is more like "code to Firefox". It's not because I think Firefox is morally superior than IE, nor is it because Firefox is perfect in its implementation of the CSS standard (as has already been pointed out, it's close but not perfect) -- but my experience has been that most of the time, when something doesn't work the way I think it should in Firefox it's because my understanding of the spec is faulty, not Firefox's. When I reach major milestones in the layout, I check against IE and add fixes to account for the differences between the two browsers (usually, that amounts to putting in hacks or changing my approach to accomodate bugs in IE). By developing in a browser that's relatively close to the standards, you can restrict your hacks and workarounds to a relatively small number of tried-and-true fixes for the major ways that IE differ from Firefox and the CSS spec. I use Firefox instead of Safari because I have to work on Windows much of the time, but I'm sure Safari would work just as well (if not better) for the initial layout work.

There's a couple of specific things I can recommend to help you get through the inital pain. First of all, avoid (as much as possible) specifying a width on an element that also has margin or padding. Sometimes you have to add additional non-semantic elements to do that, but the only alternative is always remembering to put in hacks for IE's incorrect box model. Second, get to know the most common IE bugs by reading http://www.positioniseverything.net/ie-primer.html... so you'll recognize them when you see them.
# Posted By Patrick Correia on 12/30/05 at 10:43 AM
Seth Petry-Johnson's Gravatar > I'd rather tread water for the next year or two...

This pretty much sums up my feelings on CSS-P as well. A lot of my site's customers still use older browsers like IE 4 and 5 and even some older Netscape variants. I just lack the time and patience to deal with those issues AND work on getting the "modern" browsers to render content the same.

So, for now I'm using CSS mostly for adding formatting to my table based layouts, and I will continue doing so until the standards support in the commonly used browsers improves. If I was running anything other than an e-commerce site I would probably feel differently, but the reality is that my customers don't care if I use CSS-P or tables, they just want the site to work.

In other words, I'm going to let all of YOU guys deal with the hacks and tweaks and headaches, and I'll jump into CSS-P once its as easy as table based layouts are now. :)
# Posted By Seth Petry-Johnson on 12/30/05 at 2:01 PM

© Dave Carabetta, 2005-2008. This blog licensed under the Creative Commons License. Some rights reserved. This is a personal weblog. The opinions expressed here represent my own and not those of my employer. Blog software provided by Raymond Camden.