9 ms·
CSS Is Fun Again
- CM30 3y agoCSS Nesting will definitely be great to use in future projects, and I'm super happy to see it in vanilla CSS now. But to be honest? I think CSS was fun for a while, simply because all the stuff mentioned in the intro of the article removed many of its pain points. Flexbox, Grid, the is selector, cascade layers... all of this stuff just lets you simplify your CSS down to something that actually makes sense rather than a big ball of mud and browser hacks. I will say however that I've never really got to use those fancy colour properties though. Feels like every time I've worked on a website or app for any remotely large company, the design team had some set in stone idea about what the branding should be and would accept zero deviation from that in terms of what colours could be used for text, backgrounds, etc.
- YoshiRulz 3y agoI'm sure Google's Material 3 """designers""" will make use of the built-in colour mixing if it reduces payload size.
- FireInsight 3y agoWhat is """"designers""""? I think MD3 looks pretty good compared to googles earlier attempts...
- YoshiRulz 3y agoPerhaps it's nostalgia, but I feel like the initial "material" concept—UI components being like stacked paper—was better realised in 1 (and 2) than in 3. It wasn't the first minimalist design framework, but the spec was notably thorough in a way the new one isn't. I also preferred the barely-rounded corners and standardised colour palettes, but that's more a matter of taste.
- ForkMeOnTinder 3y agoI had the opposite thought -- I bet the new color mixing will increase payload size. Which of these would you rather send over the wire? A) color-mix(in srgb, var(--primary-color), white 50%) B) #abcdef For me to give up scss, there needs to be a minifier that calculates colors ahead of time and emits them plain, the way scss does. (Maybe there already is, who knows)
- TylerE 3y agoDifference might well be a lot less than you think after compression. XML(like) things compress almost embarrassingly well.
- coev 3y agopostcss already does this https://preset-env.cssdb.org/blog/postcss-color-mix-function/ https://preset-env.cssdb.org/blog/postcss-color-mix-function...
- egeesin 3y ago[dead]
- qingcharles 3y agoThat will make zero difference to site performance. If I didn't have uBlock running, half the sites on the Internet have 100MB+ payloads now. You could save more than those 50 compressed bytes of text by just optimizing one image on your site :) I beat myself up about performance issues like that all the time and have to catch myself to go do something more useful instead.
- YoshiRulz 3y ago> All of these features are available today, as of this reading, with every major browser supporting them in the current version That may be true, but most people don't update their browser every month[1][2] (data isn't readily available it seems, but I'm sure as a webmaster you'd be logging User-Agents and can see the long tail for yourself). So if you want or need to reach a wide audience—say, if you're writing a storefront for a business, or an e-government portal—the only new features you can use are those which fail gracefully, namely ones that are syntactically valid under the old spec+parsers. [1]: https://www.stetic.com/market-share/browser/ https://www.stetic.com/market-share/browser/ [2]: https://gs.statcounter.com/browser-version-market-share/desktop/worldwide https://gs.statcounter.com/browser-version-market-share/desk...
- dmalik 3y agoI find caniuse to be a very good resource to check for these kinds of things. Here are the stats for nesting: https://caniuse.com/?search=CSS%20nest https://caniuse.com/?search=CSS%20nest Aside: Shouldn't browsers update themselves these days? Any reason to turn this off? Seems silly from a security perspective.
- Ringz 3y ago> Shouldn't browsers update themselves these days? They should. But in the same way, admins and guidelines in authorities and large corporations should now follow a more modern update strategy. "Never change a Running System" is unfortunately still a popular, lazy excuse.
- sjfjsjdjwvwvc 3y agoIn a way I can understand them - there are often things people are used to breaking or changes in the UI with software updates (not so much with browsers usually I guess). I can sympathise with older or less technical people who are afraid of an update forcing them to “relearn” how to do something they are used to. Edit: not so much large corporations tbh.
- solardev 3y ago
- bryancoxwell 3y agoOne thing I’ve really liked about using Svelte is that it’s nudged me towards using plain CSS. Since styles are component scoped it’s allowed me to just focus on applying them in the small, which I think reduces some cognitive load for me. And I’ve been surprised at how much I enjoy solving problems with pure CSS.
- montroser 3y agoYeah, scoped css is key to reducing all sorts of complexity. The BEM approach in all is craziness is basically an attempt at scoping. And then tailwind too is trying to solve many if the same problems, from the opposite direction. In both cases people end up using their component frameworks and JavaScript libraries to build new abstractions atop the hacks to try and scope css, and the pile grows. Real scoped css with @scope has actually landed in latest Chrome and Safari, but Firefox are dragging their feet. https://developer.chrome.com/docs/css-ui/at-scope https://developer.chrome.com/docs/css-ui/at-scope https://github.com/mozilla/standards-positions/issues/472 https://github.com/mozilla/standards-positions/issues/472
- ape4 3y agoTIL about that - great. Of course, there is the poor man's scoping: .page1-card { border-color: green; } .page2-card { border-color: red; }
- hellcow 3y agoSorry for being dense, but what’s the difference between this and nested styles that just landed in every browser? I still scope my styles to a particular selector in either case.
- paradox460 3y agoScoping let's you define an upper and a lower boundary So you can cut holes in the selectivity, for say, letting blog post content have its own styles. That's the biggest advantage. There's also some minor utilities it's got, like not impacting selectivity and such, but it is one of those features that will have to see widespread use to actually grow an understanding of all it's intricacies
- croes 3y agoIsn't it a huge waste of processing power to evaluate all these styles just to show the initial state of a web site?
- solardev 3y agoIt takes milliseconds. You can time it yourself in the inspector and throttle the CPU to like 1/3 speed. I'd wager CSS is never the bottleneck. I've never once seen it be a performance issue, personally. Browsers are really really fast at rendering the DOM and styling it, especially if you only need to do it once at page load. Even modern CSS isn't really that complex compared a hundred page Indesign file, for example. Computers and phones can handle it just fine. If websites feel slow, IME it's usually ads/analytics, slow AJAX and backends, or scripting bottlenecks, loops, unnecessary redraws, efc. Not really basic DOM draws from CSS.
- Ringz 3y agoFrom the point of view of the individual CSS developer, this is of course not a problem. It is the total sum of all small electricity consumers over millions of devices that should worry us. But, as a technocrat, I believe we will find other solutions than a „software electricity consumption“ diet.
- solardev 3y agoEven by that standard it's a non issue. Just keeping the screen on takes more power. Watching TikTok for a few minutes, playing a game, watching porn, arguing on a social media app... just about anything else a phone does takes more power than rendering a web page. This is literally 20 year old technology we're talking about, optimized to heck by one of the world's biggest and most engineer driven companies. If we're worried about electricity (and we should be), we should focus on renewables and storage and nuclear, not cell phone usage. It's trivial and totally dwarfed by desktops, TVs, HVAC, light bulbs, cars, just about everything.
- Ringz 3y ago
- marc_io 3y agoGiven the increasing number of people using page builders and no-code tools, these novelties are, in practice, either invisible or delayed for a large portion of websites until it makes business sense for the companies behind the software powering these tools.
- marginalia_nu 3y agoI think in general that the accessibility of CSS and HTML5 kinda sucks. Hypercard and Flash are both great examples of the sort of creative cottage industries that can emerge when you provide more accessible means of building stuff. There's like a generations of designers that grew up playing with these sorts of tools.
- solardev 3y agoI'm glad Figma is around now, but yeah, the creative authoring experience is really sad these days. We don't even have a modern equivalent to Dreamweaver or Frontpage anymore :/
- coev 3y agoYou can still use dreamweaver if you're really a glutton for pain https://www.adobe.com/products/dreamweaver.html https://www.adobe.com/products/dreamweaver.html
- deathtrader666 3y agoWebflow and Plasmic seem to have taken up those spots.
- marc_io 3y agoBricks Builder on the WordPress side is really interesting for this.
- marc_io 3y agoWappler and Pinegrow are the closest, I think. Desktop apps with visual authoring capabilities, while also supporting plain code.
- Ringz 3y ago15 - 20 years ago I was very deep in html and css. Where would you find tutorials these days to get back on with the most modern stuff?
- Vinnl 3y agoMDN is great as a reference, but also has tutorial-style articles: https://developer.mozilla.org/en-US/docs/Learn/Getting_started_with_the_web https://developer.mozilla.org/en-US/docs/Learn/Getting_start...
- wg0 3y agoI think most notable and major changes you need to know about are the new layout models. Flex[0] and Grid[1] and media queries[2] and you're mostly up to date. There's also transform+animate module as well but I won't worry about that much. [0]. https://css-tricks.com/snippets/css/a-guide-to-flexbox/ https://css-tricks.com/snippets/css/a-guide-to-flexbox/ [1]. https://css-tricks.com/snippets/css/complete-guide-grid/ https://css-tricks.com/snippets/css/complete-guide-grid/ [2]. https://css-tricks.com/a-complete-guide-to-css-media-queries/ https://css-tricks.com/a-complete-guide-to-css-media-queries... EDIT: Formatting
- runarberg 3y agoFor layout I do recommend The New CSS Layout by Rachel Andrew (https://abookapart.com/products/the-new-css-layout https://abookapart.com/products/the-new-css-layout) it is a few years old now, but not much has changed in layout since it was published.
- nirav72 3y agoCSS became fun again after the death of IE 6.
- Rapzid 3y agoThis is why flexbox and grid didn't receive the fanfare they deserved; they launched during the dark ages.
- blackbear_ 3y agoI don't know, I still find designing user interfaces with text exceedingly awkward. Is there any good (FOSS, offline) drag-n-drop designer like those we had twenty years ago?
- JKCalhoun 3y agoI'm with you. Reading the article did not get me excited about CSS, instead just filled me with more dread.
- walteweiss 3y agoFigma!
- cynicalsecurity 3y agoI have only two questions: - How is it supposed to be fun? - Why not just stick to the most basic, simple and widely supported CSS rules?
- KRAKRISMOTT 3y ago> Why not just stick to the most basic, simple and widely supported CSS rules? Then you are back to using tables.
- cynicalsecurity 3y agoFlexbox is pretty much 100% supported and it's fun. The newest CSS features are not 100% supported and they are really annoying.
- 8n4vidtmkvmk 3y agoSome people actually enjoy designing and styling a website, imagine that. It helps when you aren't fighting with the language and can easily express what you want.
- mst 3y agoCan anybody recommend a from-scratch introduction that follows the contours of modern usage? I can certainly find introductions myself but I don't know enough to know which are sensible. (though 'read everything on MDN' is always an option)
- dimmke 3y agoWould there be interest in this as a course? This course came out somewhat recently and I think it's designed for people who came to Frontend development mostly from JS/Using React: https://css-for-js.dev https://css-for-js.dev But I've been thinking about making a course that specifically focuses on helping people who have been doing web development for a long time update their skills. Because CSS has added so many modern features but it's easy to not notice if you're already tethered to a pre processor and have been using one for 10+ years
- cmeacham98 3y agoI'm a professional software engineer that has paid for numerous books and similar learning material, and even then $399 is steep for me (and yes, I know there are cheaper packages, but they only get you part of the course).
- mst 3y agoI'm not the target market for a video course -anyway- but it wouldn't surprise me if that price point results in "fewer sales than a lower price but similar revenue and a more pleasant discord due to student investment" or so. Who knows.
- cmeacham98 3y agoI'm sure it works for some people - you can see a ton of testimonials on the website - I guess I'm just not the target audience.
- airstrike 3y ago$399 seems too steep IMHO
- NeutralForest 3y agoI think at this point I'll just leave modernizing the CSS to experts and use frameworks like Tailwind or Tachyons or whatever. It's just not interesting to me.
- cantSpellSober 3y agoThat's the jQuery trap many fell into; understanding the library but not the language underneath. A basic working knowledge of CSS will still serve you after Bootstrap/Tachyons/Tailwind are no longer flavor of the month.
- NeutralForest 3y agoI mean, I have some understanding of CSS but at some point the time I spend learning it is not worth it. I don't mean to have zero knowledge of it though, I can build a website with grid and flex and whatnot.
- edm0nd 3y agoPress X for doubt
- TibbityFlanders 3y ago[flagged]
- Eric_WVGG 3y ago> display also became animatable, so now you no longer have to figure out how to move an element between hidden, shown but not visible, and shown but visible. Anyone know of any links regarding this? (Remember when blog posts had links?)
- paradox460 3y agohttps://developer.chrome.com/blog/entry-exit-animations#transitioning_discrete_animations https://developer.chrome.com/blog/entry-exit-animations#tran...
- 8n4vidtmkvmk 3y agoThat's kind of crazy. The display none doesn't apply until after the animation is complete? I'd still want to remove it from the DOM when the animation finishes though
- gherkinnn 3y agoThis post by DHH [0] showed me that I need to take a good look at current CSS. (Scroll down for the styles screenshot) I kept up with custom properties and some newer colour management but then kinda stopped. So now it's back to basics and re-evaluate how I approach styles. Not that all the features are required at all times, of course not. But it always pays to keep up with the underlying tech. And I find CSS uniquely fun to lean, as the feedback loops are nigh instant. 0 - https://world.hey.com/dhh/once-1-is-entirely-nobuild-for-the-front-end-ce56f6d7 https://world.hey.com/dhh/once-1-is-entirely-nobuild-for-the...
- treis 3y agoIs that 0.6 seconds until first paint?
- matheusmoreira 3y agoI've been re-learning CSS this year in order to work on my website and it's been amazing. Variables alone changed everything and I can't believe it's gotten nesting support already. Things like SASS are simply not needed anymore! And it keeps getting features I couldn't even imagine. Scopes are awesome and will make selectors less complex. Those color functions are going to be very useful too, I spent way too much time fiddling with colors on my website and I have no doubt they're going to make things much easier.
- patrickdavey 3y agoWhat resources have you been using to relearn?
- matheusmoreira 3y agoThe Mozilla Developer Network. https://developer.mozilla.org/en-US/docs/Web/CSS/Using_CSS_custom_properties https://developer.mozilla.org/en-US/docs/Web/CSS/Using_CSS_c... https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_nesting/Using_CSS_nesting https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_nesting... https://developer.mozilla.org/en-US/docs/Web/CSS/@scope https://developer.mozilla.org/en-US/docs/Web/CSS/@scope
- lelanthran 3y ago> Things like SASS are simply not needed anymore! The problem with things that are not needed anymore is that they won't go away. Finally CSS has also these nice QoL things that SASS has, then SASS would add new things simply to provide value. Finally Javascript has all these nice things that make the framework redundant, then the frameworks add new things, of value, and remain relevant. After a couple of iterations of these sorts of arms races, we suddenly have a big and complicated $BASE_THING, and an even more complicated $ADDITIONAL_THING. It never ends - complexity in a specific software technology tooling, processes and development, much like entropy, only increases, it never decreases.
- robertoandred 3y agoI still use SASS functions. Hard to give those up for some things.
- xivusr 3y agoWow! I hadn’t heard of color-mix, great article!
- deleted 3y ago[deleted]
- airstrike 3y ago> All of these features are available today, as of this reading, with every major browser supporting them in the current version > This mixes your primary color with 50% white, in the sRGB space. You can use other, newer, better color spaces too, such as OKLCH, which is my favorite. Relative OKLCH colors aren't available on Firefox as of today: https://developer.mozilla.org/en-US/docs/Web/CSS/color_value/oklch#browser_compatibility https://developer.mozilla.org/en-US/docs/Web/CSS/color_value... Here's a page with example gradients in SRGB and OKLCH, in which the second gradient does not show if viewed on Firefox: https://www.learnwithjason.dev/blog/oklch-better-color-css-browser/ https://www.learnwithjason.dev/blog/oklch-better-color-css-b...
- aragonite 3y agoMy favorite new CSS feature is the Custom Highlight API, which allows you to style arbitrary (and potentially overlapping!) text ranges without needing to create ad hoc <span> element nodes. MDN Demo: https://developer.mozilla.org/en-US/docs/Web/API/CSS_Custom_Highlight_API#result https://developer.mozilla.org/en-US/docs/Web/API/CSS_Custom_... Hopefully VSCode will be able to switch to using this API for syntax highlighting in the near future for a performance boost, instead of sticking to the current superposition approach: https://github.com/microsoft/vscode/issues/175938 https://github.com/microsoft/vscode/issues/175938
- noman-land 3y agoNot available in Firefox, it seems.
- culopatin 3y agoThis is super useful for a side project of mine. I hope I have some time soon to put it to good use
- aj_g 3y agoTo add to the list, clamp: https://www.smashingmagazine.com/2022/01/modern-fluid-typography-css-clamp/ https://www.smashingmagazine.com/2022/01/modern-fluid-typogr... Such a nice property, makes responsiveness much easier to build in
- qingcharles 3y agoGod, yes. It is so much easier in 2023 to make amazing responsive designs. I try to make everything without media queries now. See also: https://utopia.fyi/ https://utopia.fyi/ https://cube.fyi/ https://cube.fyi/
- hit8run 3y agoWhat happened to @apply for css mixins? https://caniuse.com/?search=%40apply https://caniuse.com/?search=%40apply Article says it’s dead and replaced with something completely different that makes no sense. Seems there is no champion anymore pushing it forward: https://discourse.wicg.io/t/needed-new-champion-for-css-apply-rule/2012 https://discourse.wicg.io/t/needed-new-champion-for-css-appl...
- Vt71fcAqt7 3y agoIt's been around for a bit now but i would add the `lh` height unit.[0] a much more recent addition is popover[1] for dialogs which will be in the next firefox [0] https://developer.mozilla.org/en-US/docs/Web/CSS/length#lh https://developer.mozilla.org/en-US/docs/Web/CSS/length#lh [1] https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/popover https://developer.mozilla.org/en-US/docs/Web/HTML/Global_att...
- qingcharles 3y agoI would urge all designers to get comfy with all the various units... there are a lot of really minor ones which will help you out enormously: https://developer.mozilla.org/en-US/docs/Learn/CSS/Building_blocks/Values_and_units#numbers_lengths_and_percentages https://developer.mozilla.org/en-US/docs/Learn/CSS/Building_...
- 29athrowaway 3y agoAn interesting fact is that .su, the TLD used by the linked website, is the TLD for the Soviet Union. So effectively the Soviet Union never ceased to exist on the Internet. https://en.wikipedia.org/wiki/.su https://en.wikipedia.org/wiki/.su
- qingcharles 3y agoThat's fascinating considering the TLDs for places like East Germany and Yugoslavia were dissolved.
- croisillon 3y agoso this blog is subsidizing criminals, yay
- busterarm 3y agoonce a Cascading Shit Show, always a Cascading Shit Show. all credit to @fat, whose talk on the Cascading Shit Show is sadly no longer on youtube. At least I still have the socks.
- cies 3y agoI think the `@scope` feature (not widely supported yet) would make CSS a bit more fun for me personally. Apart from that glimpse of hope, I'd not go as far as calling CSS "fun" anytime yet.
- qingcharles 3y agoI agree with the article, CSS has got really great. I was gone for 10 years (jail) and before I left CSS was still a real bear with tons of little hacks and killing yourself to make floats work. The biggest change to the Internet when I got out was that CSS was rather lovely and for the first time in 30 years of web designing I actually enjoy doing layout. I'll have a party though the day CSS Masonry layout is no longer hidden behind flags: https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_grid_layout/Masonry_layout https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_grid_la...
- gabrieledarrigo 3y agoSorry if I ask you, but why you were in jail?
- AeroNotix 3y agoDid something illegal
- qingcharles 3y agoThat's how it usually works...!
- 8n4vidtmkvmk 3y agoEmphasis on usually.
- traeregan 3y agoI don't know the answer but I did find their Beanie Babies exploit entertaining: https://news.ycombinator.com/item?id=38227823 https://news.ycombinator.com/item?id=38227823
- recursive 3y agoDoesn't seem like you're actually sorry, since you could have just not asked.
- rekabis 3y ago> it had gathered a reputation of being brittle and difficult to work with. For the most part… NO. At least 98+% of the cases I have seen of developers getting frustrated over the “limitations” and “warts” of CSS has boiled down to a lack of understanding of the cascade; a fundamental feature of CSS that IMO produces nearly all of the frustrations that un-/under-skilled devs run into. If CSS is being inconsistent, you need to look at the cascade from both ends: from how CSS applies it’s styling, and from how HTML is assembling the content (which can also break the cascade). One way or the other, the problem is nearly always an issue of implementation. Source: doing web pages since 1993. That’s 30 years of experience speaking.
- isleyaardvark 3y agoI agree with you, but when a fundamental feature is so easily and often misunderstood, I’d say that makes it “difficult to work with” by definition.
- youcantcook 3y ago[dead]
- divbzero 3y agoYou might not need jQuery (https://youmightnotneedjquery.com/ https://youmightnotneedjquery.com/) shows pure JS implementations of common jQuery methods. Someone should create an analogous You might not need SASS to help developers move to pure CSS.
- chris_wot 3y agoI recently recreated a website that used a lot of jquery. I didn’t use any JavaScript, it was all CSS.
- asah 3y agosweet! but alas, I'm looking through the examples and one line of simple+clear JQuery is a often a dozen tricky lines of pure CSS.
- divbzero 3y agoI usually take it as suggestive code that you don’t have to use verbatim. For example, You might not need jQuery offers the following suggestions: // toggle visibility function toggle(el) { if (el.style.display == 'none') { el.style.display = ''; } else { el.style.display = 'none'; } } // remove multiple elements for (const el of document.querySelectorAll(selector)) { el.remove(); } While the following would be more concise: // toggle visibility function toggle(el) { el.style.display = el.style.display === 'none' ? '' : 'none; } // remove multiple elements document.querySelectorAll(selector).forEach(el => el.remove());
- Rapzid 3y agoCalc deserved more attention in this article; it's really amazing what you can do with it. I'm using it in an application to center content inside a flexible container.. Using calculated padding. One of the coolest new features on the horizon is the anchor positioning system. CSS is still frustratingly complicated and nuanced in a way that's typically opaque to developers. For instance why do you need min-width/min-height 0 on nested flex containers to prevent unexpected overflowing? The answer is surprisingly complicated.
- kasajian 3y agoI almost ignored this entire article because I didn't see a date at the top of the blog. No date on a blog is the first sign of something fishy. But scrolling all the way down, you can see there's a published date. Weird place to put the date. Is this something new?
- monkeynotes 3y agoI don't think this person actually worked with CSS in the early days. The clearfix trick was back then, not now. It was back "in the day" that we had to do shitty workarounds like clearfix. Like CSS wasn't fun back then, at all. CSS wasn't fun, then not fun, and now fun again. CSS has been on a steady trajectory out of awful but it works, to predictability, and much more fit for purpose. React and the like have allowed for tight namespacing which makes collisions a thing of the past, and so the "cascading" element is less of a problem.
- chris_wot 3y agoI thought he was saying it was a cheap trick? “Tricks like clearfixes arose; bits of knowledge you just had to find and use, and then apply like cheap plaster in a house you intend to flip.”
- paradox460 3y agoIndeed I was. No one actually liked clearfix, but we had to do it. It was the bit of plaster smeared over the hole the door knob punched in the wall. A necessity, but not a nice one
- monkeynotes 3y agoBut CSS isn't "fun again" if it wasn't fun before. And it certainly was not fun before, it was a horrible nightmare of non-standard implementation and an ill fit for what designers wanted to do.
- paradox460 3y agoIt was fun compared to table and sizer gifs
- rambambram 3y agoOfftopic: dear owner of pdx.su, your RSS feed gives a wrong URL for your site.
- paradox460 3y agoThanks for catching that. I probably missed it when migrating SSGs last month. I'll get a fix up this evening
- mpawelski 3y agoWith all the recent CSS improvements I still miss the possibility to have working transition to "height:auto". The issue [1] on csswg-drafts is the most upvoted one. At least we can now use css grid and track sizes transitions, but it's far from intuitive, transition for "height:auto" should just work. [1]: https://github.com/w3c/csswg-drafts/issues/626 https://github.com/w3c/csswg-drafts/issues/626