The State of CSS

By Chen Hui Jing / @hj_chen

Interledger Foundation
https://interledger.org
The Devographics Collective
https://www.devographics.com
State of JS State of CSS State of GraphQL State of React State of HTML
Chart showing rates of usage of highest-rating CSS properties over time

Join us on Discord.

Check out the code on GitHub.

No more browser wars Interop 2024
https://wpt.fyi/interop-2024
Baseline

https://web.dev/baseline

State of CSS 2019 State of CSS 2020 State of CSS 2021 State of CSS 2022 State of CSS 2023
State of CSS 2019 State of CSS 2020 State of CSS 2021 State of CSS 2022 State of CSS 2023
Awareness of the blend-mode property over the past 4 years Awareness of the overscroll-behavior property over the past 4 years
Awareness of the content-visiblity property over the past 4 years

❗️ Caution: The browser is only able to skip rendering work if you are also careful not to call any DOM API that forces some of rendering to occur on one of the skipped subtrees. If you're using content-visibility to improve performance, audit your code to make sure these APIs are not getting called.

content-visibility: the new CSS property that boosts your rendering performance
content-visibility in the CSS Containment Module Level 2
Awareness of container queries from the State of CSS 2023 survey

CSS is awesome

contain: inline-size

Proposed in Thoughts on an implementable path forward for Container Queries

CanIUse chart for size container queries

CSS Container Queries (Size)

I'm the container!
Pretend this is a responsive image

Cards need headers

Most cards have blurbs. This is the epitome of a generic example. Oh well…

See the Pen Container Query Bookstore by Max Böck (@mxbck) on CodePen.

Container Query Bookstore by Max Böck

Colour in CSS

Visualisation of the color features section of the State of CSS 2023 survey

currentColor

Icon by DaeSung LEE

accent-color

HSL colours

Sadly drawn visualisation of HSL colour space

HSL colours

hsl(60 100% 25%)
hsl(240 100% 25%)
hsl(60 100% 50%)
hsl(240 100% 50%)
hsl(60 100% 80%)
hsl(240 100% 80%)

LAB and LCH

Sadly drawn visualisation of LAB colour space Sadly drawn visualisation of LCH colour space

OKLCH colours

oklch(60% 0.3 110)
oklch(60% 0.3 260)
oklch(80% 0.3 110)
oklch(80% 0.3 260)
oklch(100% 0.3 110)
oklch(100% 0.3 260)

Interpolation differences

black to white

sRGB

HSL

LAB

okLAB

LCH

okLCH

red to white

sRGB

HSL

LAB

okLAB

LCH

okLCH

blue to white

sRGB

HSL

LAB

okLAB

LCH

okLCH

blue to black

sRGB

HSL

LAB

okLAB

LCH

okLCH

red to green

sRGB

HSL

LAB

okLAB

LCH

okLCH

purple to gold

sRGB

HSL

LAB

okLAB

LCH

okLCH

blue to red

sRGB

HSL

LAB

okLAB

LCH

okLCH

mediumvioletred to gold

sRGB

HSL

LAB

okLAB

LCH

okLCH

indigo to lightseagreen

sRGB

HSL

LAB

okLAB

LCH

okLCH

same perceptual lightness origins

sRGB

HSL

LAB

okLAB

LCH

okLCH

Max LCH chroma

sRGB

HSL

LAB

okLAB

LCH

okLCH

Adapted from Gradient Color Spaces Exploration by Adam Argyle

Relative colours with CSS

Relative colour syntax

Pending Firefox: Implement CSS Color 5 Relative Color Syntax

Opacity adjustments

Input colour
HSL
OKLAB
OKLCH

Pending Firefox: Implement CSS Color 5 Relative Color Syntax

Programmatically generate colours

Input colour

50% darker

40% darker

30% darker

20% darker

10% darker

Base

10% lighter

20% lighter

30% lighter

40% lighter

50% lighter

Pending Firefox: Implement CSS Color 5 Relative Color Syntax

Awareness of :has() from the State of CSS 2023 survey
CanIUse chart for the :has() selector

The :has() selector

            /* Matches menu items with submenus in them */
nav li:has(menu) a::after { … }

/* Matches <h1> elements only if they have a <p> element directly after */
h1:has(+ p) { … }

/* Matches all <section> elements that do NOT contain headings */
section:not(:has(h1, h2, h3, h4, h5, h6)) { … }

/* Matches all <section> elements that have empty <div>s */
section:has(div:empty) { … }
          

No CSS class? No problem

Some form

Missing features in CSS from State of CSS 2023

Animating grid rows or grid columns

Also see CSS Fool's Mate on CodePen.

Animating 0fr to 1fr


Content that is meant to hidden

For all intents and purposes

Let's have multi-line content

Content that is meant to always shown

For all intents and purposes

Let's have multi-line content

Animate to auto

Have to enable “Experimental Web Platform features” from chrome://flags on Chrome Canary


Content that is meant to hidden

For all intents and purposes

Let's have multi-line content

Content that is meant to always shown

For all intents and purposes

Let's have multi-line content

QR code to https://stateofcss.com/

https://stateofcss.com

References

Thank you

Websitehttps://chenhuijing.com

GitHub@huijing

Mastadon@huijing@tech.lgbt

Codepen@huijing

Font is Inclusive Sans by Olivia King.