Comments on: What You Need to Know about Modern CSS (Spring 2024 Edition) https://frontendmasters.com/blog/what-you-need-to-know-about-modern-css-spring-2024-edition/ Helping Your Journey to Senior Developer Wed, 17 Apr 2024 22:00:40 +0000 hourly 1 https://wordpress.org/?v=6.5.2 By: Chris Coyier https://frontendmasters.com/blog/what-you-need-to-know-about-modern-css-spring-2024-edition/#comment-2006 Wed, 03 Apr 2024 22:36:28 +0000 https://frontendmasters.com/blog/?p=1013#comment-2006

You are writing if/then code in CSS: that should be in JavaScript.

Do you feel that way about media queries? Hover states? Focus styles? Disabled styles? Validity checks? Heck, every selector is an if/then statement. If the selector matches, do the styles.

you could have been handled the situation much easier, and with less code, with a class. style=”–variant: 1;” is class1 and style=”–variant: 2;” is class2. Your code would be simpler and easier to read

I agree class changes are a very clear way to change the state of something. But changing the value of a custom property in CSS is a different beast entirely. You could change a custom property because of a :has() selector, or a media query, or a state change, or a million other things. In those cases, you don’t have the ability to change a class in the HTML. But with a style query, you can still change a whole chunk of styles when the custom property changes.

]]>
By: Michael Berger https://frontendmasters.com/blog/what-you-need-to-know-about-modern-css-spring-2024-edition/#comment-2005 Wed, 03 Apr 2024 22:24:47 +0000 https://frontendmasters.com/blog/?p=1013#comment-2005 This is very useful article. However, I have a big problem with container queries, at least as you have described them. Problem 1: You are writing if/then code in CSS: that should be in JavaScript.
Problem 2: The bigger issue: you are writing more code then you need to. In the example you used, you could have been handled the situation much easier, and with less code, with a class. style=”–variant: 1;” is class1 and style=”–variant: 2;” is class2. Your code would be simpler and easier to read in HTML, CSS and JS.

]]>
By: Chris Coyier https://frontendmasters.com/blog/what-you-need-to-know-about-modern-css-spring-2024-edition/#comment-1998 Wed, 03 Apr 2024 15:46:53 +0000 https://frontendmasters.com/blog/?p=1013#comment-1998 In reply to s427.

You’re correct! Thank you. Selecting within the class exhibits the issue more clearly:
https://codepen.io/chriscoyier/pen/oNOpqJK

]]>
By: s427 https://frontendmasters.com/blog/what-you-need-to-know-about-modern-css-spring-2024-edition/#comment-1989 Wed, 03 Apr 2024 08:07:19 +0000 https://frontendmasters.com/blog/?p=1013#comment-1989 Very helpful article, thank you very much!

However, please note that in “Scoping”, the example given with the three embedded divs and light/dark classes does not work. Contrary to what the article says, “some text” will use the “light” style. I am guessing this is an overly simplified version of the example given on the MDN page for @scope, which is slightly more convoluted: https://developer.mozilla.org/en-US/docs/Web/CSS/@scope#how_scope_conflicts_are_resolved

]]>
By: Mauricio Poveda https://frontendmasters.com/blog/what-you-need-to-know-about-modern-css-spring-2024-edition/#comment-1903 Sat, 30 Mar 2024 15:27:21 +0000 https://frontendmasters.com/blog/?p=1013#comment-1903 Awesome post by one the most CSS saavy devs in CSS. Very helpful and thankful to FEM to post this contents free.

]]>
By: Oliver https://frontendmasters.com/blog/what-you-need-to-know-about-modern-css-spring-2024-edition/#comment-1875 Wed, 27 Mar 2024 16:05:43 +0000 https://frontendmasters.com/blog/?p=1013#comment-1875 Very helpful summary!

]]>