Skip to main content
Albero Academy

Backgrounds, Borders & Shadows

Decorate boxes — background images and sizing, rounded corners, borders and outlines, and box & text shadows for depth.

Chapter 9CSS14 min readBeginner friendly
  • #CSS
  • #Backgrounds
  • #Shadows

Backgrounds, borders and shadows are the details that turn a plain box into a designed component. This chapter covers background images and positioning, border-radius, borders and the often-confused outline, and shadows for depth.

Backgrounds

background properties
.hero {
background-color: #0f172a;
background-image: url("bg.jpg");
background-size: cover; /* fill the box, cropping as needed */
background-position: center;
background-repeat: no-repeat;
}
/* Shorthand + multiple layers (a tint over an image) */
.card {
background: linear-gradient(rgb(0 0 0 / 0.4), rgb(0 0 0 / 0.4)), url("bg.jpg") center/cover;
}

Rounded corners

border-radius
border-radius: 12px; /* all corners */
border-radius: 12px 0 12px 0; /* per corner (TL TR BR BL) */
border-radius: 9999px; /* a pill / circle (on a square) */

Borders & outlines

border vs outline
border: 1px solid #e5e7eb; /* width style colour */
border-bottom: 2px solid #2563eb; /* one side */
/* Outline draws OUTSIDE the border and doesn't affect layout —
which is exactly why it's used for focus rings. Never remove it
without a replacement. */
button:focus-visible { outline: 2px solid #2563eb; outline-offset: 2px; }

Shadows

box & text shadow
/* x-offset y-offset blur spread colour */
box-shadow: 0 4px 12px rgb(15 23 42 / 0.08); /* subtle lift */
box-shadow: inset 0 1px 0 rgb(255 255 255 / 0.1); /* inner highlight */
/* Stack shadows for realistic depth */
box-shadow: 0 1px 2px rgb(0 0 0 / 0.06), 0 8px 24px rgb(0 0 0 / 0.08);
text-shadow: 0 1px 2px rgb(0 0 0 / 0.3);

Practice

Build a card: a subtle border, 12px border-radius, and a soft two-layer box-shadow that lifts on hover. Then make a hero with a background image, a dark gradient tint over it (multiple backgrounds), and centred cover sizing.

Key takeaways

  1. 01background-size: cover fills a box; layer a gradient over an image with multiple backgrounds.
  2. 02border-radius rounds corners (per-corner values; 9999px makes pills/circles).
  3. 03A border takes up space; an outline is drawn on top and is used for focus rings — never remove it.
  4. 04box-shadow is x y blur spread colour; stack two for realistic, premium depth.
  5. 05Keep shadows soft and low-opacity — heavy shadows look dated.