liveBook · Manning

Alpha channel

As explained in Math for Web Design

Alpha is a graphics channel value from zero to one that represents a color's opacity or coverage during compositing.

An alpha channel is a color value from 0 to 1 that controls transparency. An alpha of 0 is completely transparent, while 1 is completely opaque; percentages from 0% to 100% express the same range. section 7.1.1

Use alpha values with common CSS color notations:

  • In rgb(), write the alpha after a slash: rgb(128 0 128 / 0.5). section 7.1.1
  • In hexadecimal notation, append a two-digit alpha value: #rrggbbaa. 00 is transparent and ff is opaque. section 7.1.1
  • The same slash notation works with lab(), such as lab(30% 60 -50% / 0.25). section 7.1.3

Blending a transparent blue over red

For a blue foreground with αs = 0.5 over an opaque red background, source-over compositing calculates each channel as Cout = Csαs + Cb(1 − αs). Red becomes 0.5, green 0, and blue 0.5, producing normalized (0.5, 0, 0.5), or rgb(128 0 128). section 7.6.2

h1 
    color: rgb(128  0 128 / 0.5);
}

Inspect the CSS listing for a semitransparent purple color expressed with rgb() alpha syntax. section 7.1.1

How Math for Web Design covers it

How deep it goes
Defines alpha ranges and notation, then derives source-over compositing per channel with a worked example.
Examples
Uses semitransparent purple and blue-over-red examples across rgb(), hexadecimal, and lab() color notation.
What it assumes
Assumes familiarity with CSS colors and RGB components while teaching alpha ranges and compositing calculations explicitly.
What you can do after
Apply alpha through CSS rgb(), hexadecimal, or lab() notation and predict the resulting color over an opaque background.
How it connects
Connects RGB color model, hexadecimal color notation, LAB color space, CSS color functions, and alpha compositing.

Also explained in

Compare how 3 books explain alpha channel →

Related concepts

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