CSSNestedDeclarations is coming to all browsers to improve CSS Nesting!

CSS nesting just got a whole lot better!


This content originally appeared on Bram.us and was authored by Bramus!

I have a new article up on web.dev, about CSSNestedDeclarations which is coming to all browsers.

To fix some weird quirks with CSS nesting, the CSS Working Group resolved to add the CSSNestedDeclarations interface to the CSS Nesting Specification. With this addition, declarations that come after style rules no longer shift up, among some other improvements.

These changes are available in Chrome from version 130 and are ready for testing in Firefox Nightly 132 and Safari Technology Preview 204.

Besides writing the post, I had lots of fun building this CSSRule debugger for this blogpost. It shows you what goes on behind the scenes and how your CSS gets interpreted by the CSS Engine.

Here’s a comparison of Chrome without and with CSSNestedDeclarations support. The version with CSSNestedDeclarations support clearly is better.

Screenshot of the CSSRule Debugger in Chrome 129, which has no CSSNestedDeclarations support: in the parsed CSS the declarations got shifted up, amongst other things.
Screenshot of the CSSRule Debugger in Chrome 130, which has CSSNestedDeclarations support: the parsed CSS is the same as the input CSS thanks to CSSNestedDeclarations which you can see in the serialized CSS section.

I cannot help but stress that this is a change that is part of the CSS Nesting spec and is one that is coming to all engines. Firefox Nightly 132 is passing all tests, and with 8/11 subtests passing Safari Technology Preview 204 still has a little bit of cleaning to do before it can ship this.

Read “CSS nesting improves with CSSNestedDeclarations” →


This content originally appeared on Bram.us and was authored by Bramus!


Print Share Comment Cite Upload Translate Updates
APA

Bramus! | Sciencx (2024-10-08T13:15:03+00:00) CSSNestedDeclarations is coming to all browsers to improve CSS Nesting!. Retrieved from https://www.scien.cx/2024/10/08/cssnesteddeclarations-is-coming-to-all-browsers-to-improve-css-nesting/

MLA
" » CSSNestedDeclarations is coming to all browsers to improve CSS Nesting!." Bramus! | Sciencx - Tuesday October 8, 2024, https://www.scien.cx/2024/10/08/cssnesteddeclarations-is-coming-to-all-browsers-to-improve-css-nesting/
HARVARD
Bramus! | Sciencx Tuesday October 8, 2024 » CSSNestedDeclarations is coming to all browsers to improve CSS Nesting!., viewed ,<https://www.scien.cx/2024/10/08/cssnesteddeclarations-is-coming-to-all-browsers-to-improve-css-nesting/>
VANCOUVER
Bramus! | Sciencx - » CSSNestedDeclarations is coming to all browsers to improve CSS Nesting!. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2024/10/08/cssnesteddeclarations-is-coming-to-all-browsers-to-improve-css-nesting/
CHICAGO
" » CSSNestedDeclarations is coming to all browsers to improve CSS Nesting!." Bramus! | Sciencx - Accessed . https://www.scien.cx/2024/10/08/cssnesteddeclarations-is-coming-to-all-browsers-to-improve-css-nesting/
IEEE
" » CSSNestedDeclarations is coming to all browsers to improve CSS Nesting!." Bramus! | Sciencx [Online]. Available: https://www.scien.cx/2024/10/08/cssnesteddeclarations-is-coming-to-all-browsers-to-improve-css-nesting/. [Accessed: ]
rf:citation
» CSSNestedDeclarations is coming to all browsers to improve CSS Nesting! | Bramus! | Sciencx | https://www.scien.cx/2024/10/08/cssnesteddeclarations-is-coming-to-all-browsers-to-improve-css-nesting/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.