liveBook · Manning

Complementary color relationship

As explained in CSS in Depth, Second Edition

A complementary color is a color positioned opposite another color on a color wheel or comparable hue model.

A complementary color sits opposite another color on a color wheel or comparable hue model. Blue pairs with yellow, green with magenta or purple, and red with cyan. section 11.3.4

Use this relationship as a starting point, then refine the result:

  • In OKLCH or HSL, add or subtract 180 degrees from the hue; keep equivalent values such as -15 and 345 within a familiar 0–360 range. section 11.3.4
  • Choose chroma and lightness from an existing page color, then adjust them until the result looks appropriate. section 11.3.4
  • Check the result in browser DevTools, especially when previewing link active, hover, or focus states. section 11.3.4

A green palette accent

Starting with a green hue near 165 degrees gives a complementary hue near 345 degrees. Adjusting it toward 10 degrees and reducing lightness produces oklch(64% 0.15 10deg), assigned to the --red custom property. section 11.3.4

Listing 11.8 Adding the red color to the palette
@layer theme {
  :root {
    --brand-green: oklch(45% 0.09 165.4deg);
    --dark-green: oklch(59% 0.12 164.1deg);
    --medium-green: oklch(74% 0.15 166.4deg);
    --text-color: oklch(26% 0.01 0deg);
    --gray: oklch(64% 0.02 248deg);
    --light-gray: oklch(96% 0.003 248deg);
    --extra-light-gray: oklch(98% 0 0deg);
    --white: oklch(100% 0 0deg);

    --red: oklch(64% 0.15 10deg);    #1
  }
}

See the CSS custom-property definition that adds the derived red accent to the palette. section 11.3.4

How CSS in Depth, Second Edition covers it

How deep it goes
Explains opposite hues and a practical OKLCH workflow, then stops short of treating the result as an automatic final choice.
Examples
Uses blue–yellow, green–magenta, and red–cyan pairs plus a green-to-red OKLCH palette example.
What it assumes
Builds from the basic idea of a color wheel while introducing hue, chroma, and lightness through an applied example.
What you can do after
Apply the relationship in CSS, refine chroma and lightness, and test interactive states with DevTools.
How it connects
Connects color wheels, OKLCH, HSL, CSS custom properties, browser DevTools, and color-palette tools.

Also explained in

Compare how 5 books explain complementary color relationship →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of CSS in Depth, Second Edition. The section links point to the parts of the book it draws on.