Curriculum
Course: CSS Advanced
Login

Curriculum

CSS Advanced

CSS Rounded Corners

0/1

CSS Border Images

0/1

CSS Color Keywords

0/1

CSS Text Effects

0/1

CSS 2D Transforms

0/1

CSS 3D Transforms

0/1

CSS Transitions

0/1

CSS Animations

0/1

CSS Tooltip

0/1

CSS Style Images

0/1

CSS Image Reflection

0/1

CSS Masking

0/1

CSS Buttons

0/1

CSS Multiple Columns

0/1

CSS User Interface

0/1

CSS Box Sizing

0/1

CSS Media Queries

0/1
Text lesson

Shadow Effects

 

IMG_3641

 

CSS Shadow Effects

Subsequently, incorporate a color for the shadow effect.

In the upcoming sections, you will explore the following properties for adding shadow effects in CSS:

  • text-shadow
  • box-shadow

CSS Text Shadow

The CSS text-shadow property adds shadow effects to text.

In its basic form, you define the horizontal shadow (2px) and the vertical shadow (2px).

IMG_3644

Example 

h1 {
  text-shadow: 2px 2px;
}

Subsequently, incorporate a color for the shadow effect.

IMG_3643

Example 

h1 {
  text-shadow: 2px 2px red;
}

Afterwards, introduce a blur effect to the shadow.

IMG_3645

Example

h1 {
  text-shadow: 2px 2px 5px red;
}

Below is an example illustrating white text with a black shadow.

IMG_3646

Example 

h1 {
  color: white;
  text-shadow: 2px 2px 4px #000000;
}

Here is an example displaying a red neon glow shadow.

IMG_3647

Example 

h1 {
  text-shadow: 0 0 3px #FF0000;
}

Multiple Shadows

To incorporate multiple shadows to the text, you can specify a comma-separated list of shadows.

Here is an example illustrating a red and blue neon glow shadow.

IMG_3648

Example 

h1 {
  text-shadow: 0 0 3px #FF0000, 0 0 5px #0000FF;
}

Below is an example demonstrating white text with black, blue, and dark blue shadows.

IMG_3649

Example 

h1 {
  color: white;
  text-shadow: 1px 1px 2px black, 0 0 25px blue, 0 0 5px darkblue;
}

The text-shadow property can also be utilized to generate a simple border around text, devoid of shadows.

IMG_3650

Example 

h1 {
  color: coral;
  text-shadow: -1px 0 black, 0 1px black, 1px 0 black, 0 -1px black;
}