Files
README.md

Riihisoft training day materials, March 2026 #

CSS is pretty cool nowadays, so I compiled some of the cool parts of it into one package.

Open the slides

Repositories:

Running it locally #

Node.js

$ npm ci
$ npm run dev

Python

$ cd src
$ python3 -m http.server

Docker

$ docker build -t css-dev .
$ docker run --rm -it -p 5173:5173 -v "$PWD":/app -v /app/node_modules css-dev

Planning #

OKLCH #

Human readable and easier color settings

Variables and @property #

Type safe css with @property, for turbo charging your css variables.

@property --such-color {
    syntax: "<color>";
    inherits: false;
    initial-value: #decade;
}

Parts #

Container queries #

.card-grid {
  container-type: inline-size;
}

@container (min-width: 400px) {
  .card {
    display: grid;
    grid-template-columns: 1fr 2fr;
  }
}

:has() for selecting parents #

In css you cannot move backwards. This is because it was chosen due to css being parsed sequentially, to decrease content shifts

form:has(input:invalid) {
  border: 2px solid red;
}

.card:has(img) {
  grid-template-columns: 200px 1fr;
}

Use cases:

  • Form validation styling
  • dynamic layouts
  • conditional styling
button:has(svg) {
  padding-left: 0.5rem;
}

Native CSS nesting #

Sass style nesting is now native and well supported

.card {
  padding: 1rem;

  & h2 {
    font-size: 1.5rem;
  }

  &:hover {
    box-shadow: 0 4px 10px;
  }
}

Cascade layers with @layer #

Solving css specificity hell

@layer reset, base, components, utilities;

@layer components {
  .btn {
    background: blue;
  }
}

@layer utilities {
  .text-center {
    text-align: center;
  }
}

Great for:

  • predictable css overrides
  • design systems
  • utility classes that always win
  • no more !important

Modern CSS functions #

No more JS calculations

clamp()

font-size: clamp(1rem, 3vw, 2rem);

color-mix()

--primary-light: color-mix(in srgb, var(--primary), white 30%);

min() and max()

width: min(100%, 800px);

View transitions #

document.startViewTransition(() => {
  document.body.classList.toggle("grid");
});

example: list to grid animation

Color scheme with color-scheme #

Toggle light / dark page, inputs and custom components

:root {
    color-scheme: light dark;
}

Scroll driven animation #

Animate on scroll or on viewport intersection

.animate-on-viewport-intersection {
    animation: something-cool linear both;
    animation-timeline: view();
}

.animate-on-scroll {
    animation: cool-animation linear both;
    animation-timeline: scroll();
}

Relative colors #

Colorscheme that changes dynamically!

UI/UX improvements #

accent-color

input[type="checkbox"] {
  accent-color: #4f46e5;
}

:focus-visible

content-visibility

.section {
  content-visibility: auto;
}

Improved form validation #

:user-invalid vs :invalid

  • lazy vs eager validation

Native accordion #

done with summary and details

@starting-style #

easier entry events