DEV Community

Cover image for CSS Just Changed Forever🤔: 7 Revolutionary Features You Need to Know
Mo Andaloussi
Mo Andaloussi

Posted on • Edited on

CSS Just Changed Forever🤔: 7 Revolutionary Features You Need to Know

As web developers, we've all experienced those moments of frustration when dealing with CSS. From centering divs to managing dark mode transitions, CSS has historically been a source of countless developer headaches. But the landscape is changing. With its recent major update and a beautiful new logo in Rebecca Purple, CSS is entering a new era of powerful, developer-friendly features.

💡 Get weekly CSS tips, code snippets, and tutorials straight to your inbox - 100% free!

The Significance of Rebecca Purple

Before diving into the new features, it's worth noting the touching story behind the new CSS logo's color. Rebecca Purple isn't just another color name - it carries a profound meaning in the web development community. Named after Rebecca Meyer, the daughter of CSS pioneer Eric Meyer, this color serves as a lasting tribute. Rebecca, who insisted on being called by her full name at age six, passed away shortly after. Her memory lives on through this standard CSS color, which will likely be part of the web's foundation for centuries to come.

1. Align Content Without the Complexity

Remember all those memes about centering a div? They're now obsolete. The new align-content property works directly in any block layout, no flexbox or grid required. It's almost surprising it took 25 years to implement such a fundamental feature, but better late than never.

.centered-content {
    align-content: center;  /* That's it! No flexbox or grid needed */
    block-size: 100vh;
}
Enter fullscreen mode Exit fullscreen mode

2. Typed CSS Variables with @property

Part of CSS Houdini, the @property rule is a game-changer for variable handling. Previously, CSS variables were interpreted as simple strings, limiting their animation potential. Now, you can specify variable types like number, color, or percentage, enabling safer code and more sophisticated animations.

/* Old way - limited animation capabilities */
:root {
    --gradient-stop: 50%;
}

/* New way - fully animatable */
@property --gradient-stop {
    syntax: '<percentage>';
    initial-value: 0%;
    inherits: false;
}

.gradient {
    background: linear-gradient(90deg, blue var(--gradient-stop), red);
    transition: --gradient-stop 0.3s;
}

.gradient:hover {
    --gradient-stop: 75%;
}
Enter fullscreen mode Exit fullscreen mode

3. Starting Style: Better First Impressions

The new @starting-style rule solves a common animation challenge. When elements hidden with display: none become visible, their entrance animations often fail to trigger. This rule lets you define initial styles for elements when they're first rendered, perfect for dialogs, popovers, and other dynamic content.

.dialog {
    display: none;
    transform: translateY(0);
    opacity: 1;
    transition: transform 0.3s, opacity 0.3s;
}

@starting-style {
    .dialog {
        transform: translateY(20px);
        opacity: 0;
    }
}

.dialog.open {
    display: block;  /* Will now animate smoothly from the starting style */
}
Enter fullscreen mode Exit fullscreen mode

4. Enhanced Mathematical Capabilities

CSS continues to evolve as a powerful styling language with new math functions:

.mathematical {
    /* Rounding numbers */
    width: round(45.6px);           /* 46px */
    height: round(down, 45.6px);    /* 45px */
    margin: round(up, 45.6px);      /* 46px */

    /* Remainder operations */
    padding: rem(17, 5);            /* 2 (remainder of 17÷5) */
    gap: mod(17, 5);               /* Same as rem() */
}
Enter fullscreen mode Exit fullscreen mode

5. Simplified Dark Mode with light-dark()

Dark mode implementation becomes more straightforward with the light-dark() function. This feature allows you to specify different values for light and dark color schemes without media queries.

6. Smarter Form Validation Styles

Form validation UX improves with the new user-valid and user-invalid pseudo-classes. Unlike their predecessors (:valid and :invalid), these only trigger after user interaction, preventing premature error messages.

.input {
    border: 2px solid #ccc;
}

.input:user-invalid {
    border-color: #ff4444;
    animation: shake 0.3s;
}

.input:user-valid {
    border-color: #44ff44;
}

.error-message {
    display: none;
}

.input:user-invalid + .error-message {
    display: block;
}
Enter fullscreen mode Exit fullscreen mode

7. Animation Breakthrough with interpolate-size

Perhaps the most exciting addition is the interpolate-size property. It solves the long-standing challenge of animating elements with dynamic heights.

.dropdown {
    overflow: hidden;
    height: auto;
    transition: height 0.3s;
    interpolate-size: allow-keywords;  /* Enables smooth height animation */
}

.dropdown.collapsed {
    height: 0;
}
Enter fullscreen mode Exit fullscreen mode

Looking Forward

These features represent just the tip of the iceberg. With other powerful additions like container queries, subgrid, and the :has selector, CSS continues to evolve into a more capable and developer-friendly language. The modern CSS baseline, supported by all major browsers, proves that CSS isn't just surviving—it's thriving.

Gone are the days when CSS was seen as a necessary evil in web development. These new features demonstrate a commitment to solving real-world developer challenges while making the language more intuitive and powerful. As we move forward, it's clear that CSS is not just changing—it's revolutionizing how we approach web styling.

Check this article for the best css practices

This article is inspired by Fireship video about the topic

Top comments (28)

Collapse
 
gianpaj profile image
Gianfranco P.

Nice! I managed to animate my website's navbar with interpolate-size: allow-keywords;

Image description

Thanks

Collapse
 
mo-dev profile image
Mo Andaloussi

Im happy that hellped you , good job

Collapse
 
timoransky profile image
Ján Timoranský

Please keep in mind that this feature is not widely supported by all major browsers. You can take a look here to see which browsers are supported, but sadly for now not many of them developer.mozilla.org/en-US/docs/W...

Collapse
 
itsmeseb profile image
sebkolind

Yo! Those are awesome. Be aware of browser support tho.

However, the @property is insane! I really like this one, and I think the future of vanilla CSS is bright, when we start seeing stuff like this. Damn.

Collapse
 
mo-dev profile image
Mo Andaloussi

Vanilla CSS is good, but it always gets overtaken by the libraries.

Collapse
 
best_codes profile image
Best Codes

Nice post! There's also a video by Fireship on YouTube that covers the same CSS techniques. :)

I made a post about the new logo recently, too!

Collapse
 
mo-dev profile image
Mo Andaloussi

Hello, thank you.
Yes, I already mentioned in the comment below that this article is inspired by a fireship video; I guess I should add it to the post.
and thank you for sharing your post.

Collapse
 
tomasdevs profile image
Tomas Stveracek

Great article! For anyone interested in more modern CSS tips, I recently wrote an article that might be helpful: Modern CSS Tips & Tricks to Boost Your Workflow.

Collapse
 
mo-dev profile image
Mo Andaloussi

Thank you.

Collapse
 
drvy profile image
Dragomir Yordanov

This looks like a copy of Fireship's video:

CSS just changed forever… plus 7 new features you don't know about
youtube.com/watch?v=A89FMtIkWKc

Just with different words.......

Collapse
 
mo-dev profile image
Mo Andaloussi

Yes, you are right. I like Fireship content, and I definitely got inspired from his video to write this article and add examples. I don't see any problem with that, to be honest. It's like you read the documentation from an official website and decide to make an article about it.

Thank you for your comment.

Collapse
 
timoransky profile image
Ján Timoranský • Edited

Great article, just FYI: interpolate-size is not yet available for all the browsers, so I wouldn't use it in production yet.

Collapse
 
mo-dev profile image
Mo Andaloussi

I think it is available for Chrome and Firefox.

Collapse
 
timoransky profile image
Ján Timoranský

Based on the MDN documentation, it's only available for Chrome at the moment. But let's see, maybe it will become more available next year.

Collapse
 
michaeljmeyer3 profile image
Michael Meyer

Heck yeah! I saw the fireship video and have been updating things for a few days here. calc-size is about my favorite thing. It has so many uses outside of vertical animations.

Great news for all of us, and a terrific write up!

Collapse
 
mo-dev profile image
Mo Andaloussi

Thank you.

Collapse
 
spo0q profile image
spO0q

CSS is definitely programming, and even more now.

Collapse
 
eddsaura profile image
Jose E Saura

Starting style is HUGE

Collapse
 
lc_phm_f11952cc8e810faf profile image
Lạc Phạm

Great article! Thank you.

Collapse
 
mo-dev profile image
Mo Andaloussi

Thank you.