CSS shadow effect

I know, we said we’ll focus on WordPress tutorials but, I can’t resist sharing cool CSS tricks from time to time like this one CSS shadow effect we’ve used for our Vela theme. If you take a look at Vela header you’ll see h1 and h2 text with blog title and description. Vela comes with two different background images, one is very colorful and the other one is dark, so to keep text readable in this situation you have to use shadow or text border. And since there’s no enough support for text-shadow CSS3 property (only for Safari so far) you have to improvise.

shadow

What we’re going to use is pure CSS solution, but you can use for example some JavaScript with a simple loop or something… Here’s the code and after that an explanation.

<h1><span><a href="#">Some text</a></span>Some text</h1>
h1 {
        font-size:26px;
        font-weight:bold;
        color:#111;
}

h1 span{
        position:absolute;
        margin:-1px 0 0 -1px;
        color:#fff;
}

Yes, that’s all! Key element is span tag with same text which is positioned absolute and moved a bit. You can place it in any tag you want and also add links and everything like in example. This is tested on FF, IE6, IE7, IE8, Opera, Chrome and Safari.

Posted by: ThemeGalaxy on February 26, 2009
Easy To Customize

Theme Galaxy's WordPress themes are easy to understand and to edit within the WordPress Administration panel, allowing you to flexibly customize your theme.

Save CPU + Memory

Website templates from Theme Galaxy have been built lightly, incorporating optimized code, to help you save substantial CPU + memory usage on your server.

Up-To-Date WordPress

Our cutting-edge premium WordPress themes are compatible with the latest WordPress version release 3.3, and also work well with previous versions.