Elsewhere – Bram.us https://www.bram.us A rather geeky/technical weblog, est. 2001, by Bramus Tue, 08 Oct 2024 13:16:11 +0000 en-US hourly 1 https://wordpress.org/?v=6.7.1 CSSNestedDeclarations is coming to all browsers to improve CSS Nesting! https://www.bram.us/2024/10/08/cssnesteddeclarations-is-coming-to-all-browsers-to-improve-css-nesting/ https://www.bram.us/2024/10/08/cssnesteddeclarations-is-coming-to-all-browsers-to-improve-css-nesting/#respond <![CDATA[Bramus!]]> Tue, 08 Oct 2024 13:15:03 +0000 <![CDATA[Elsewhere]]> <![CDATA[css]]> <![CDATA[css nesting]]> <![CDATA[css object model]]> <![CDATA[link]]> https://www.bram.us/?p=34866 <![CDATA[CSS nesting just got a whole lot better!]]> <![CDATA[

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” →

]]>
https://www.bram.us/2024/10/08/cssnesteddeclarations-is-coming-to-all-browsers-to-improve-css-nesting/feed/ 0
Benchmarking the performance of CSS @property https://www.bram.us/2024/10/03/benchmarking-the-performance-of-css-property/ https://www.bram.us/2024/10/03/benchmarking-the-performance-of-css-property/#respond <![CDATA[Bramus!]]> Thu, 03 Oct 2024 13:03:14 +0000 <![CDATA[Elsewhere]]> <![CDATA[css]]> <![CDATA[link]]> <![CDATA[performance]]> https://www.bram.us/?p=34834 <![CDATA[With @​property now being Baseline Newly Available, I thought it’d be a good time benchmark the impact – if any – it has on the performance of your CSS. When starting to use a new CSS feature it’s important to understand its impact on the performance of your websites, whether positive or negative. With @property … ]]> <![CDATA[

With @​property now being Baseline Newly Available, I thought it’d be a good time benchmark the impact – if any – it has on the performance of your CSS.

When starting to use a new CSS feature it’s important to understand its impact on the performance of your websites, whether positive or negative. With @property now in Baseline this post explores its performance impact, and things you can do to help prevent negative impact.

For this I built and open sourced the “CSS Selector Benchmark” project which I have been working on for some time now.

To benchmark the performance of CSS we built the “CSS Selector Benchmark” test suite. It is powered by Chromium’s PerfTestRunner and benchmarks the performance impact of CSS. This PerfTestRunner is what Blink (= Chromium’s underlying rendering engine) uses for its internal performance tests.

The runner includes a measureRunsPerSecond method which is used for the tests. The higher the number of runs per second, the better.

The created benchmarks for @property specifically measure how fast Blink can handle a Style Invalidation and the subsequent Recalculate Style task. This was tested with both registered and unregistered custom properties, as well as regular properties.

Read “Benchmarking the performance of CSS @property” on web.dev →
Check out “css-selector-benchmark” on GitHub →

]]>
https://www.bram.us/2024/10/03/benchmarking-the-performance-of-css-property/feed/ 0
The CSS Podcast 089: View Transitions https://www.bram.us/2024/09/26/the-css-podcast-089-view-transitions/ https://www.bram.us/2024/09/26/the-css-podcast-089-view-transitions/#respond <![CDATA[Bramus!]]> Thu, 26 Sep 2024 20:49:00 +0000 <![CDATA[Elsewhere]]> <![CDATA[link]]> <![CDATA[podcast]]> <![CDATA[view transitions]]> https://www.bram.us/?p=34807 <![CDATA[Last week I joined my colleagues Adam and Una on The CSS Podcast to talk about View Transitions.]]> <![CDATA[

Last week I joined my colleagues Adam and Una on The CSS Podcast. I was brought on to talk about View Transitions, a feature I’m doing the DevRel work for at Google.

In this episode Una and Adam bring on an esteemed guest Bramus, who brings us deep knowledge on View Transitions. These are easy to get started with but difficult to master, but not with Bramus here to teach us. He’ll be covering introductory to advanced API features and a big bag of examples and demos.

You can watch the episode on YouTube, which I have embedded below:

You can also listen to it using your favorite podcasting app.

]]>
https://www.bram.us/2024/09/26/the-css-podcast-089-view-transitions/feed/ 0
Animate to height: auto; (and other intrinsic sizing keywords) in CSS https://www.bram.us/2024/09/17/animate-to-height-auto-and-other-intrinsic-sizing-keywords-in-css/ https://www.bram.us/2024/09/17/animate-to-height-auto-and-other-intrinsic-sizing-keywords-in-css/#respond <![CDATA[Bramus!]]> Tue, 17 Sep 2024 15:46:09 +0000 <![CDATA[Elsewhere]]> <![CDATA[animation]]> <![CDATA[css]]> <![CDATA[link]]> https://www.bram.us/?p=34770 <![CDATA[Use the interpolate-size property or the calc-size() function to enable smooth transitions and animations from lengths to intrinsic sizing keywords and back.]]> <![CDATA[

I have a new article up on developer.chrome.com:

An often requested CSS feature is the ability to animate to height: auto. A slight variation of that request is to transition the width property instead of the height, or to transition to any of the other intrinsic sizes represented by keywords like min-content, max-content, and fit-content.

As of Chrome 129 you can now use the interpolate-size property or the calc-size() function to enable smooth transitions and animations from lengths to intrinsic sizing keywords and back.

The gist is to add the following snippet to your stylesheet to opt-in to interpolating from <length-percentage>s to any of the supported <intrinsic-size-keyword>s or vice versa.

:root {
    interpolate-size: allow-keywords;
}

The alternative is to use the calc-size() approach (which nowadays requires two arguments btw), but in most cases interpolate-size: allow-keywords; will do just fine.

Find all the details and a bunch of demos in the article Animate to height: auto; (and other intrinsic sizing keywords) in CSS.

]]>
https://www.bram.us/2024/09/17/animate-to-height-auto-and-other-intrinsic-sizing-keywords-in-css/feed/ 0
CSS-only Custom Range Slider with Motion https://www.bram.us/2024/06/06/css-only-custom-range-slider-with-motion/ https://www.bram.us/2024/06/06/css-only-custom-range-slider-with-motion/#comments <![CDATA[Bramus!]]> Thu, 06 Jun 2024 07:53:56 +0000 <![CDATA[Elsewhere]]> <![CDATA[at-property]]> <![CDATA[css]]> <![CDATA[demo]]> <![CDATA[link]]> <![CDATA[scroll-driven animations]]> https://www.bram.us/?p=34587 <![CDATA[@property + counters + anchoring + scroll-driven animations = 😍]]> <![CDATA[
Recording of Temani’s demo

~

I love this demo by Temani Afif. As you drag the thumb of the range input, the tooltip updates. It’s a combination of @property, counters, anchoring, and scroll-driven animations.

See the Pen CSS-only Custom range slider by Temani Afif (@t_afif) on CodePen.

Cranking it up a noth, Temani also incorporated my approach to a CSS-only scroll velocity detection to make the tooltip jiggle as you drag the thumb across.

See the Pen CSS-only Custom range slider with motion by Temani Afif (@t_afif)on CodePen.

Love it! 😍

]]>
https://www.bram.us/2024/06/06/css-only-custom-range-slider-with-motion/feed/ 3
Multi-page application View Transitions are here (Google I/O 2024) https://www.bram.us/2024/05/17/multi-page-application-view-transitions-are-here-google-i-o-2024/ https://www.bram.us/2024/05/17/multi-page-application-view-transitions-are-here-google-i-o-2024/#comments <![CDATA[Bramus!]]> Thu, 16 May 2024 23:30:23 +0000 <![CDATA[Elsewhere]]> <![CDATA[css]]> <![CDATA[googleio]]> <![CDATA[public speaking]]> <![CDATA[video]]> <![CDATA[view transitions]]> https://www.bram.us/?p=34541 <![CDATA[My talk for Google I/O 2024]]> <![CDATA[

For this year’s Google I/O, I recorded the session “Multi-page application View Transitions are here”.

Last year, we debuted Same-Document View Transitions for use in your Single-Page Applications (SPAs), and now we’re taking it to the next level. Get ready for enhanced control over View Transitions to more easily create immersive user experiences. We are also giving you Cross-Document View Transitions which allow you to create seamless navigations in your Multi-Page Applications (MPAs).

In the talk, I cover two main topics:

  1. Cross-Document View Transitions for Multi-Page Applications
  2. View Transitions Improvements (view-transition-class and View Transition Types)

You can find the video embedded at the top of this post. If you’re more into reading, check out the announcement blog post. The documentation up on developer.chrome.com also got an overhaul.

Watch “Multi-page application View Transitions are here” on YouTube →
Read the announcement blog post →
Read the updated documentation (SPA + MPA) →

]]>
https://www.bram.us/2024/05/17/multi-page-application-view-transitions-are-here-google-i-o-2024/feed/ 2
Introducing “Unleash the Power of Scroll-Driven Animations” https://www.bram.us/2024/05/06/introducing-unleash-the-power-of-scroll-driven-animations/ https://www.bram.us/2024/05/06/introducing-unleash-the-power-of-scroll-driven-animations/#respond <![CDATA[Bramus!]]> Mon, 06 May 2024 19:51:13 +0000 <![CDATA[Elsewhere]]> <![CDATA[link]]> <![CDATA[scroll-driven animations]]> <![CDATA[video course]]> https://www.bram.us/?p=34535 <![CDATA[I built a thing: a 10-part video course that teaches you all there is to know about scroll-driven animations with CSS or JavaScript.]]> <![CDATA[

Poster frame of the fist episode of the series

I’m proud to announce the release of “Unleash the Power of Scroll-Driven Animations”, a 10-part video course I created that teaches you all there is to learn all about scroll-driven animations with CSS or JavaScript.

With scroll-driven animations you can take an existing CSS or WAAPI animation and animate it on scroll. Because of that, scroll-driven animations inherit all of the benefits these APIs bring. This includes hardware accelerated scroll-driven animations that are not subject to jank when the main thread gets blocked.

📝 Read the announcement post →
📺 Watch the videos on YouTube →
🧑‍🔬 Check out the demos and tools →
🧑‍💻 Get the debugger extension →

]]>
https://www.bram.us/2024/05/06/introducing-unleash-the-power-of-scroll-driven-animations/feed/ 0
CSS color-scheme-dependent colors with light-dark() https://www.bram.us/2024/04/21/css-color-scheme-dependent-colors-with-light-dark/ https://www.bram.us/2024/04/21/css-color-scheme-dependent-colors-with-light-dark/#respond <![CDATA[Bramus!]]> Sun, 21 Apr 2024 15:40:53 +0000 <![CDATA[Elsewhere]]> <![CDATA[css]]> <![CDATA[dark mode]]> <![CDATA[link]]> https://www.bram.us/?p=34467 <![CDATA[I’ve written about light-dark() before here on bram.us, and last month I also wrote an article for web.dev about it. The article takes a bit of a different approach, so it’s still worth a read even when you’ve seen my previous one before. System colors have the ability to react to the current used color-scheme … ]]> <![CDATA[

I’ve written about light-dark() before here on bram.us, and last month I also wrote an article for web.dev about it.

The article takes a bit of a different approach, so it’s still worth a read even when you’ve seen my previous one before.

System colors have the ability to react to the current used color-scheme value. The light-dark() function exposes the same capability to authors.

I’m especially fond of this demo that I built. The page responds to your Operating System’s light/dark setting but also allows overriding light/dark mode by changing the value of the color-scheme to only light or only dark.

See the Pen
Color switching with light-dark() and color-scheme
by web.dev (@web-dot-dev)
on CodePen.

CSS color-scheme-dependent colors with light-dark()

]]>
https://www.bram.us/2024/04/21/css-color-scheme-dependent-colors-with-light-dark/feed/ 0
CSS ::backdrop now inherits from its originating element https://www.bram.us/2024/02/21/css-backdrop-now-inherits-from-its-originating-element/ https://www.bram.us/2024/02/21/css-backdrop-now-inherits-from-its-originating-element/#respond <![CDATA[Bramus!]]> Wed, 21 Feb 2024 22:54:16 +0000 <![CDATA[Elsewhere]]> <![CDATA[backdrop]]> <![CDATA[css]]> <![CDATA[link]]> https://www.bram.us/?p=34356 <![CDATA[Screenshot of the demo featured in the article. In Chrome 122 the backdrop is light purple because it can access the custom property from the dialog element. If you ever struggled with ::backdrop not having access to custom properties, here’s some good news: As of Chrome 122 – and also in Firefox 120 and soon … ]]> <![CDATA[
Screenshot of the demo featured in the article. In Chrome 122 the backdrop is light purple because it can access the custom property from the dialog element.

If you ever struggled with ::backdrop not having access to custom properties, here’s some good news:

As of Chrome 122 – and also in Firefox 120 and soon Safari 17.4 – ::backdrop is a tree-abiding pseudo-element, meaning that it inherits any inheritable properties from its originating element.

Go check out the article I wrote for developer.chrome.com for all details + a demo.

Changes to CSS ::backdrop inheritance →

]]>
https://www.bram.us/2024/02/21/css-backdrop-now-inherits-from-its-originating-element/feed/ 0
Tailwind marketing and misinformation engine https://www.bram.us/2024/02/21/tailwind-marketing-and-misinformation-engine/ https://www.bram.us/2024/02/21/tailwind-marketing-and-misinformation-engine/#respond <![CDATA[Bramus!]]> Wed, 21 Feb 2024 22:45:15 +0000 <![CDATA[Elsewhere]]> <![CDATA[css]]> <![CDATA[link]]> <![CDATA[tailwind]]> https://www.bram.us/?p=34350 <![CDATA[Nuanced piece by Tero Piirainen on where Tailwind took a good practice, twisted it around, and took it for a run. Use it or don’t, love it or hate it, but this last sentence of the article hits close to home: Learn to write clean HTML and CSS and stay relevant for years to come. … ]]> <![CDATA[

Nuanced piece by Tero Piirainen on where Tailwind took a good practice, twisted it around, and took it for a run.

Use it or don’t, love it or hate it, but this last sentence of the article hits close to home:

Learn to write clean HTML and CSS and stay relevant for years to come.

Frameworks come and go. The foundations are here to stay.

Tailwind marketing and misinformation engine →

]]>
https://www.bram.us/2024/02/21/tailwind-marketing-and-misinformation-engine/feed/ 0