Skip to main content
Web DevelopmentTutorials

Modern CSS: Features You Should Be Using Today

CSS has evolved dramatically. Explore nesting, :has(), container queries, cascade layers, and other modern features with excellent browser support.

Mbeah Essilfie

Mbeah Essilfie

May 12, 2026 at 06:04 AM

8 min read 1444 views
Modern CSS: Features You Should Be Using Today

CSS Is No Longer "Just Styling"

Modern CSS is a powerful, declarative programming language. Many patterns that once required JavaScript or preprocessors are now native.

Native Nesting

No more Sass just for nesting:

.card {
  padding: 1rem;
  border-radius: 0.5rem;

  & .title {
    font-size: 1.25rem;
    font-weight: bold;
  }

  &:hover {
    box-shadow: 0 4px 12px rgb(0 0 0 / 0.1);
  }

  @media (width >= 768px) {
    padding: 2rem;
  }
}

The () Selector (Parent Selector!)

CSS can now select parents based on children:

/* Style a form group that contains an invalid input */
.form-group:has(input:invalid) {
  border-color: red;
}

/* Style a card differently if it has an image */
.card:has(img) {
  grid-template-rows: 200px 1fr;
}

/* Change nav style when a dropdown is open */
nav:has(.dropdown[open]) {
  background: var(--nav-active-bg);
}
:has() is the most powerful CSS selector ever added. It eliminates the need for JavaScript-based "parent has class" patterns entirely.

Cascade Layers

Control specificity without fighting it:

@layer base, components, utilities;

@layer base {
  a { color: blue; }
}

@layer components {
  .nav a { color: white; }  /* Wins over base regardless of specificity */
}

@layer utilities {
  .text-red { color: red !important; }  /* Wins over everything */
}

Logical Properties

Write direction-agnostic CSS:

/* ❌ Physical — breaks in RTL languages */
.element {
  margin-left: 1rem;
  padding-right: 2rem;
  border-top: 1px solid;
}

/* ✅ Logical — works in any writing direction */
.element {
  margin-inline-start: 1rem;
  padding-inline-end: 2rem;
  border-block-start: 1px solid;
}

View Transitions

Page transitions without JavaScript frameworks:

@view-transition {
  navigation: auto;
}

.hero-image {
  view-transition-name: hero;
}

::view-transition-old(hero) {
  animation: fade-out 0.3s ease;
}

::view-transition-new(hero) {
  animation: fade-in 0.3s ease;
}

Subgrid

Children align to parent grid tracks:

.grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
}

.card {
  display: grid;
  grid-template-rows: subgrid;
  grid-row: span 3; /* Participate in 3 parent rows */
}

Check Support

@supports (selector(:has(*))) {
  /* Use :has() */
}

@supports not (selector(:has(*))) {
  /* Fallback */
}

CSS is more powerful than ever. Check caniuse.com and start using these features — most have 90%+ browser support.

CSSTailwind CSS
Mbeah Essilfie

Written by Mbeah Essilfie

Fullstack Software Developer

Read next

The Complete Guide to Vue 3 Composables
12 min read

The Complete Guide to Vue 3 Composables

Understand the power of Vue 3's Composition API through practical, real-world composable patterns that you can use today.

Mbeah EssilfieMbeah Essilfie
982