By Peter Bell

Why Bother With CSS (Help me out!)?

I try very hard to focus on the back end of the web applications we generate. Creating a system for quickly and efficiently generating the server side code for flexible, custom web apps is more than enough to keep me out of trouble. Unfortunately that isn't working out so well. Some of our clients create table based layouts which are inaccessible, bad for SEO and hard to maintain. Others ask us to outsource the production of CSS from jpeg mock-ups which has consistently resulted in CSS that is more tortured and hard to maintain (and no more semantic) that the table based layouts it is designed to improve upon . . .

I've spent most of the last week "learning" CSS. You can't help but pick some up if you work on web apps all the time, but I'd done a pretty good job to date of not actually learning how to build a site using CSS the "right" way. After all, I knew that if I learnt CSS I'd get stuck fixing templates for my design partners (for which I don't get paid), so to date ignorance was a profitable policy! The problem I've always had with CSS is selling the benefits enough to justify us spending a little more time on each project to do the markup right.

Firstly, it seems to me the more I play with it that just like well architected code, if you have well designed CSS for one site it is much easier to use that as a basis for additional sites and that it only takes longer to do a site in CSS if you don't really know how to code CSS properly. Most of the problems we've had in the past with markup has been rookie mistakes from our suppliers like having an absolute positioned sidebar and wondering why the footer lays over it unless a hack is used or the well known problems with the difference between IE and everyone elses box model.

That said, imagine you're selling a website to a small business owner who runs a chain of three sporting goods stores or the marketing manager at a legal or accounting firm with 10-50 professional staff. They've got a $15,000-$25,000 budget (depending on the project) for consulting, design, data entry, programming, testing, deployment and support of a fairly rich site with a number of custom objects and a decent chunk of custom programming. The good news is that you know you can provide them with maintainable, semantically valid, accessible and highly usable markup, but it's gonna cost (for a site with a site wide screen template, a site wide print template than then maybe twelve custom screen templates for displaying lists, details, forms and reports for various different objects) at least a few hundred dollars more - I'd say probably $1,000-$2,000 all in (total cost - not additional).

From the owner/marketing manager, the question comes up, "what's in it for me"? "Why should we bother doing this?" What is a response that would make them happily open their wallet wide to do the site right?

To date I've focused on:

  • Search Engine Optimization - By moving presentation based code out of the HTML, by replacing image navigation with text and by putting the page title and content at the top of the page, it will help the site when being indexed for relevance on the keywords in the site content.
  • Accessibility - By creating semantically valid markup and using the right tags in the right way, the site will typically be easier for visitors using alternate interfaces such as screen readers. By defining text size using em's or percentages, those with poor vision will be able to easily up the font size to better read the marketing messages.
  • Maintainable - Over time as you want to make changes to the look and feel of the site, well designed CSS will be quicker and easier to maintain than a site with large amounts of obscure presentation markup mixed in with the content.

Assuming the company doesn't do any business with the government, what are the other benefits that CSS provides? I find that for some clients, the potential SEO benefits are enough to get them to pull the trigger, but for those that for whatever reason don't care about SEO, the accessibility and maintainability stories are often "nice but not worth paying for" on the basis that they don't have many customers using screen readers and they seldom tweak the look and feel of the site (preferring a complete redesign every 3-4 years instead).

Any Thoughts?!

Related Blog Entries

Comments
You can also approach it from an SEO point of view - CSS usually results in a better text/code ratio which makes search engines happier. It also loads faster than a convoluted table interface, again, making spiders (and customers, happier.

Also, if you like to make site-wide changes such as seasonal colors, it is far easier to edit one style sheet than however many layout pages and tables you would need to edit otherwise.

Finally, the geek in me gets really happy when running the w3c validator returns a "green light" for my code.
# Posted By Ian | 9/6/07 11:21 AM
Couple of things come to mind other than the ones you mentioned (which while, very applicable, are more from a developers point of view rather than the customers).

Better user experience: Typically, Structural HTML/CSS sites are about 50-60% smaller than their tabled based counterparts and 25-30% smaller than their (we are going to do this in HTML/CSS but with a tabled layout paradigm) cousins. This results in a faster download to the client. If you are moving from a tabled layout to a pure Structural HTML/CSS site, the site itself loads much faster since browsers don't show a table until its been closed. So a user gets the site quicker.

Cost Savings - bandwidth: Smaller pages equal less bandwith per. So a user isn't going to get choked by paying for more bandwidth or having to buy servers as often to keep up with demand.

Cost Savings - maintenance. A structural HTML site is easier to maintain period. Its easier to see what you are dealing with than a tabled layout (or the HTML table paradigm cousin).

Check out my presentation from CFUNITED. (CSS: The Basics). It talks a lot about this, includin g sample page that I converted. http://shayna.com/docs/CSSBackToBasics.zip
# Posted By Sandra Clark | 9/6/07 11:33 AM
I agree on the SEO piece, the problem I find is with the clients that for whatever reason dn't value SEO. The maintainability is a real benefits, but of course many of the smaller companies just don't want to pay for tweaks to the look and feel every few months (although I think they probably save time/money just with the quicker changes during the initial development). I'm with you re: the validator and "good feeling", now I just need to sell that to our clients :->
# Posted By Peter Bell | 9/6/07 11:35 AM
Peter-
In addition to the stuff that you mentioned, there are also some other benefits. A couple that I came up with are performance and compatibility.

Using external CSS and divs instead of tables, means that there is less data to send, less data to parse, thus resulting is quicker load times. This could mean more conversions (sales).

As for compatibility, "proper" (emphasis on proper) CSS allows for a more uniform display across different browsers. This is becoming increasingly important as IE is losing its dominance in the market. Again, could result in higher conversion rate.

As for how to present this to your owner/marketing manager, my personal recommendation would be to present it from a dollars and cents standpoint. I.e. if you have 100 visitors a day, and you covert 50% of those hits (which is probably extremely high), and 25% of your total traffic uses something other than IE, then by not being standards compliant, the company loses out on 12.5 sales a day (100 visitors * .25 *.5). And if you make$10 on each sale, that equals $125 a day in potential lost revenue. This means that in 16 days, you have lost $2000 because you were not standards compliant. Obviously, you should replace this with more accurate numbers to your situation, but this should get the point across.
# Posted By Phillip Gagnon | 9/6/07 11:37 AM
@Sandra,

Many thanks for the comment! Some very good points, and thanks for the link to your slides - I keep meaning to check out your materials as I hear great things about them. Will make sure to check the preso out tonight.

Thanks again!
# Posted By Peter Bell | 9/6/07 11:37 AM
Performance is another one. Well done CSS results in much smaller file sizes. Plus the included CSS files are cached. This all makes page loads and renders faster in my experience plus on a high traffic site can have significant impact on bandwidth usage.

Depending on where you are and who the site is being built for, there may be legal requirements to make the site accessible.
# Posted By Rick Mason | 9/6/07 11:40 AM
@Phillip, Good point re: download times. I'm not convinced by the standards piece only because the horribly hacky tables with spacer gifs usually display pretty well in most browsers - the only real exception would be mobile devices, screen readers and the like which most of my clients see as a vanishingly small proportion of their current audience (and to be fair, even well designed CSS will often require custom stylesheets for small form factor mobile devices - you fundamentally need to change the content presentation for small mobile devices irrespective of technology).
# Posted By Peter Bell | 9/6/07 11:41 AM
@Rick, Yep, I think performance, download time, bandwidth and rendering time are great points - thanks. As you point out, if you're dealing with the government in the US or in general I believe in the UK there are also legal accessibility requirements. Anyone know of any other legal accessibility requirements?
# Posted By Peter Bell | 9/6/07 11:43 AM
In a previous role, we produced a simple e-commerce solution for small-medium shops.
This used templates to generate nice XHTML and CSS for styling.

The system was about 75% re-usable - often clients wanted slightly different ways of cataloguing products or dealing with options like size, colour, etc. This took the time.

Having used CSS, it was often very quick to change the style of the entire site and as it was fairly robust, shifting the layout of the menu's, shopping cart, main content, etc. was mostly painless - I tend to work in a conservative way - going for extra boxes rather than hacking the box model so it was very cross browser compatible from the outset...

Overall, CSS saved money, time & sanity and hopefully the next system I roll will be even better.

Sometimes it is an absolute pain in the backside, but when you have full control of the design & build process, it can be a joy to use.
# Posted By GLen | 9/6/07 12:02 PM
@Glen, thanks for the comment! I think in the end we're just going to eat any time taken to create good CSS markup, because I think that in the long run you are right that the reusability between projects and the simpler skinning will end up saving us time rather than dealing with a bunch of projects each having a lot of custom HTML.

Good point - thanks!
# Posted By Peter Bell | 9/6/07 12:08 PM
Peter, while accessibility may not be your client's direct concern, there have been cases in the US at least of corporations getting sued for not providing accessible solutions. Most notable was Target.

So while your clients might say they don't need it, they might and not know it.
# Posted By Terrence Ryan | 9/6/07 12:14 PM
@Terrence-
I have heard that too. Sandra made a comment about that during her presentation on accessibility at CFUnited. Like a business that is not wheelchair accessible, or does not have handicap parking spaces. Same idea. Good point!
# Posted By Phillip Gagnon | 9/6/07 12:19 PM
Interesting! Of course, typically they have shallow enough pockets, but I'll have to dig into this. Do you happen to have any links (if not, I'll try to find and post some)?

Sad to say a dose of FUD is often just what it takes to push someone over the edge once you've exhausted the positive reasons :->
# Posted By Peter Bell | 9/6/07 12:20 PM
Not that I haven't used the "You may be sued" comment before, but...

At this time, the only areas that the ADA MIGHT cover if the target suit goes against them is for companies that sell their items in "Bricks and Mortor" buildings as well as online. (Its going to be interesting for Amazon though since they aren't covered, but they run the Target website.)

Its still the right thing to do and should be done, but if you are a mom and pop setup only selling on the internet, there isn't a need to worry right now. (It could happen in time though).

Having said that, the disabled population accounts for 15-30% of Americans. Thats a whole lot of people that could be turned away from your website. And they do have some disposable income that isn't going into your pockets.

There is also a ruling in the UK that makes it a law that any website that is available and does business in the UK does come under their disability laws and needs to be made accessible. And yes a US company has been sued and lost in UK court. So if your company does business in foreign countries, you might come under their laws as well.
# Posted By Sandra Clark | 9/6/07 12:27 PM
@peter Here's a page with some links to the articles: http://apps.wharton.upenn.edu/brainstorm/index.cfm...

I think it's not just about getting sued, but the whole package:

It's cheaper, faster, more maintainable, more accessible, has the benefit of being the right thing to do vis-a-vis the disabled, and if you don't move this way you could possibly be sued.

Plus this is the future. It's not a question of if your sites will move this way, it's a question of when.

Whole lotta upside, not a whole lotta downside.
# Posted By Terrence Ryan | 9/6/07 12:40 PM
@Terrance, Nice link, nice summary. Agreed.

Thanks everyone!
# Posted By Peter Bell | 9/6/07 12:44 PM
It's actually very similar to MVC. CSS is the presentation layer while HTML is the content layer and JavaScript is the behavior layer. So having that good separation counts to make things more flexible and easier to maintain.

Another benefit I'd add to that list is lightweight and interchangeability. By taking the presentation out of your content file size is reduced and the CSS is cached enhancing performance. Also stylesheets can easily be swapped in and out with JavaScript or based on media type. No more print pages, let CSS handle it for you! Need specific CSS for handheld devices? Then create a new CSS document to set styles whenever a handheld device is viewing the site.

Out of curiosity what books on CSS have you been reading? Or have you only been reading online materials? I'd be more than happy to make some book suggestions. How are you enjoying the book I gave you?
# Posted By Javier Julio | 9/6/07 12:59 PM
@Javier,

Nice comparison to MVC - thanks! (Hope you had a good time in NYC?)

I read two books - the Bulletproof one you provided and the first edition of "CSS Anthology: 101 Essential Tips, Tricks & Hacks ". I'm also looking to read Designing with Web Standards by Jeffrey Zeldman. Any other suggestions for the latest best practices?

I'm also checking out Smashing Magazine, Subtraction (Knoi Vinh's blog) and A List Apart - all of which seem to have great content online - any other blogs/sites you'd recommend?
# Posted By Peter Bell | 9/6/07 1:34 PM
As far as I'm concerned you are already a CSS expert with that list! Make sure you pick up the new second edition of Zeldman's book. If you haven't gotten it yet I can always give you my copy. Other books I highly recommend are:

Web Standards Solutions (by Dan Cederholm)
CSS Mastery: Advanced Web Standards Solutions (by Andy Budd)
DOM Scripting (by Jeremy Keith)

Those are just 3 names of a bunch you should be familiar with. They are celebrities in the web standards world. You not getting those books is not an option. You have been warned. :) Thanks Peter I had a great time in NYC. When I'm there next we should hang out again for dinner. My best friend had a lot of fun as well. The sushi/tapas were great.
# Posted By Javier Julio | 9/6/07 1:59 PM
Thanks for the recommendations! Let me know when you're back in NYC although I'm leaving September 19th for a while . . . Glad you enjoyed the "tapas"!
# Posted By Peter Bell | 9/6/07 2:40 PM
I don't deal with SEO stuff, but I do deal with CF Development / XHTML / CSS on a daily basis. I was until this past year, a subscriber to the "yeah, css-whatever" club. I had bought books, I understood the theory behind it all, but it was too much of a hassle for me to really sit down and go through all my code.

This past year, I've had the lovely pleasure of rewriting our administrative portal (for internal and clients). I made it a challenge to really nail down css/xhtml and try to keep this as efficient as possible. I use table for tabular data only and any one-off/weird forms layouts that the designers insist we make.

Honestly, at first, I didn't see a difference between the two sites until a co-worker got his hands on it. He had to repurpose the portal for another client and without touching a single CFM page, he was able to change the entire look and feel of the website by modifying the CSS file and a single template (a shell). I've never seen that before. He completely changed the entire look/feel of the website until it no looked like what I had started with.

Months later, I've seen at least 5-6 different iterations of the admin and it's all the same codebase behind the scene. The upgrade was well worth the cost it took me to develop. If there's a CFC with a bug, it gets replaced on all our existing sites that uses the new admin. There's been very little "functional" bugs. I have noticed a speed boost as well.

So, if you're the kind of a company that needs to redeploy and redevelop, the payoff doesn't seem worth it, but trust me when I say it is as it's immediately noticeable. If you're not the reploy and redevelop type of business, then... the cost in savings becomes apparent over time in bandwidth fees as you're paying less due to smaller and more efficient xhtml/css coding.
# Posted By Todd Rafferty | 9/6/07 3:01 PM
Cool - thanks!
# Posted By Peter Bell | 9/6/07 3:19 PM
I think we are slow in seeing the benefits of CSS because we have the use of variables and IF/THEN statments when we use ColdFusion.
Try thinking about how CSS solves some issues without the aid of a programming language.
media="print" is very powerful for hiding certain sections.

But I wonder if CSS will be replaced very quickly. It looks almost like assembler language programming in my opinion.
# Posted By Phillip Senn | 9/12/07 5:24 PM
css layer examples / properties and layer attributes
http://css-lessons.ucoz.com/css-layer-properties.h...
# Posted By gallery | 7/15/08 10:52 AM
BlogCFC was created by Raymond Camden. This blog is running version 5.005.