← Learning Hub
Intermediate

Shadows, Gradients and Modern Effects

A few properties can make a plain page look modern and polished.

Modern websites use a small set of effects to show depth and focus: shadows lift cards off the page, gradients add energy to banners, rounded corners and blur make interfaces feel soft and friendly. All of these are pure CSS now - no image editing needed - so they're fast and easy to change.

Shadows

Example
.card   { box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12); }
.lifted { box-shadow: 0 1px 2px rgba(0,0,0,.08), 0 12px 28px rgba(0,0,0,.14); }  /* two shadows */
h1      { text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3); }

The numbers are: x-offset, y-offset, blur, (spread), colour.

Gradients

Example
<!DOCTYPE html>
<html>
  <head>
    <style>
      .box { height: 90px; border-radius: 14px; margin: 10px 0; color: #fff;
             display: grid; place-items: center; font-weight: bold; }
      .a { background: linear-gradient(135deg, #7c3aed, #db2777); }
      .b { background: radial-gradient(circle at top left, #fde68a, #f97316); }
      .c { background: linear-gradient(90deg, #22c55e 0%, #22c55e 60%, #e5e7eb 60%); color: #111; }
    </style>
  </head>
  <body>
    <div class="box a">Linear gradient</div>
    <div class="box b">Radial gradient</div>
    <div class="box c">60% progress bar</div>
  </body>
</html>
▶ Try it yourself

More modern tricks

  • border-radius: 50% on a square makes a circle (profile pictures).
  • object-fit: cover fills a box with a picture without stretching it.
  • aspect-ratio: 16 / 9 keeps a box's shape at any width.
  • backdrop-filter: blur(8px) blurs what is behind a see-through box (the "glass" look).
  • filter: grayscale(1) or brightness(0.8) changes how an image looks.
Example
<!DOCTYPE html>
<html>
  <head>
    <style>
      .avatar { width: 80px; height: 80px; border-radius: 50%; object-fit: cover; }
      .thumb  { width: 100%; max-width: 320px; aspect-ratio: 16 / 9; object-fit: cover; border-radius: 12px; }
      .glass  { margin-top: -60px; margin-left: 20px; width: 200px; padding: 12px; border-radius: 12px;
                background: rgba(255,255,255,.35); backdrop-filter: blur(8px); }
    </style>
  </head>
  <body>
    <img class="avatar" src="https://picsum.photos/200" alt="Profile photo">
    <br><br>
    <img class="thumb" src="https://picsum.photos/600/400" alt="Sample photo">
    <div class="glass">Glass card</div>
  </body>
</html>
▶ Try it yourself
Keep effects gentle. Soft shadows and one or two gradients look professional; too many make a page hard to read.
Key points
  • box-shadow adds depth; gradients blend colours.
  • border-radius, object-fit, aspect-ratio and filter are everyday tools.
  • Use effects gently.

📝 Test yourself

1. Which value turns a square image into a circle?
2. What does object-fit: cover do?
3. Fill in the gradient type that goes in a straight line:
background: -gradient(#7c3aed, #db2777);