liveBook · Manning

Color scale

As explained in Web Design Playground

A smooth transition between two or more colors across a visual area, including linear and radial forms in CSS.

A color scale, or gradient, lets one background move from one color to another instead of staying a single hue. Think of a wash of paint that changes color across a page element. CSS can create that effect as a background image, so you do not need to supply an image file. section 17.18

Choose how the colors should travel:

  • A linear gradient changes color along a straight line. Set its direction with an angle or a direction such as `to top right`. section 17.18 section 17.19
  • A radial gradient changes color outward from a point, forming a circle or ellipse. section 17.18
  • Color stops set where colors occur in the transition. If you leave their positions out, the browser spaces them for you. section 17.19 section 17.21

A three-color background

```css div { background-color: blue; background-image: linear-gradient(to top right, red, white 25%, blue); height: 175px; width: 100%; } ``` The color travels from the bottom left toward the top right. White reaches its stop at 25%, earlier than the halfway position it would receive by default. The blue `background-color` gives a browser that cannot display the gradient a solid-color fallback. section 17.22 section 17.21

For an outward-moving version, try `radial-gradient(ellipse farthest-corner at left top, yellow, blue)` as the `background-image` value. Modern browsers support both gradient types without vendor prefixes; putting a `background-color` first provides a fallback for older browsers. section 17.25 section 17.27

Want to play? In the Web Design Playground’s Gradient Construction Kit, choose Linear or Radial, pick colors and stops, then watch the preview and copy the resulting CSS. Try moving a middle color stop and see how the blend changes. section 17.28 section 17.21

How Web Design Playground covers it

How deep it goes
Defines linear and radial forms, then works through directions, color stops, CSS declarations, and fallback colors.
Examples
Uses colored div backgrounds, a three-color stop at 25%, and Playground exercises with angles and radial shapes.
What it assumes
Builds on CSS color values and styling an element’s background; defines gradients before introducing their CSS syntax.
What you can do after
Build it from scratch with CSS, or apply it via the Web Design Playground’s Gradient Construction Kit.
How it connects
Connects gradients to CSS background images, color stops, color schemes, and browser fallbacks.

Also explained in

Compare how 5 books explain color scale →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Web Design Playground. The section links point to the parts of the book it draws on.