Command Palette

Search for a command to run...

Hectal
Back to the lesson: Topic 5.8 — Backgrounds and Gradients
CSS · Example 2 of 3

Linear, radial, conic and repeating gradients

No image files at all: every pattern is drawn by the browser from the gradient functions.

Every box can paint a background colour plus any number of image layers, which you size, position and repeat; gradients are images the browser draws for you, in straight lines, circles or around a point.

Change the code and press Run (Ctrl+Enter). Predict what will happen first, then break it on purpose and read what changes. Your edits are saved and match the lesson page.

Ready for more? This phase has 5 hands-on exercises with automatic checks.

Practice questions

Write the code in the editor, run it, then open the model answer to compare.

01

Make a 300×100 .bar with a left-to-right gradient from #22c55e to #0ea5e9 and a fallback colour #22c55e. Log its computed background-image.

02

Make a progress pie that is 70% filled using conic-gradient, 120px wide and round. Log its computed border-radius.

Explain it without notes

01

How do multiple backgrounds stack, and where does the background colour go?

02

What's the difference between background-size: cover and contain?

03

Name the three gradient types and a good use for each.

04

Why might background: url(...) undo a background-color you set earlier?

05

When should an image be an <img> instead of a CSS background?

Linear, radial, conic and repeating gradients

Preview

Press Run to see the page.

Console

Nothing logged yet.