CSS Shadow
Learn how to add depth and dimension to your web elements using CSS shadow effects
Knowing how to add drop shadow effects with the CSS syntax and style text and elements the way you like allows you to make your designs more realistic.
When an object, like a tree or building, obstructs a light source, it creates a shadow. Likewise, an element on a page casts a shadow, giving the impression that it's raised above other elements behind it.
A raised button, for example, signals that the element is interactive, and users can click it. Above all, shadows indicate the hierarchy of elements and make designs look more natural and aesthetically appealing.
The text-shadow
property allows us to add one or several
With text-shadow
property, the box-shadow
Keep in mind that the order of values matters: offset-x offset-y blur-radius color. Otherwise, the browser won't apply the shadow.
The color
value is optional when specifying shadow parameters with the box-shadow
color
property value) for your
To specify the color value, you can use multiple options:
- HEX colors
- RGB/RGBA colors
- HSL/HSLA colors
- Predefined color names
Shadow blur-radius
value of the box-shadow
property defines how far the blurring spreads, and the larger the blurring, the more prominent it gets.
The blur radius can be specified in different length units, like
Pro Tip: If you omit the blur-radius
value or set it to 0, the shadow edges will be sharp.
Horizontal and vertical offset values of the box-shadow
property specify the position of a
- The horizontal offset — the x-axis value — can be positive, and the shadow will be on the right of the box. A negative offset value puts the shadow on the left of the box.
- The vertical offset — the y-axis value — can be positive, and the shadow will be below the box. A negative value sets the shadow above the box.
The correct text-shadow
. Like other
{
text-shadow: 1px 1px 2px red, 0 0 4px blue, 2px 2px 6px yellow;
}
The correct answer is the box-shadow
The first two values of the text-shadow