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

Mo Andaloussi @mo-dev

About: I'm a Senior full-stack web developer. Sharing my professional experience with the community.

Joined:
Apr 17, 2023

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

Publish Date: Nov 26 '24
165 27

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

Comments 27 total

  • Gianfranco P.
    Gianfranco P.Nov 27, 2024

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

    Image description

    Thanks

  • Dragomir Yordanov
    Dragomir YordanovNov 27, 2024

    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.......

    • Mo Andaloussi
      Mo AndaloussiNov 27, 2024

      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.

  • Nozibul Islam
    Nozibul IslamNov 27, 2024

    thank you for sharing.

  • Best Codes
    Best CodesNov 27, 2024

    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!

    • Mo Andaloussi
      Mo AndaloussiNov 27, 2024

      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.

  • Jose E Saura
    Jose E SauraNov 28, 2024

    Starting style is HUGE

  • Tomas Stveracek
    Tomas StveracekNov 28, 2024

    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.

  • Humayun Ahmed
    Humayun AhmedNov 28, 2024

    Nice one.

  • Michael Meyer
    Michael MeyerNov 29, 2024

    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!

  • Kazi Priom
    Kazi PriomNov 29, 2024

    It's nice to see CSS get a new look. Thanks for covering it!

  • Ján Timoranský
    Ján TimoranskýNov 29, 2024

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

    • Mo Andaloussi
      Mo AndaloussiNov 29, 2024

      I think it is available for Chrome and Firefox.

      • Ján Timoranský
        Ján TimoranskýNov 29, 2024

        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.

  • sebkolind
    sebkolindNov 29, 2024

    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.

    • Mo Andaloussi
      Mo AndaloussiNov 29, 2024

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

  • Stephen Belovarich
    Stephen BelovarichNov 29, 2024

    Thank you. I'm excited to implement some of these.

  • Lạc Phạm
    Lạc PhạmDec 3, 2024

    Great article! Thank you.

  • Md Nazmus Sakib
    Md Nazmus SakibDec 15, 2024

    wonderful

Add comment