CSS Zen Garden Tips
So I've been singing their praises, so OK, seriously what can we learn from them...
Think About Your Images and How You Use Them - They Are Important
There are two ways to add an image: the <img> tag and background property in CSS. It does make a difference. CSS Zen Garden has no image tags. When you consider their experiment it's clear why. For their very particular website, if they included an image... any image, it would be an element that every designer would have to incorporate into their design. Therefore, the website was constructed without a single image tag. Do you miss them?? Take a look at the amazing and beautiful effects they achieve using only CSS background images. It's nothing short of amazing. The lesson for the rest of the internet is simple... You never need to use an <img> tag. It's completely unnecessary with the power of CSS.
Did you hear me right? Never use an <img> tag? Well, that's not quite what I said. I said you never need to. If you want to beautify your website, CSS Zen Garden shows you how to do that without a single image tag. By applying background images to your elements you can go a long way. And when you hit a wall? Well, take a page from Dave Shea's book, cheat. CSS Zen Garden has a set of six divs with the id "extraDiv" 1-6 built in. This is brilliant! You have what passes for six image tags that you can style and position at will anywhere on the page. You probably won't need them all, but they are a great way to avoid <img> tags in your website design. So maybe you add an <img> tag, but you also have another tool in your web developing toolbox, these "fake" image tags.
So when should you use which? What's the best practices? Here's the question I ask. When I was learning accessible web design, I was told to include a descriptive alt attribute to all images that added to the content of the page, and any image which did not, set the alt attribute to "", empty. That way accessible devices will ignore them. Well, if it doesn't add to the content you're trying to convey, why not stick it in the stylesheet instead. Which means you should absolutely use <img> tags, but only when the image provides information / content that you want to use in the page. If not, add the image using the background property of CSS.
Spans Rock
OK, I'd never thought about this much. I'd used spans for what I think most people did, an inline level element to mark up text as opposed to block level elements like divs. Well, since Dave Shea got his hands on an article by Douglas Bowman on www.StopDesign.com it's not your grandma's span tag anymore. Douglas Bowman established the world's best technique for replacing text with images. It's unparalleled; not just because it's so effective and works beautifully, but it's so simple. Identify the element in a style rule, and apply a background image that replaces the text, then you target the span inside it and set it to display:none which vanishes the original text, leaving only the image. Yet, the HTML has no <img> tags running around getting in the way, and all the information is present in text form for accessible technologies. As far as those devices are concerned there aren't even any images because all the "magic" is in the stylesheet; all that's there is text and the text is all there. This is elegant, SEO-friendly, and highly accessible.
Now this is an area where CSS Zen Garden is a little overbuilt. In a normal webpage you don't need a span tag nested inside every single element. In order to give designers maximum flexibility with this template, Dave Shea put spans everywhere. However, if you have anything on multiple web pages, then just like CSS Zen Garden, it might not be a bad idea to include a span on those items in case you need to do an image replacement down the road in some future redesign. In most cases, it's not that hard to go back in our sites if it turns out we change our mind later. If it would be, then be proactive about adding the span just like CSS Zen Garden.
So is that all you can do with spans? Not hardly. Here's another cool trick. Background images are limited. Any element just about, can take a background image, however it can only take one. If you apply a second background image to an element, it cascades and the second image eliminates the first. Well, spans can help with that. If you nest a span tag inside the element that gives you a second targetable element to apply a background image to. So while you can still only apply one image to your <h2> element, you can also target the span inside it doubling how many background images you can use. Pretty slick.
Skip to Main Points