Skip to content

Exciting CSS updates since 2020

Colors

OKLAB and OKLCH

Use OKLCH, it has nicer colors and beautiful gradients.

oklch() is a new way to define CSS colors. In oklch(L C H ) or oklch(L C H / a), each item corresponds as follows:

  • L is perceived lightness (0%-100%). “Perceived” means that it has consistent lightness for our eyes, unlike L in hsl().
  • C is chroma, from gray to the most saturated color.
  • H is the hue angle (0-360).
  • a is opacity (0-1 or 0-100%).

Documentation on OKLCH

New color functions

  • color-mix() on MDN: “Takes two color values and returns the result of mixing them in a given colorspace by a given amount.”
  • color() on MDN: “Allows a color to be specified in a particular, specified color space rather than the implicit sRGB color space.”

text-wrap: balance

Text is wrapped in a way that best balances the number of characters on each line, enhancing layout quality and legibility.

Cascade Layers

Cascade layers allow controlling the specificity and order of rule sets across stylesheets.

CSS Subgrid

CSS subgrid allows a child grid to inherit the column and row definitions of its parent grid, making it easier to align nested grid items consistently with the parent layout. It helps maintain a cohesive design structure without redefining grid tracks in the child elements.

Related 📚 CSS Grid on this blog

CSS Nesting

One of our favorite CSS preprocessor features is now built into the language: nesting style rules.

CSS Masking and Clipping

Both are used to hide parts of elements and show other parts.

Masks are images; Clips are paths.