CSS is evolving faster than ever, and browser vendors are catching up quickly. If you're a frontend developer, staying updated on the latest CSS features can dramatically improve your workflow, reduce JavaScript overhead, and enable cleaner, more maintainable code.
This post covers the most recent and upcoming CSS features supported by modern browsers in 2024 and beyond.
1. :has()
- The Parent Selector β
Status: Supported in all major browsers (Chrome, Firefox, Safari, Edge)
article:has(h2) {
border-left: 4px solid #3b82f6;
}
This long-awaited parent selector allows styling a parent based on its child. Think of it as bringing reactive logic directly into CSS!
Use cases:
- Add styles to a card if it contains an image
- Highlight forms that contain invalid fields
- Conditionally show elements
2. @scope
- Scoped Styling (Experimental) π
Status: Supported in Chrome and Safari (behind flags in others)
@scope (.card) {
h2 {
color: teal;
}
}
@scope
allows you to scope a set of styles to a part of the DOM. Think of it like :is()
+ :where()
but localized and smarter.
Use cases:
- Write modular, reusable components without style leakage
- Eliminate need for heavy BEM naming
3. CSS Nesting β
Status: Supported in Chrome, Safari, Firefox, and Edge
.card {
color: black;
&:hover {
color: blue;
}
}
Now you can write cleaner, more readable styles without using a preprocessor like Sass.
Benefits:
- Cleaner scoping
- Easier maintenance
- Better structure for components
4. color-mix()
and relative-color()
π
Status: Supported in Chrome and Safari (partial support in Firefox)
color: color-mix(in srgb, red 50%, white);
Mix colors directly in CSS!
--primary: #3b82f6;
--light: relative-color(--primary lightness + 30%);
Define derived colors based on another.
5. Container Queries β
Status: Supported in all major browsers
@container (min-width: 500px) {
.card {
flex-direction: row;
}
}
CSS can now respond to element size, not just the viewport. This is a game-changer for component-based design.
Use cases:
- Adaptive cards
- Responsive sidebars
- Grid layouts that adapt inside other containers
6. View Transitions API (CSS + JS) π
Status: Supported in Chromium browsers (Safari & Firefox partial)
::view-transition-old(root),
::view-transition-new(root) {
animation: fade 0.4s;
}
Paired with JavaScript's startViewTransition()
, you can now add seamless page transitions natively.
7. Anchor Positioning π
Status: Partially supported (behind flags in some browsers)
.my-tooltip {
position: anchor;
anchor-name: --target;
top: anchor(top);
left: anchor(center);
}
CSS-based positioning that dynamically adapts to the layout and scroll state. Think tooltips, popovers, dropdowns β without JS hacks.
8. accent-color
β
Status: Fully supported
input[type="checkbox"] {
accent-color: #3b82f6;
}
Customize checkboxes, radio buttons, and range sliders without heavy styling or JavaScript.
9. :nth-child(An+B of S)
Advanced Selectors β
Status: Supported in most modern browsers
li:nth-child(2n of .highlight) {
background: yellow;
}
Filter based on subset of siblings β great for selective styling without adding classes manually.
10. Logical Properties β
padding-inline: 1rem;
padding-block: 2rem;
Instead of padding-left
/padding-right
, use logical properties for better support in right-to-left (RTL) layouts and accessibility.
Summary Table
Feature | Support Status | Description |
---|---|---|
:has() |
β Full | Parent selector |
@scope |
π§ Experimental | Scoped styles |
Nesting | β Full | Sass-like nesting in native CSS |
color-mix() |
β Partial | Mix colors in CSS |
Container Queries | β Full | Style based on container size |
View Transitions API | β Chromium | Native page transition animations |
Anchor Positioning | π§ Partial | Position based on DOM anchors |
accent-color |
β Full | Custom form control colors |
nth-child of S |
β Most Browsers | More powerful structural pseudo-class |
Logical Properties | β Full | Direction-aware spacing & layout |
Final Thoughts
These CSS features are reducing our reliance on JavaScript and giving us new superpowers as frontend developers. If you havenβt yet experimented with container queries, view transitions, or :has()
, now is the time to do it!
Stay modern, write less code, and build cleaner UI!
Top comments (0)