Taking full advantage of CSS
CSS (Cascading Style Sheets) offers many more benefits beyond that of streamlined web pages with table-less layouts and precise positioning (no more transparent 1-pixel spacer GIFs!), mentioned in my previous post. Indeed, that’s just scratching the surface of CSS.
Here are some more clever things you can do with CSS to get your website really humming:
- Reorder your content to sit above your top and left navigation in the HTML. That will boost the keyword prominence on your pages, which is good for SEO. Then use CSS to get the page to still display as you want. CSS Zen Garden is a great example of this in action… for example, notice how the HTML doesn’t change between this layout with left-side nav and this one with right-side nav; it’s only the CSS that’s changing.
- If you must use graphical navigation or headings instead of text-based, then use the CSS “image replacement” technique to substitute in a text link or heading tag, respectively, when the CSS is not loaded (as is the case when the search engine spiders come to visit). For example, northland.edu uses this technique well. Currently, this is much more effective for SEO than Alt attributes.
Many of the image replacement techniques physically move the text off the screen (text-indent: -9999em; left:-9999em;display:none, etc). This isn’t desirable as search engines are starting to examine external CSS files more closely to look for spam. There are a few image replacement techniques that don’t do this type of hiding and are still accessible, namely The Leahy/Langridge Method, The Gilder/Levin Method and The “Shea Enhancement”. Each of these methods have their pluses and minuses, which the Mezzoblue article outlines quite well. (Thanks to our CSS guru Darren for this last bit of advice.)
- Learn to code in “CSS shorthand.” With shorthand, hex codes for colors, margins, box dimensions and borders can all be abbreviated, for instance. More about this here. The efficiency of CSS shorthand translates into not only a speedier download for your customers, but also compact and tidy code that’s easier to maintain.
- Make code that “degrades gracefully” (or, as they prefer to say now in geek circles, “enhances progressively”). Creating a separate “low-bandwidth version” or “printer friendly version” or “mobile version” of your site will sound ludicrous in years to come (heck, I think it sounds ludicrous NOW!), because CSS makes such a thing unnecessary. Check out how gracefully gotomedia.com degrades on a cell phone or PDA, for instance.
- Correct for browser incompatibility snafus with browser-specific CSS. Does something look awry in your page layout when loading your site with the Safari browser, for instance? Internet Explorer doesn’t always play nice with the other browsers. Until the days where all the browsers follow all the same standards to the letter, browser-specific stylesheets are a useful crutch.
- Separate the presentation layer from the content layer as much as possible and move it into an external stylesheet (in other words, a separate .CSS file). That way it gets cached by the web browser and doesn’t have to reload with each new page.
- Plan for site-wide changes. Things change — colors, sidebars, ads, copyright dates, etc. Utilize CSS files and/or server-side includes to make future site-wide updates as painless as possible.
- Make use of the cascading nature of CSS. Most of the styles you define will be used site-wide. Some will only be for one particular page. Then there will be occasions where you’ll want to “cascade” styles, and have certain sections of your site adopt a particular look/layout/theme that overrides or branches off from the site-wide styles. Clever use of cascading styles can lead to very efficient and elegant code.
Warning! Geek speek ahead:
Be careful of overriding previously declared statements. And also be aware that specificity is important in the cascade. Declare all your tag styles first then declare your id and class selectors down the doc. That way the cascade works and can be overwritten with new selectors. (Thanks again to our CSS guru Darren for this last bit of advice.)
CSS coders: the Web Developer Firefox extension is an awesome tool for coding, debugging, and tweaking style sheets. You can display the stylesheet and the rendered page simultaneously side-by-side and then interactively edit the CSS, immediately viewing the effect of the change on the rendered page. And it makes identifying errors (be they validation, CSS, or JavaScript) a piece-of-cake. Did I mention the plugin is free? 🙂
Comments

Chapter 7:
Content Marketing
From the fundamentals of link building to the nuances of natural linking patterns, virality, and authority.
Related Posts

Your Ultimate Guide to Google Penalties
When your website’s traffic suddenly takes a tumble and you don’t know why, it can be maddening. Why is this happening? It’s possible you’ve been hit with a Google penalty, or have come up against one of Google’s algorithm updates. If you’re wondering how Google penalties work and what you should do to avoid them, […]
Read More
Using Psychology to Boost Your Conversion Rate Optimization
Can a better understanding of the human brain help you get more conversions? Absolutely! Let’s look at how to incorporate some psychological concepts into your conversion rate strategy, along with some examples. Behavioral economics: humans are irrational What is behavioral economics and what does it have to do with conversion rates? Traditionally, economists believed that […]
Read More
How to Master Social Selling on LinkedIn
Social selling could be your key to securing new prospects and boosting your bottom line. When not done properly, however, social selling can also ruin your online presence and repel potential customers. So what is social selling, and why does your brand need it? More importantly, how do you master social selling? Let’s look at […]
Read More