PSD to HTML conversion PSD to HTML conversion PSD2HTML.com with over 300 professionals takes the designs to HTML and beyond

Code Snippet

Home » Code Snippets » CSS » CSS Text Shadow

CSS Text Shadow

Regular text shadow:

p { text-shadow: 1px 1px 1px #000; }

Multiple shadows:

p { text-shadow: 1px 1px 1px #000, 3px 3px 5px blue; }

The first two values specify the length of the shadow offset. The first value specifies the horizontal distance and the second specifies the vertical distance of the shadow. The third value specifies the blur radius and the last value describes the color of the shadow:

1. value = The X-coordinate
2. value = The Y-coordinate
3. value = The blur radius
4. value = The color of the shadow

Using positive numbers as the first two values ends up with placing the shadow to the right of the text horizontally (first value) and placing the shadow below the text vertically (second value).

The third value, the blur radius, is an optional value which can be specified but don’t have to. It’s the amount of pixels the text is stretched which causes a blur effect. If you don’t use the third value it is treated as if you specified a blur radius of zero.

Also, remember you can use RGBA values for the color, for example, a 40% transparency of white:

p { text-shadow: 0px 2px 2px rgba(255, 255, 255, 0.4); }

Subscribe to The Thread

  1. stencil says:

    For ‘shadow’ use black eg: rgba(0, 0, 0, 0.4);

  2. Dyllon says:

    i wish i had coda.. (i have windows)

  3. The Coda clips addition is a great feature Chris. Thanks.

  4. Kerr says:

    Love the coda snippet feature. Very nifty.

  5. Great job Chris! Loving the Coda addition.

  6. Oooh! Nice. And lovin’ Coda even more.

    Thanks!

  7. AWESOME! Yet another great feature to the site!

  8. Ryan says:

    Just another great reason why Textmate owns.

  9. Why doesn’t Firefox support CSS text shadows? Is there a workaround for FF?

  10. Dor says:

    Firefox latest does support it.

    You may have to use -mozilla-text-shadow. (Not sure though.)

  11. For firefox, just add a copy of those lines and replace “text-shadow” with “-moz-text-shadow”.

  12. Is there a way to be able to achieve this effect while still having valid CSS(2.1, I know it’s valid in CSS3, but I need it for CSS2.1 as well).

  13. stella says:

    nope -moz-text-shadow doesn’t work

  14. Kevin Oh! says:

    When using multiple shadows… are they rendered in the order they are listed? For example, if I have a 1px shadow could I accidentally cover it with a 3px shadow because I listed them in my CSS in reverse order?

  15. Scott says:

    isnt there any other way of using colours in the website codes without typing the color codes. e,g using the name of the colour like red instead of something like this #FFFFF

  16. Dominick says:

    Scott, you can use names of colors. Just use the name of the color in place of the hex value. The color “blue” is even used in this text-shadow example.

    You can find a list of supported CSS color names here:

    http://en.wikipedia.org/wiki/Web_colors

  17. Grazie per l’articolo, non puoi immaginare quanto mi sia stato d’aiuto!

    Complimenti per il sito!

  18. joska says:

    Hello
    Be aware that setting css3 text-shadow will affect the anti-aliasing in google chrome on windows.
    Make a try if you are using Microsoft windows and you will see that in chrome fonts are ugly if you use css3 text-shadow.
    check the bug report in the Google chrome help forum”.
    And by the way, thanks Chris for sharing your knowledge.

  19. Vicky says:

    Great!!!
    But it is not a valid property……

  20. This is nice to know. I have used it once or twice now.

  21. Finally! I find a straight forward way to use drop shadow with css. I’m a newbie so I appreciate your post. Thank you

  22. James says:

    props on the fools and horses reference :)

  23. esar says:

    Thanks for this Nice thread ;)

    I’m playing with it but I’m little confused about inner shadow!
    Is it possible or any way to use inner-shadow?

  24. Ana Lee says:

    Nice Tutorial!, The text-shadow property really rocks.

Speak, my friend

At this moment, you have an awesome opportunity* to be the person your mother always wanted you to be: kind, helpful, and smart. Do that, and we'll give you a big ol' gold star for the day (literally).

Posting tips:
  • You can use basic HTML
  • When posting code, please turn all
    < characters into &lt;
  • If the code is multi-line, use
    <pre><code></code></pre>
Thank you,
~ The Management ~