XML technologies / CSS / CSS Cookbook / Typography for the web / Adding shadows to text
(Excerpt from “CSS Kochbuch” by Christopher Schmitt)
Problem
You want to add a shadow to heading text, as shown in the following figure.
Figure: HTML text with a drop shadow.
Solution
Use the property text-shadow to set the shadow’s colour and position.
h1 {
font-size: 2.5em;
font-family: Myriad, Helvetica, Arial, sans-serif;
width: 66.6%;
text-shadow: grey .15em .15em .15em;
margin: 0 0 0.1em 0;
}Discussion
The first value of the property text-shadow sets the shadow colour. Two values follow for the shadow’s offset from the HTML text. The first length specifies the offset on the x axis, and the second on the y axis. The fourth value of text-shadow sets the shadow’s blur radius. Higher values make the shadow blurrier.
The property text-shadow has not been part of the specification since CSS 2.1. Safari is the only known browser supporting it.
See also
More information on the property text-shadow is available in the CSS 2.0 specification.
Copyright of the German edition © 2007 by O’Reilly Verlag GmbH & Co. KG
You may print the online version for your private use.
Otherwise, this chapter from “CSS Kochbuch” is subject to the same conditions as the bound edition: the work, including all its parts, is protected by copyright. All rights reserved, including reproduction, translation, microfilming, and storage and processing in electronic systems.
O’Reilly Verlag GmbH & Co. KG, Balthasarstr. 81, 50670 Köln