Hi, I'm Meagan Fisher, a designer living in Brooklyn. I make websites, eat food & love owls.

Shadows and CSS3

I’m currently working on a design that uses text-shadow and box-shadow, with RGBA in place to create the shadow color. I wanted to tweet about this technique because it’s simple and awesome, but to my surprise I couldn’t find a good, quick tutorial that covered the use of both text and box-shadow, along with RGBA. So I decided to create one.

I learned this technique from Dan Cederholm’s Handcrafted CSS book, so if you’re able I’d recommend just going out and grabbing that, as he explains it much more elegantly and thoroughly than I ever could.

Text-shadow

Applying text-shadow to elements is easy, and coupled with RGBA it works beautifully. Since both text-shadow and RGBA are supported by Safari, Firefox, Konqueror, and Opera, why not start playing with them now?

Text shadow is sexy.

If you’re using one of the aforementioned browsers, you should see a nice drop shadow on the text above. (If you’re not — why?) This drop shadow is created using the following code:

text-shadow: 1px 1px 1px rgba(0,0,0,.4);

Breaking it down

  • The first 1px indicates how much the shadow should be offset horizontally; in this case we’re telling the shadow to appear one pixel to the right. Using -1px would move the shadow one pixel to the left.
  • The second 1px indicates how much the shadow should be offset vertically; in this case we’re telling the shadow to appear one pixel lower than the text. Using -1px would move the shadow one pixel above the text.
  • The third 1px value tells the shadow how much it should blur. Using 0 for this value would create a solid drop shadow, which has a blocky, high-contrast effect. Using only this value (ex. text-shadow: 0 0 1px rgba(0,0,0,.4);) would create an outer glow.
  • rgba(0,0,0,.4); gives the shadow its color. In this case we’re using (0,0,0), which is the RGB value for black, and we’re giving that black an opacity of 40%, or .4.

Why use RGBA for the shadow color?

Using RGBA instead of a solid color for the shadow is great because it allows some of the page’s background color to bleed through. This means that the shadow will blend nicely with the page’s existing color scheme, and if you ever change up the site’s background color your shadows will change too. If you’re unclear about how rgba works, check out Drew McLellan’s 24ways article.

So now you should be able to implement text-shadow and RGBA in your designs. This technique is very powerful, as it can be used to make text jump off the page:

Text shadow is sexy.

or appear to be set into the page:

Text shadow is sexy.

Box shadow

Once you know how to use text-shadow + RGBA to achieve drop shadows, you’re well on your way to mastering box-shadow. The syntax is exactly the same, so box-shadow: 0 1px 10px rgba(0,0,0,.1); will create a black shadow at 10% that’s centered horizontally, one pixel down, with a ten pixel blur.

test image

Misty the one-toothed cat thinks box shadow is awesome.

Box shadow is supported in Safari and Firefox 3.5, but like border-radius it requires the use of vendor-specific properties. So assuming we wanted to add a drop shadow to an image in Safari and Firefox, here’s how we’d code it:

-webkit-box-shadow: 0 1px 10px rgba(0,0,0,.1);
-moz-box-shadow: 0 1px 10px rgba(0,0,0,.1);
box-shadow: 0 1px 10px rgba(0,0,0,.1);

You’ll notice I included the standard box-shadow property; this is in place for future browsers who may one day support this property.

There you have it! Once again your shadow blends nicely with the background because you’re using RGBA, and creates a kick-ass 3-D effect with minimal markup.

Box-shadow and text-shadow may not be for every project, but since they’re so easy to implement and browser support for these features is growing, why not try them out?

I can hear some of you naysayers yelling about Internet Explorer, but really is it so bad if some users get to see shadows and some don’t? The design won’t be broken for IE people, they’re just missing out on a few visual treats that other users will see.

If you’re not sold on the argument that we should reward users who choose modern browsers, check out Dan’s Handcrafted CSS book, Aaron Gustafson’s A List Apart article and Andy Clarke’s multiple well written articles on the subject.

114 Responses

Yay, I love this!! Thanks for sharing Meagan!

Maddie

Your Cat Misty looks like a pirate… yarrr.
And text shadow is sexy…

Matt

Nice to see a writeup of how text-shadow exactly works. I’ve been using it for a while but haven’t known fully what each variable does.

Thanks, Meagan :)

Matthew Kempster

Nice read… thanks for posting.

“I can hear some of you naysayers yelling about Internet Explorer, but really is it so bad if some users get to see shadows and some don’t? The design won’t be broken for IE people, they’re just missing out on a few visual treats that other users will see.”

Totally agree with this statement, it is time to move forward!

~ Aaron I

Aaron Irizarry

Megan thanks so much for posting this. Awesome work!

Gedy

Great writeup. I’ve been sneaking more and more bits like this, as well as -webkit and -moz declarations, just to spruce things up for the more browser-savvy crowd.

Thanks for the article. My favorite part was the part with the cat. In the middle there.

Jordan Little

I’m a fan of graceful degradation using things like this. Forget IE users; just give the extra niceties to those with relevant browsers. WordPress’s admin area does a good job of this — rounded corners everywhere and lots of shadows too while IE users see squares and no shadows.

kylegetsspam

Awesome stuff. I learn something new everyday!

John Stone

Thank you for sharing this, Megan. Just last night I was messing around with gradients on Illustrator for use on a web page to give CSS-generated boxes drop-shadow like effects. Your tutorial gives me one more option. {:)

Paras G.

Box-shadow has been dropped from the spec, so this probably won’t continue to work in it’s current form, unless it gets dropped back in.

http://www.w3.org/TR/css3-background/#the-box-shadow

Andrew

Very detailed and crisp! Rock hard CSS3 hardrock!

Edgar Leijs

The very thing that I’ve been looking for, thanks for setting out in simplicity for us all

Dan

Great post! I was just recently browsing through your site as you were on the “40 Amazing Female Role Models for Web Designers” list, and today found this article from CSS Beauty News. Good work :)!

Haven’t seen too many sites yet utilizing text-shadow but just yesterday I stumbled on http://analog.coop/, they use a subtle off-white text-shadow on all text (shadows are not in rgba but text colours are). Looks nice!

Jemiina Hautamäki

Your blog is really beautiful!

Hafeyang

That is pretty sweet, dude.

Mike Rouse

YEP! thanks for share skills! i got it now

andrew

[...] via Owltastic — by Meagan Fisher. [...]

Owltastic — by Meagan Fisher « amelia a earhart

Sweet, Thanks for posting this

Siegfred

I hope it will be supported by Microsoft soon

fsmedia

Really beautiful post… Thanks.

-Deepu

Deepu Balan

You can get the same effect in IE using filters:

p{filter:progid:DXImageTransform.Microsoft.Shadow(color=’#000000′,direction=135,strength=2)}

(adjust properties accordingly)

There are performance issues so it’s not for every site but it could be useful to a client who demands it work in IE.

Bill H

Thanks. But hey, I hope people won’t use it to often. I remember when Photoshop add the shadow feature for fonts. After that the whole web was overshadowed :-(

Oli

Thanks for the tip, I’m implementing this tonight. Bonus: works on the iPhone.

Netpaths

Great post! Can’t wait to try it out

Phil

Great post Meagan. CSS3 ftw!

Andrew

Wicked thank you, great post!

Dan

Well explained. Thanks for sharing the info.

RaphaelDDL

Found your site through your 24 Ways article on “Making Your Mockup in Markup” – thanks so much for this informative article on these two “new” selectors – I now understand them and feel confident in using them in my work!

Laneth Sffarlenn

First of all I love love love your site, it’s so beautifully designed.

Great post, you really explain text-shadow and box-shadow well. I am just getting in CSS3. Thank you.
Idil

Idil

I realized the power of this a few weeks ago while writing a plugin for WordPress to get images from flickr. I wanted the images to have drop shadows, but when one user put the plugin on a site with a dark background the shadows were too light. Now I’ve started using RGBa for all the shadows that I need.

Josh

[...] Dan Cederholm teach this at An Event Apart and in Bulletproof Web Design. Meagan Fischer also has a recent tutorial with black as the example shadow color. Dan and Meagan are better designers and smarter people than [...]

Don’t Use Black for Shadows | E Marketing, Web Design, Web Develop, SEO and SEM Egypt Blog

Thank you for bringing together two of my greatest loves: Owls and CSS3 tricks.

devolute

Like another commenter, I also came across this post via your 24 Ways article on “Making Your Mockup in Markup”.

Misty is one smart cat! Thank you for sharing how to make this happen. I cannot wait to try it out. And others have said it, and I will say it too… your website is quite lovely.

Stacy

Shadows and CSS3…

Applying text-shadow to elements is easy, and coupled with RGBA it works beautifully. Since both text-shadow and RGBA are supported by Safari, Firefox, Konqueror, and Opera, why not start playing with them now?…

You are now listed on FAQPAL

[...] full post on Owltastic [...]

Shadows and CSS3 — MooTools and CSS Resources

[...] вариант на статийката тук : http://owltastic.com/2009/12/shadows-and-css3/ Share this [...]

CSS3 и сянката… « Борис Делев

all nice and well, but unless Microsoft finally develops a compliant browser all these techniques are only visible to a minority of page visitors. Worse: in IE8 you only see, instead of a nice text shadow, a badly rendered text with a jagged edge = not at all an attractive design for 60%+++ of all site visitors!

Juergen

I use text and box shadow on my site.
Do you know if there is any possibility to validate this ?

Great post Cheers

Theo

oh god… i hate IE

tanya singh

[...] A wide and closeup view of the design with gradients, text-shadow and box-shadow added. For information on how to implement text-shadow and box-shadow using RGBA, check out the article I wrote on it last week. [...]

Make Your Mockup in Markup | Reincarnationlab

[...] property it’s now simple and easy to create the effect with pure CSS. No Photoshop trickery here!Shadows and CSS3I’m currently working on a design that uses text-shadow and box-shadow, with RGBA in place to [...]

50 Brilliant CSS3/JavaScript Coding Techniques - Smashing Magazine

Box-shadow and drop shadow are good, but how to make the shadow look like a glow.. outer glow.. like shadow in but it’s spread to every direction.. is that possible?

Adods

[...] Shadows and CSS3I’m currently working on a design that uses text-shadow and box-shadow, with RGBA in place to create the shadow color. I wanted to tweet about this technique because it’s simple and awesome, but to my surprise I couldn’t find a good, quick tutorial that covered the use of both text and box-shadow, along with RGBA. So I decided to create one. I learned this technique from Dan Cederholm’s Handcrafted CSS book, so if you’re able I’d recommend just going out and grabbing that, as he explains it much more elegantly and thoroughly than I ever could. [...]

50 Brilliant CSS3/JavaScript Coding Techniques » Shai Perednik.com

Great one.. but IE not supporting

Srinivas Tamada

[...] Shadows and CSS3I’m currently working on a design that uses text-shadow and box-shadow, with RGBA in place to create the shadow color. I wanted to tweet about this technique because it’s simple and awesome, but to my surprise I couldn’t find a good, quick tutorial that covered the use of both text and box-shadow, along with RGBA. So I decided to create one. I learned this technique from Dan Cederholm’s Handcrafted CSS book, so if you’re able I’d recommend just going out and grabbing that, as he explains it much more elegantly and thoroughly than I ever could. [...]

50 Brilliant CSS3/JavaScript Coding Techniques | Google Reader | Юлиян Попов

[...] property it’s now simple and easy to create the effect with pure CSS. No Photoshop trickery here!Shadows and CSS3I’m currently working on a design that uses text-shadow and box-shadow, with RGBA in place to [...]

寂静小站 – 网摘 » 50 Brilliant CSS3/JavaScript Coding Techniques

[...] Shadows and CSS3I’m currently working on a design that uses text-shadow and box-shadow, with RGBA in place to create the shadow color. I wanted to tweet about this technique because it’s simple and awesome, but to my surprise I couldn’t find a good, quick tutorial that covered the use of both text and box-shadow, along with RGBA. So I decided to create one. I learned this technique from Dan Cederholm’s Handcrafted CSS book, so if you’re able I’d recommend just going out and grabbing that, as he explains it much more elegantly and thoroughly than I ever could. [...]

50 Brilliant CSS3/JavaScript Coding Techniques | XtremelySocial.com

Great post, using your css technique will greatly help reduce graphical effects used. It will be awesome when all browsers recognize it.

Thanks for sharing and keep ‘em coming.

Memphis Web Design

Very nice work…thanks for sharing…

Karthi

[...] Shadows and CSS3I’m currently working on a design that uses text-shadow and box-shadow, with RGBA in place to create the shadow color. I wanted to tweet about this technique because it’s simple and awesome, but to my surprise I couldn’t find a good, quick tutorial that covered the use of both text and box-shadow, along with RGBA. So I decided to create one. I learned this technique from Dan Cederholm’s Handcrafted CSS book, so if you’re able I’d recommend just going out and grabbing that, as he explains it much more elegantly and thoroughly than I ever could. [...]

50 Brilliant CSS3/JavaScript Coding Techniques | Web Design Cool

[...] Shadows and CSS3 I’m currently working on a design that uses text-shadow and box-shadow, with RGBA in place to create the shadow color. I wanted to tweet about this technique because it’s simple and awesome, but to my surprise I couldn’t find a good, quick tutorial that covered the use of both text and box-shadow, along with RGBA. So I decided to create one. I learned this technique from Dan Cederholm’s Handcrafted CSS book, so if you’re able I’d recommend just going out and grabbing that, as he explains it much more elegantly and thoroughly than I ever could. [...]

50 Brilliant CSS3/JavaScript Coding Techniques | Vectordump

[...] Shadows and CSS3 I’m currently working on a design that uses text-shadow and box-shadow, with RGBA in place to create the shadow color. I wanted to tweet about this technique because it’s simple and awesome, but to my surprise I couldn’t find a good, quick tutorial that covered the use of both text and box-shadow, along with RGBA. So I decided to create one. I learned this technique from Dan Cederholm’s Handcrafted CSS book, so if you’re able I’d recommend just going out and grabbing that, as he explains it much more elegantly and thoroughly than I ever could. [...]

50 Brilliant CSS3/JavaScript Coding Techniques « Social-Press

This is really good one.

Ganesh

This is really good one.

creativegrafica

Shadows non IE :(

StaLker

[...] 18.) Shadows and CSS3 [...]

25 Useful CSS3 Techniques and Tutorials | DSpot Inc

I would say that your text shadows are sexy, but that’s because you’re being very subtle about them. I think that too much shadow is a bad thing. Hopefully CSS3 people will not resort to dark drop shadows behind everything. It’s all in the tiny details.

Courtney Kirchoff

good idea Thank

jackiller

[...] Shadows and CSS3 I’m currently working on a design that uses text-shadow and box-shadow, with RGBA in place to create the shadow color. I wanted to tweet about this technique because it’s simple and awesome, but to my surprise I couldn’t find a good, quick tutorial that covered the use of both text and box-shadow, along with RGBA. So I decided to create one. I learned this technique from Dan Cederholm’s Handcrafted CSS book, so if you’re able I’d recommend just going out and grabbing that, as he explains it much more elegantly and thoroughly than I ever could. [...]

50 Brilliant CSS3/JavaScript Coding Techniques | Top Web Hosts Review Best Web Hosting 2010

[...] text shadow elements. This effect is becoming hugely popular in web design through the internet.Owltastic Effect – Design your text-shadow and box-shadow elements to look great on your web design with nice and [...]

Essential CSS3 Resources

[...] added. For information on how to implement text-shadow and box-shadow using RGBA, check out the article I wrote on it last week.37 pieces of flairOkay, maybe you don’t need that much flair, but it couldn’t hurt to [...]

Make Your Mockup in Markup - Everything You Need - Basic Web Design

Love it. IE users will come round eventually.

This is a beautiful site.

Tom Fallowfield

http://www.islamabadid.com/listen_to_fm_radios_islamabad/fm_100_islamabad/

I want to change the background of the above page

Can any body help me

Abdul Wakeel

[...] Shadows and CSS3 I’m currently working on a design that uses text-shadow and box-shadow, with RGBA in place to create the shadow color. I wanted to tweet about this technique because it’s simple and awesome, but to my surprise I couldn’t find a good, quick tutorial that covered the use of both text and box-shadow, along with RGBA. So I decided to create one. I learned this technique from Dan Cederholm’s Handcrafted CSS book, so if you’re able I’d recommend just going out and grabbing that, as he explains it much more elegantly and thoroughly than I ever could. [...]

50 Brilliant CSS3/JavaScript Coding Techniques |

[...] Shadows and CSS3 [...]

More Best Resources About CSS3

[...] A wide and closeup view of the design with gradients, text-shadow and box-shadow added. For information on how to implement text-shadow and box-shadow using RGBA, check out the article I wrote on it last week. [...]

Make Your Mockup in Markup

[...] Shadows and CSS3 Animation [...]

How to Learn CSS3 | [Re]Encoded.com

Text shadows ARE sexy! Lovely article introducing me to CSS3, thanks for showing me how it is done

Rory

[...] Owltastic Effect – Design your text-shadow and box-shadow elements to look great on your web design with nice and effective text effects. [...]

Essential CSS3 Resources : Adsensefeed.com

[...] Shadows and CSS3 I’m currently working on a design that uses text-shadow and box-shadow, with RGBA in place to create the shadow color. I wanted to tweet about this technique because it’s simple and awesome, but to my surprise I couldn’t find a good, quick tutorial that covered the use of both text and box-shadow, along with RGBA. So I decided to create one. I learned this technique from Dan Cederholm’s Handcrafted CSS book, so if you’re able I’d recommend just going out and grabbing that, as he explains it much more elegantly and thoroughly than I ever could. [...]

50 Brilliant CSS3/JavaScript Coding Techniques | Geek is a Lift-Style.

Finally I found clear and step by step tutorial how to use shadows properties in css 3. thanks

Alif

I don’t use shadows very often (I do software, not design), but when I do, I come here for reference. It happens to be exactly one year after this post was written, but I can’t remember a time when I didn’t use this as my reference for box- and text-shadow. Thanks.

Andrew

It also works in Chrome. :)

dxo

[...] Shadows and CSS3 [...]

More Best Resources About CSS3 | Cruz3N Blog

box-shadow also has an optional ‘spread radius’ value

Nicolas Gallagher

[...] owltastic.com/2009/12/shadows-and-css3/ [...]

css

[...] 12. Shadows And CSS3 [...]

70 Must See CSS3 Tips, Tricks And Tutorials

Text shadows is useful but only in places where you want an image to stand out that little bit more.As some one already pointed out too much shadow is a bad thing. With using CSS3 shadow people will have to sort out that detail them selfs. So taken that in to account Text shadow can be sexy at times.

Me

[...] Shadows And CSS3 [...]

50 Excellent CSS3 Tutorials | psdtohtmlguide

Shadows and CSS3 works in Chrome but not as good I think.

RayRogers

Thanks a lot for another great tutorial. This website has been my gateway to HTML 5 and CSS 3.

Rohit Mishra

[...] article contains a simple and easy to implement tutorial about using the @font-face property.Shadows and CSS3 design that uses text-shadow and box-shadow, with RGBA in place to create the shadow color. I wanted [...]

50 CSS3 Tutorials Every Designer Should See

I like the letter press ideas, I wanted to let you know I’ll be using it on my site!!

- Aaron

Solar Monster

[...] 50 Excellent CSS3 Tutorials Example: Selectors Introduced In CSS3 40 Brilliant CSS3 Techniques and Tutorials Example: Shadows and CSS3 [...]

Web & Programming Tutorials Roundup | Freelance Flux

[...] 50 Excellent CSS3 Tutorials Example: Selectors Introduced In CSS3 40 Brilliant CSS3 Techniques and Tutorials Example: Shadows and CSS3 [...]

Web & Programming Tutorials Roundup

I will be using this effect when I get my site up and running. Thanks for this tutorial, never underestimate the power of CSS!
-Joe

Bloodstock Tickets

[...] Shadows and CSS3 [...]

24个CSS3文本效果示例教程-站博

[...] Shadows and CSS3 [...]

CSS3 drop shadow

I have been browsing online more than three hours today, yet I never found any interesting article like yours. It is pretty worth enough for me. In my view, if all web owners and bloggers made good content as you did, the internet will be much more useful than ever before.

Rob Benwell Wiki

Hello there, just became aware of your blog through Google, and found that it is really informative. I am gonna watch out for brussels. I will be grateful if you continue this in future. Numerous people will be benefited from your writing. Cheers!

Esp Bass

I agree. The cat is definitely stashing some pieces of eight!

Oliver

[...] compatibility isn’t really an issue for this technique.I should note that I’m not the first to come up with this technique, and that it isn’t perfect. Chris Coyier argues against it, [...]

Better CSS Shadows | The Internet Rhetorician

[...] Shadows and CSS3 [...]

24 cool CSS3 text effect examples and tutorial

Thanks for the info, I have been helpful.

PD: That cat’s a little scary xD

Diseño Web Terrassa

[...] Shadows and CSS3 – Meagan Fisher [...]

Cascading Style Sheets Reference Links | kabayview.com

People who use IE hate the internet. Fact.

DMC

Leave a Reply

A quick overview

Raised in Florida, a new New Yorker via Boston. When not making websites, I try to write and speak about making websites.

Read more about me

Latest Tweet

Can I take out a restraining order on @LinkedIn? It's been over a year since I closed my account, but I still get weekly emails. Stalkers!

Follow owltastic on twitter