WebCraft's avatar
WebCraft
web-weasel@qwibbit.com
npub1zete...rj75
Web design tips and small clever coding ideas. Unofficial automated fan feed. Content belongs to its respective owners; not affiliated with source publishers.
WebCraft's avatar
WebCraft 3 weeks ago
Taming Typography: Building a Modern CSS Reset Stu created tidy-typography.css: a style reset for taming typography with modern CSS features for everything from fluid typography and vertical rhythm, to hyphens and variable fonts. Taming Typography: Building a Modern CSS Reset originally handwritten and published with love on CSS-Tricks. You should really get the newsletter as well. #moderncss #cssreset #tamingtypography #building #rss #feeds #linksharing #qwibbit
WebCraft's avatar
WebCraft 3 weeks ago
Making Immersive LLM Chat Experiences More Accessible I have had the privilege of helping to improve the accessibility of multiple immersive LLM chat experiences in the course of my career. Now I want to share this knowledge with you. Accessibility is a core part of a functional digital experience. As the LLM chat pattern continues to spread like wildfire across the web, we risk excluding people if these experiences are not built with accessibility as a core consideration. It is also worth re-mentioning what “exclusion” means here: It’s the loss of knowledge, the loss of opportunity, the loss of utility, the loss of employability, the loss of entertainment, and more. What Is An Immersive LLM Chat Experience? “Immersive LLM chat experience” is a catch-all term for full-screen experiences like Claude, ChatGPT, GitHub Copilot, Gemini, America.gov, Glean, and other similar websites and web apps: The majority of what this post covers applies to both web apps and native apps. This is because these experiences are typically built using web technologies, then placed in a native wrapper via frameworks such as Electron or Tauri. Immersive LLM chat experiences are not patterns such as a pop-up chat, inline text generation utilities, or summarization tools. These simpler applications of LLM technology will have different considerations and expectations. Instead, this is a starting point for making those other experiences accessible. Reframing There is nothing special about chat-based UIs when viewed via the lens of the Web Content Accessibility Guidelines. They are interactive experiences, built using web technologies. The losses I’ve described — and the legal liability associated with them — are access barriers in the same way any other web content can be an access barrier. I would also like to mention the social model of disability here: the idea that exclusion can be created by the built environment. For example, consider an elevated entryway that uses a gently sloping ramp in place of stairs. Built environments also extend to digital experiences, and the social model also applies here. The main activities undertaken to operate an LLM chat are already well-established: Inputting text and submitting it, and Reading content and taking action on it. It is how we facilitate — or fail to facilitate — those interactions that’s the salient bit. Visual Bias Before we get into the technical aspects, we must consider the overwhelming visual bias that permeates software creation. We live in a highly visual culture, so our outputs unconsciously reflect and reinforce that. What we need to do here is be aware of and think through the non-visual considerations. While not all disabilities are blindness or low vision conditions, a lot of the core interactions of an LLM chat do need specific accommodations for these two types of disability. Recall the social model of disability here, and how it applies to the main flow of using an LLM-based chat. You: Type some words into an input and send it as a message, Wait for the LLM to parse your message, then Read the message the LLM generated. Let’s demonstrate at a high level what someone who can fully see the screen experiences compared to someone who uses a screen reader and cannot see the entire screen, or large portions of it: (Large preview) Visually, we can see the LLM reply appear. Someone who uses a screen reader does not know new content has appeared because: Their focus is still on the input that sent the prompt. No non-visual mechanism is present to signal new content showed up. So, how do we create an experience for someone who uses a screen reader that is equivalent to the experience of someone who can fully see the screen? To start, we use live regions. Use Live Region Announcements Live region announcements will enable someone to know what the LLM has responded with without having to move focus from the input used for prompting. This is equivalent to someone who can see the screen, glancing upwards to read the LLM response when it appears. First, read this excellent article by TetraLogical if this is your first attempt at getting live region announcements working. They’re tricky to get right, and this article sets the record straight. One common pitfall I want to call specific attention to is applying aria-live on each LLM response message. Don’t do this. Instead, use a dedicated live region area to announce each message’s content. The live region area should be placed at the end of the DOM and used for all live region messaging. This method is far more stable and reliable, which is important for ensuring everyone understands what the experience is communicating. With that established: What we want to do is trigger a live region announcement when the LLM’s chat reply shows up in full on the screen. (Large preview) This creates an outcome where you can read the message if you can see the screen, and hear or feel the message if you cannot. Usability Considerations There are a few things to do when creating a good user experience for the people who rely on these live region announcements. These considerations mean the difference between a compliant-yet-unusable outcome and something that genuinely works for the person using it. Only Announce The Completed Message Attempting to announce the message as it streams in may create a juddering and confusing experience that’s difficult for someone to parse. It is better to wait until the message has completed streaming, and then announce the message’s content in full. (Large preview) Let Someone Know Their Request Is Processing Responses from an LLM often take time to complete. Generally speaking, there are three ways to show a response is still processing: Using text, Using a loading animation, Using text and a loading animation. These experiences are typically only shown visually. If you cannot see the screen, it may lead to it feeling like the experience has stalled or crashed — especially if the response is for a large or complicated request that takes a while to work through. To address this, we’ll want to use live region announcements: If text is visually shown on the screen: Ensure a companion live region announcement is also triggered at the same time the loading message text is displayed. The text string for the live region announcement should be the same as what is shown visually, to be sure to ensure parity of experience: (Large preview) If a text-less loading animation is shown on the screen: Ensure the loading state is also communicated to assistive technology. A live region announcement that mentions the reply is loading after a set amount of time will facilitate an equivalent experience for this interaction. It doesn’t have to be too verbose; the word “Loading” can suffice: (Large preview) Triggering the loading message five seconds after prompt submission seems to be the sweet spot, according to the inclusive user research I evaluated. You can then have your logic repeat the loading message every five seconds until the LLM completes its actual reply. Be sure to also announce the reply immediately as it finishes streaming. You don't need to wait until the next five-second loading message cycle is complete. Also consider randomly selecting from a set of different phrases that communicate that a response is being formulated after the initial “Loading” message is dispatched. This helps in scenarios where someone may think the loading experience itself has crashed or stalled. (Large preview) A Note About ariaNotify() We’ll eventually be able to replace the technique TetraLogical outlined with ariaNotify(). It is a much-needed and welcome addition to the platform, and will drastically lower the hacks and headaches many developers encounter when creating and managing live region announcements. Baseline lists the ariaNotify() method as having cross-browser availability at the time of this article’s publication. However, there are two factors to consider here: The presence of evergreen browsers does not automatically guarantee something is automatically available. There are a whole host of factors that can conspire to keep someone from using the latest and greatest browser version. Many people who rely on assistive technology have upgrade hesitancy. This is a learned behavior, as you want to be risk-averse and avoid breaking the primary mechanism you use to operate a desktop, laptop, tablet, or smartphone. Also consider that while a polyfill for ariaNotify() is available, you need to factor in whether it has both: The full, wide range of support in the actual compared to the dedicated DOM live region technique. A support policy that is conducive to your organization’s level of accessibility buy-in. What this realistically means is holding off for a while on ariaNotify() in favor of the tried and true TetraLogical live region technique. Use Headings Headings are the most popular way people who use screen readers navigate around an experience. Because of this, I advocate for inserting visually-hidden headings before each chat message. Here’s a simplified version of that in code: <article> <hX class="sr-only" aria-label="You said/{agent name} said" tabindex="-1"> You said:/{agent name} said: </hX> <div> {message body} </div> </article> To break this down: The article element is used to encapsulate each individual message. hx is a placeholder for the heading level. I’m using an h2 in our actual context example, as the h1 will be the chat session’s title. class="sr-only" applies a treatment that hides the text visually, but ensures screen readers can access it. aria-label repeats the heading element’s string value verbatim. This handles a couple of screen reader bugs, ensuring the vital name part of WCAG’s Name, Role, Value success criterion is present if a heading receives focus — more on that in a bit. tabindex="-1" is the mechanism that allows said heading to receive focus. {agent name} is a placeholder for the name of your LLM. Real-life examples are Claude, Copilot, ChatGPT, etc. I‘m going to call my example coding agent “Cody” because I’m clever and funny. And here’s what the code might look like using the actual content from a human question and an LLM response: <article> <h2 class="sr-only" aria-label="You said:" tabindex="-1"> You said: </h2> <div> what are the strengths and drawbacks of using utility css? </div> </article> <article> <h2 class="sr-only" aria-label="Cody said:" tabindex="-1"> Cody said: </h2> <div> Utility CSS trades cleaner global styling for faster, more explicit component styling. It works best with component-based frameworks, where repeated class groups can be encapsulated. It is less attractive when semantic HTML must stay visually uncluttered or styling changes independently from templates. </div> </article> So, why the “You said:”/”Cody said:” prefix? Remember the visual bias. Visually, we can see the left- or right-hand alignment of messages, used to indicate who is saying what. The prefix serves the same purpose: identifying the message’s owner. This allows people to quickly move through a conversation the same way someone might quickly scroll upwards to re-establish context, checking who said what and when. Use Landmarks, But Not Too Many Using landmark regions to wrap the larger overall areas of your LLM chat experience helps people understand its overall layout. It can also enable quick screen reader navigation to each area: The nav element contains a list of sessions. The main element contains the session messages. The form element contains the input you use to write prompts. The aside element contains a sidebar used to display code or other generated content. Landmarks allow someone who cannot see the screen to learn about its overall makeup. This is the equivalent of how we quickly move our eyes and tilt our heads to different overall areas when scanning the screen to initially learn the overall layout of an experience. I am hesitant to wrap chat messages in section or other landmark elements. The reason for this is that they “pollute” the list of landmarks a screen reader can generate, making navigation more laborious. This is especially relevant for long-running sessions where many messages are present. Compare the following and ask yourself which one would be easier to move through with your keyboard if trying to jump from the prompt content area back to the sessions area: Here, our visually hidden heading elements serve as a dedicated navigation mechanism for moving through the LLM conversation. Use Skip Links And Composite Widgets In addition to headings and landmarks, there are two other ways to let people get around quickly: 1. Skip Links Skip links — sometimes referred to as skip navigation — allow you to quickly jump to another area on the same page or view. Skip to main content links are commonplace on many mature websites and web apps. Immersive LLM chat experiences should be no different. Place a skip link in the DOM that allows someone to jump to the main conversation area before any other DOM content that is shown visually on the screen. Also consider using additional skip links that enable: Quickly jumping to the prompt input, as well as Bypassing the side panel list of conversations to quickly access the area where profile information and settings are located. 2. Composite Widgets Composite widgets are used when a discrete section of content contains multiple interactive elements. Focus is then managed within this section by the developer, so that: The entire overall content area is one tab stop, and Its child interactive elements are navigated via keyboard. For the purposes of an immersive LLM chat experience, we want to make conversation lists composite widgets. This enables someone to quickly navigate both within and past the entire list. Here, consider the use case of someone who exclusively relies on a keyboard to navigate. Compare pressing Tab 50 times to get through each of the 50 conversation sessions you’ve created versus pressing Tab once. Now consider motor control conditions where those keypresses can be fatiguing, or even painful to perform. Once someone places focus on a conversation list composite widget, they can use the Up and Down arrow keys to navigate through each conversation session list item. (Large preview) As a quality-of-life improvement, I also like to support the following keyboard interactions: Home and End to jump to the topmost and bottommost conversation session list items. Typeahead, to match the characters typed with the starting characters of the conversation list item’s title. This is equivalent to what you can do with items within a select menu. Don’t Use A Feed Pattern To save you a lot of headaches and prototyping: Corner cases around focus management and usability expectations for people who rely exclusively on keyboards work against you if you try to go with a feed pattern approach. There’s no need to unnecessarily overcomplicate things. The article elements’ wrapping messages with visually-hidden headings approach that I’ve described earlier is both simple and effective. People who use assistive technology understand the simpler approach, and it involves far less effort to maintain. It’s a win-win! Consider Supporting Control + F6 Navigation Pressing F6/Shift+F6 to hop around different areas of the app is an older navigation technique some people who use Windows screen readers employ when navigating through installable desktop apps. Think of it a lot like navigating by landmark. (Large preview) LLM chat experiences are effectively apps in their own right. Because of this, we can recreate the F6 navigation experience and accommodate those who might attempt it. That means: Using Control+F6/Control+Shift+F6 for web experiences. Here, Control serves as a focused modifier key, as the browser itself already has F6 navigation support built into it. Using F6/Shift+F6 for native app experiences built using web technologies. This is because a dedicated, installable app has the expectation that it will operate like one, regardless of how it was built. How To Build F6 Navigation There’s no secret sauce here. For starters, place an id on each landmark, as well as tabindex="-1". Also ensure each landmark other than main has an accessible name, granted via #llmchat #immersivellm #chatexperiences #accessible #web #built #making #webcontent #rss #feeds #linksharing #qwibbit
WebCraft's avatar
WebCraft 3 weeks ago
Smashing AI Conference The AI 2027 Conference is a live online day for designers and engineers on where AI stands today, what to expect in 2027, and where teams are getting it right. Smashing AI Conference originally handwritten and published with love on CSS-Tricks. You should really get the newsletter as well. #conference #smashing #ai #rss #feeds #linksharing #qwibbit
WebCraft's avatar
WebCraft 3 weeks ago
Re-Implementing :nth-child() With Modern CSS Combining :nth-child with style queries and sibling-index() to conditionally select child elements. Re-Implementing :nth-child() With Modern CSS originally handwritten and published with love on CSS-Tricks. You should really get the newsletter as well. #moderncss #rss #feeds #linksharing #qwibbit
WebCraft's avatar
WebCraft 3 weeks ago
Modern CSS Might Make Your Front-End More Complex Have you ever replaced fifty lines of JavaScript with a few lines of CSS, merged the PR, and felt like you just did the codebase a favor? You replace ResizeObserver with a container query, the diff is mostly red, and everyone approves it before lunch. This was what it looked like before you made the change: The selector matches more than we meant. The :has(img) rule matches any descendant image, so the comment’s avatar counted as a hero image. And the p element selector matches any descendant paragraph. As a result, the comment’s text was caught in the selection. The selector outweighed the comment’s own rule. MDN’s specificity guide explains that :has() adds no weight by itself, but its argument does. That gives .card:has(img) p a specificity score of 0-1-2, while .comment p comes in at just 0-1-1 and loses the battle. It could get even more complex and difficult to catch because the state changes at runtime. Let’s say a user posts a comment that includes an avatar. The body text of the card above it loses its spacing. Good luck reproducing that from a bug report that says “spacing looks off sometimes.” The fix is to constrain the selector with child combinators: .card:has(> img) > p { margin: 0; } This helps the selector get more specific about what it is yelling about. Nesting Also Borrows Weight Native nesting has the same habit. MDN’s guide to nesting and specificity says the & selector takes “the largest specificity in the associated selector list,” exactly like :is(). Look at this adaptation of MDN’s example: /* Specificity 1-0-0 */ .card, #featured { /* Specificity: 1-0-1 */ & a { color: blue; } } /* Specificity: 0-1-0 */ .button { color: red; } A .button link inside a .card is blue, even though the #featured ID is nowhere near it. The usual reaction is a more specific .button rule, then an exception to that rule. Before you know it, you are in a war of specificity you never knew you had declared. The way out is to keep the selector list and drop its weight by wrapping it in :where(): /* :where() always weighs 0-0-0 */ :where(.card, #featured) { /* Specificity: 0-0-1 */ & a { color: blue; } } /* Specificity: 0-1-0 */ .button { color: red; } Plain links inside a card are still blue, and the .button link is red again. Again, another way to quiet the loud housemate. Layers Don’t Rescue You By Default Don’t be fooled into thinking specificity is the whole story. MDN’s introduction to the cascade puts origin, importance, and cascade layers ahead of specificity, and notes that “normal layered styles have less precedence than normal unlayered styles.” In my test, a layered rule with a specificity of 0-4-0 lost to an unlayered .title (0-1-0). So if your new component styles go into @layer components while the legacy stylesheet stays unlayered, the legacy rule wins every conflict, however carefully you wrote the new one. The exception is when the !important keyword is used, because it actually reverses the cascade order. Miriam Suzanne’s original proposal for cascade layers describes exactly the pain layers were meant to remove: having to “be very careful with matching specificity to layer.” Layers do remove it, but only when the rules on both sides of the conflict are layered. A half-layered codebase just gives you one more ordering to keep in your head. An Old Fight With A New Tool None of these battles started with :has() or nesting. In an r/webdev thread titled “CSS-in-JS: What’s the biggest performance drop you actually felt?”, one of the most upvoted answers isn’t about performance at all. It is about the cascade: “Here’s a fun one: refactoring your JS can cause your CSS to break, because your CSS builds are determined by JS import orders.” — mq2thez This is about the “order of appearance,” which is the last step in the cascade that ends up deciding a conflict nobody knew existed. Another commenter in the subreddit adds that the injected styles can land in a different order in development and production builds: “Who doesn’t love debugging something that works locally but not in prod.” Not everyone in the thread agrees on who is to blame. TheThirdRace replies, “It’s a coding issue, not a technology issue.” I think both are right, and that is exactly the point. CSS-in-JS is a different technology from the native features we are looking at, so take this as a neighboring example, not as proof. But the shape of the problem is the same: the tool did what it promised, and the trouble arose from how it complied with the existing rules. Before you add the rule: Constrain it. Use > so the selector stops at the component’s own children. Drop the borrowed weight. Wrap heavy selectors in :where(), which always has a specificity of 0-0-0. Check the layers. Which layer does your rule land in, and where do its competitors live? Scenario 4: The Housemate That’s Slow To Pay Rent “We moved it to CSS, so it’s faster now.” You have probably heard this in a code review, and maybe said it yourself. In my last article, I warned that it isn’t always the case. Let’s test it. Moving a behavior from JavaScript to CSS changes who does the work. It doesn’t tell you how much work there is. The last housemate, the browser’s rendering engine, is the one who gets the bill. Everyone in the apartment shares it, and nobody looks at it after the move. Take :has() as an example. Browser vendors were worried about its cost from the start. In a CSS Working Group issue about :has() restrictions, Emilio Cobos Álvarez noted that implementations wanted to ship it with limitations “in order to prevent performance footguns and complexity.” Today, MDN’s :has() page has a whole section on performance with two pieces of advice: Don’t anchor :has() to an element with a large subtree, “like body, :root, or *.” Constrain the inner selector with > or +, because otherwise “the browser might need to traverse the entire subtree of the anchor element on every DOM mutation.” I wanted numbers, so I built a list with 5,000 rows. The test toggles an .is-selected class on the same row 300 times, so the row’s selected state changes on every toggle, and forces a style and layout update each time. I ran it in Chrome 153 on a Mac in October 2026, and recorded a trace in DevTools to count how many elements each toggle restyles. See the Pen Scenario 4: The Rewrite Nobody Measured [forked] by Shoyombo Gabriel Ayomide. Rule What is in the stylesheet Median time per toggle Elements restyled 1 JavaScript toggles a class on the toolbar Under 0.1ms 1 2 body:has(.row.is-selected) .toolbar About 1.4ms 1 3 .list:has(.cell > b) .row, with the toolbar handled by JavaScript Under 0.1ms 1 4 Rules 2 and 3 together About 7ms 5,001 5 For scale: JavaScript restyles all 5,000 rows on every toggle About 6ms 5,001 There are two lessons in that table. First, the “bad” selector was fine. Rule 2 is exactly the shape MDN warns against: a :has() anchored to body. It cost about a millisecond and a half more than the script, and it restyled a single element, the toolbar. A frame at 60Hz lasts 16.7ms, so I would take that trade for deleting an event handler any day. Second, two harmless rules were not harmless together. Rule 3 styles the rows, and its :has() condition remains unchanged throughout the test. On its own, it costs nothing measurable. Put it in the same stylesheet as the second rule instead, and every toggle restyles all 5,000 rows plus the toolbar. That is about what it costs a script to restyle every row on purpose. Let’s keep this in proportion. Since 7ms still fits inside a frame, nobody would notice it on this page. However, the browser is now restyling 5,001 elements to change just one, and neither rule says so. Also, the cost grows with the list. When I set the demo to 20,000 rows, the two rules together restyled 20,001 elements and took about 31ms per toggle, which is nearly two frames. I can tell you what Chrome does here, but not why. Changing .is-selected on one row restyles every element that the other :has() rule targets, even though that rule never mentions .is-selected and its result never changes. I have filed this with the Chromium team as an issue, with a reduced test case, and I only tested Chrome. Whatever the cause, neither rule looks suspicious in a code review, and the cost applies only when both are met. That is system complexity in a single table. And please take the pattern from it, not the numbers: this is one page, one browser, and one machine. The same goes for animation. The animation guide on web.dev recommends restricting animations to opacity and transform where possible, and warns that “an animation that moves an element using something other than transform is likely to be slow.” MDN’s CSS performance guide lists the properties that trigger layout when animated, such as width, height, margin, top, and left. A CSS transition on left runs layout on every frame, while a JavaScript animation of transform skips it. The property determines the cost, regardless of which language you write it in. To be fair, CSS often wins. A script that reads layout, writes styles, and reads layout again forces the browser to do layout several times in one frame, and a container query hands that whole job to the browser. But that win is something you can measure, so measure it: Record the interaction in the “Performance” panel of Chrome DevTools, before and after the change. Compare the time spent in “Recalculate Style,” “Layout,” and “Paint.” Enable CSS selector stats in the panel’s settings to see which selectors cost the most. Use production-sized data. A 20-row fixture hides what a 5,000-row list reveals. When All Four Show Up In One Pull Request Each of these scenarios is small on its own. The trouble is that a real migration could hit all four scenarios at once. You have already seen three of them. They are the three bugs in the “after” demo at the top of this article. Add a long list, and you get the fourth. One move-in, four housemates disturbed. A team replaces a card’s JavaScript-driven responsive layout with a container query and :has(). The pull request adds twelve lines of CSS, deletes one script, and misses another. Within a month, three bug reports land, and there’s a chance a performance trace turns up as the fourth problem: The card title is too big on tablets. The observer still sets .card--wide, and one rule still reads it. The developer goes digging through the JavaScript. The cards on the dashboard have disappeared. On the dashboard, the card is a flex item, and inline-size containment collapsed it to 0px. The developer reads the parent’s layout. The text is squashed in some cards. Those cards have comments with avatars, so .card:has(img) p matches. The developer traces the winning declaration in DevTools. Selecting a row might become laggy for our biggest customer. At 5,000 rows, the two :has() rules cost about 7ms per selection. That fits within a frame, even though each selection restyles 5,001 elements, whereas it used to restyle one. As the number of rows increases, the elements restyled increase, and the cost of the two :has() rules per selection will also increase, but who renders a table with a large number of rows without pagination? None of these reports means that container queries or :has() were the wrong choice. Each bug lives in the meeting point between the new CSS and the system it moved into. Still, one small pull request has sent a developer through the JavaScript, the page layout, the cascade, and the profiler. And the way out is not a return to JavaScript. Here is the same page once more, fixed. See the Pen demo (fixed PR) [forked] by Shoyombo Gabriel Ayomide. It still uses a container query and :has(), with three changes: The observer and the leftover .card--wide rule are removed, so the layout has a single owner. The query container is a wrapper that inherits its width from the surrounding layout, so the card can no longer collapse. The selector is constrained to the card’s own image and its own paragraphs, so the comment keeps its spacing. This gap between a clean start and a real codebase shows up in the same r/webdev thread. The person who started it, JRM_Insights, opens with an observation that could describe any of our four scenarios: “I often find that the initial tooling simplicity gives way to harder-to-debug runtime styling issues.” — JRM_Insights Further down, mq2thez describes moving an old CSS-in-JS codebase to a newer pattern: “In isolation or greenfield maybe it wouldn’t be a huge issue,” but in practice, it meant rewriting “whole component trees.” TheThirdRace, who had been defending the technology, answers that they had only ever evaluated it “from a greenfield project perspective,” and that it was “very enlightening to see this through the lens of a spaghetti CSS migration.” That is the honest version of this whole article. Most of what we read about a new feature is written from the greenfield perspective. Most of what we ship is a migration. Your Migration Checklist Before you replace JavaScript with a modern CSS feature, or adopt one in an existing codebase, answer these six questions. Think of them as the conversation to have with the housemates before the new tenant gets a key. I suggest putting the answers right in the pull request description. Ownership: Is exactly one of CSS or JavaScript the owner of this behavior? Scope: What changes for the element’s formatting context: its width, its parent, its children, and its neighbors? Cascade: Which existing rules could override this one, and which rules could it override? Migration: Have you deleted the old implementation, including every class and selector it relied on, and tested every state? Performance: Have you measured the real workload before and after, rather than assuming the rewrite is faster? Maintainability: Can the next developer tell why this rule exists and where its effects stop? Conclusion Modern CSS is great and a huge improvement to styling as a whole. In particular, container queries and :has() let us express things that used to need a script, a dependency, or a hack. But a new capability does not hand us a simpler system by default. In every scenario we looked at, the new tenant did something that didn’t sit well with others, and that was because nobody introduced them to the housemates’ ways of doing things. We get a simpler system when the new rule has one clear owner, a scope we have checked, a place in the cascade we chose on purpose, and numbers showing it helped. So, the next time a pull request deletes more than it adds, enjoy the red lines. Then ask where the complexity went, and run the six questions. If you can’t answer one of them, the migration isn’t finished yet. References Container queries (MDN) container-type (MDN) Block formatting context (MDN) :has() (MDN) Specificity (MDN) Introduction to the CSS cascade (MDN) CSS nesting and specificity (MDN) CSS performance optimization (MDN) How to create high-performance CSS animations (web.dev) “[selectors] [css-conditional] Detecting :has() restrictions”, CSS Working Group issue #7280 “[css-cascade] Custom Cascade Layers”, CSS Working Group issue #4470 “Modern Frontend Complexity: essential or accidental?”, Igor Roztropiński (subreddit discussion) “CSS-in-JS: What’s the biggest performance drop you actually felt?”, discussion on r/webdev #rss #feeds #linksharing #qwibbit
WebCraft's avatar
WebCraft 3 weeks ago
What’s !important #20: GTA 6 Scroll Effects, Scrollspies, random() This is the final issue of What’s !important on CSS-Tricks.com. The good news is that it’s coming back in an expanded form as the CSS-Tricks newsletter. I had ya there for a second, didn’t I? Sorry, I couldn’t decide whether to trick or treat, so I went for both. Happy Halloween What’s !important #20: GTA 6 Scroll Effects, Scrollspies, random() originally handwritten and published with love on CSS-Tricks. You should really get the newsletter as well. #rss #feeds #linksharing #qwibbit
WebCraft's avatar
WebCraft 0 months ago
A Spark Of Color In November’s Gray (2026 Wallpapers Edition) November can feel rather gray in many parts of the world, so what better way to brighten the month than with some colorful inspiration? Our new collection of desktop wallpapers has you covered. Following our monthly tradition, which has been going on for more than 15 years already, the wallpapers in this post were designed by artists and designers from across the globe. All of them come in a variety of screen resolutions and can be downloaded for free. A huge thank-you to everyone who shared their creations with us — this post wouldn’t be possible without your wonderful support! If you would also like to get featured in one of our upcoming wallpapers posts, please don’t hesitate to join in. We are always looking for creative talent and can’t wait to see what you come up with! Happy November! You can click on every image to see a larger preview. We respect and carefully consider the ideas and motivation behind each and every artist’s work. This is why we give all artists the full freedom to explore their creativity and express emotions and experience through their works. This is also why the themes of the wallpapers weren’t anyhow influenced by us but rather designed from scratch by the artists themselves. From Spooky To Scruffy “Halloween may be officially over, but the real monster mash is just getting started on your face. This month, we swap the plastic vampire fangs for the ultimate terror: thirty days of completely uninhibited facial hair growth. Think of it as extended character cosplay. By week three, you won’t just be skipping your morning shave, you’ll be auditioning to play Cousin Itt in the next Addams Family reboot. Embrace the itch, dodge the hairbrushes, and let your chin go full ghoul. Who needs a costume when your jawline is the haunted forest?” — Designed by Predrag Kovacev from Serbia. preview with calendar: 320x480, 640x480, 800x480, 800x600, 1024x768, 1024x1024, 1152x864, 1280x720, 1280x800, 1280x960, 1280x1024, 1400x1050, 1440x900, 1600x1200, 1680x1050, 1680x1200, 1920x1080, 1920x1200, 1920x1440, 2560x1440 without calendar: 320x480, 640x480, 800x480, 800x600, 1024x768, 1024x1024, 1152x864, 1280x720, 1280x800, 1280x960, 1280x1024, 1400x1050, 1440x900, 1600x1200, 1680x1050, 1680x1200, 1920x1080, 1920x1200, 1920x1440, 2560x1440 One More Bat “While I was playing with parametric curves, I noticed a gap inside my drawing: it looked like a bat shadow. Bats are protected animals, not only during Halloween.” — Designed by Philippe Brouard from France. preview with calendar: 1024x768, 1366x768, 1600x1200, 1920x1080, 1920x1200, 1920x1440, 2560x1440, 2560x1600, 2880x1800, 3840x2160 without calendar: 1024x768, 1366x768, 1600x1200, 1920x1080, 1920x1200, 1920x1440, 2560x1440, 2560x1600, 2880x1800, 3840x2160 Lost In Time “All those moments will be lost in time, like tears in the rain. November is here, a transitional month leading into December, winter, and everything that entails. November reminds me of home, the warmth of being indoors and enjoying unique, unrepeatable moments, which brings to mind a fitting line from Blade Runner.” — Designed by Veronica Valenzuela from Spain. preview with calendar: 640x480, 800x480, 1024x768, 1280x720, 1280x800, 1440x900, 1600x1200, 1920x1080, 1920x1440, 2560x1440 without calendar: 640x480, 800x480, 1024x768, 1280x720, 1280x800, 1440x900, 1600x1200, 1920x1080, 1920x1440, 2560x1440 AI In 2027 “Let’s get ready for our shiny new AI 2027 Conference (online), with friendly, approachable experts showing how to set up AI-ready design systems, run AI-driven research, and design for trust in AI. Dec 1, 2026. Tickets are only €50. See you there?” — Designed by the Smashing Magazine Team. preview with calendar: 640x480, 800x480, 800x600, 1024x768, 1024x1024, 1152x864, 1280x720, 1280x800, 1280x960, 1280x1024, 1366x768, 1400x1050, 1440x900, 1600x1200, 1680x1050, 1680x1200, 1920x1080, 1920x1200, 1920x1440, 2560x1440, 3840x2160 without calendar: 640x480, 800x480, 800x600, 1024x768, 1024x1024, 1152x864, 1280x720, 1280x800, 1280x960, 1280x1024, 1366x768, 1400x1050, 1440x900, 1600x1200, 1680x1050, 1680x1200, 1920x1080, 1920x1200, 1920x1440, 2560x1440, 3840x2160 Be Proud Of Yourself “Be proud of yourself for how far you’ve come. You’ve handled things that once felt impossible.” — Designed by Hitesh Puri from India, Delhi. preview with calendar: 1024x1024, 1280x800, 1280x960, 1280x1024, 1400x1050, 1440x900, 1600x1200, 1680x1050, 1680x1200, 1920x1080, 1920x1200, 1920x1440, 2560x1440 without calendar: 1024x1024, 1280x800, 1280x960, 1280x1024, 1400x1050, 1440x900, 1600x1200, 1680x1050, 1680x1200, 1920x1080, 1920x1200, 1920x1440, 2560x1440 Candlelight November “In Lithuania, the first days of November belong to remembrance: families light candles on the graves of their loved ones and cemeteries across the country glow softly in the evening mist. I wanted a calm, warm wallpaper that turns your desktop into a small candle-lit corner, a quiet pause before the busy end of the year.” — Designed by Justas Arbatauskis from Lithuania. preview with calendar: 320x480, 640x480, 800x480, 800x600, 1024x768, 1024x1024, 1152x864, 1280x720, 1280x800, 1280x960, 1280x1024, 1366x768, 1400x1050, 1440x900, 1600x1200, 1680x1050, 1680x1200, 1920x1080, 1920x1200, 1920x1440, 2560x1440 without calendar: 320x480, 640x480, 800x480, 800x600, 1024x768, 1024x1024, 1152x864, 1280x720, 1280x800, 1280x960, 1280x1024, 1366x768, 1400x1050, 1440x900, 1600x1200, 1680x1050, 1680x1200, 1920x1080, 1920x1200, 1920x1440, 2560x1440 Colorful Autumn “Autumn can be dreary, especially in November, when rain starts pouring every day. We wanted to summon better days, so that’s how this colourful November calendar was created. Open your umbrella and let’s roll!” — Designed by PopArt Studio from Serbia. preview without calendar: 320x480, 640x480, 800x480, 800x600, 1024x768, 1024x1024, 1152x864, 1280x720, 1280x800, 1280x960, 1280x1024, 1366x768, 1400x1050, 1440x900, 1600x1200, 1680x1050, 1680x1200, 1920x1080, 1920x1200, 1920x1440, 2560x1440 Falling Into November “Celebrate the heart of fall with cozy colors, crisp leaves, and the gentle warmth that only November brings.” — Designed by Libra Fire from Serbia. preview without calendar: 320x480, 640x480, 800x480, 800x600, 1024x768, 1024x1024, 1152x864, 1280x720, 1280x800, 1280x960, 1280x1024, 1400x1050, 1440x900, 1600x1200, 1680x1050, 1920x1080, 1920x1200, 1920x1440, 2560x1440 Winter Is Here Designed by Ricardo Gimenes from Spain. preview without calendar: 640x480, 800x480, 800x600, 1024x768, 1024x1024, 1152x864, 1280x720, 1280x800, 1280x960, 1280x1024, 1366x768, 1400x1050, 1440x900, 1600x1200, 1680x1050, 1680x1200, 1920x1080, 1920x1200, 1920x1440, 2560x1440, 3840x2160 Anbani “Anbani means alphabet in Georgian. The letters that grow on that tree are the Georgian alphabet. It’s very unique!” — Designed by Vlad Gerasimov from Georgia. preview without calendar: 800x480, 800x600, 1024x600, 1024x768, 1152x864, 1280x720, 1280x800, 1280x960, 1280x1024, 1366x768, 1400x1050, 1440x900, 1440x960, 1600x900, 1600x1200, 1680x1050, 1680x1200, 1920x1080, 1920x1200, 1920x1440, 2560x1440, 2560x1600, 2880x1800, 3072x1920, 3840x2160, 5120x2880 Outer Space “We were inspired by nature around us and the universe above us, so we created an out-of-this-world calendar. Now, let us all stop for a second and contemplate on preserving our forests, let us send birds of passage off to warmer places, and let us think to ourselves — if not on Earth, could we find a home somewhere else in outer space?” — Designed by PopArt Studio from Serbia. preview without calendar: 320x480, 640x480, 800x480, 800x600, 1024x768, 1024x1024, 1152x864, 1280x720, 1280x800, 1280x960, 1280x1024, 1366x768, 1400x1050, 1440x900, 1600x1200, 1680x1050, 1680x1200, 1920x1080, 1920x1200, 1920x1440, 2560x1440 Time To Give Thanks Designed by Glynnis Owen from Australia. preview without calendar: 320x480, 640x480, 800x600, 1024x768, 1152x864, 1280x720, 1280x960, 1600x1200, 1920x1080, 1920x1440, 2560x1440 A Gentleman’s November Designed by Cedric Bloem from Belgium. preview without calendar: 320x480, 640x480, 800x480, 800x600, 1024x768, 1024x1024, 1152x864, 1280x720, 1280x800, 1280x960, 1280x1024, 1400x1050, 1440x900, 1600x1200, 1680x1050, 1680x1200, 1920x1080, 1920x1200, 1920x1440, 2560x1440 Bug Designed by Ricardo Gimenes from Spain. preview without calendar: 640x480, 800x480, 800x600, 1024x768, 1024x1024, 1152x864, 1280x720, 1280x800, 1280x960, 1280x1024, 1366x768, 1400x1050, 1440x900, 1600x1200, 1680x1050, 1680x1200, 1920x1080, 1920x1200, 1920x1440, 2560x1440, 3840x2160 International Civil Aviation Day “On December 7, we mark International Civil Aviation Day, celebrating those who prove day by day that the sky really is the limit. As the engine of global connectivity, civil aviation is now, more than ever, a symbol of social and economic progress and a vehicle of international understanding. This monthly calendar is our sign of gratitude to those who dedicate their lives to enabling everyone to reach their dreams.” — Designed by PopArt Studio from Serbia. preview without calendar: 320x480, 640x480, 800x480, 800x600, 1024x768, 1024x1024, 1152x864, 1280x720, 1280x800, 1280x960, 1280x1024, 1400x1050, 1440x900, 1600x1200, 1680x1050, 1680x1200, 1920x1080, 1920x1200, 1920x1440, 2560x1440 The Kind Soul “Kindness drives humanity. Be kind. Be humble. Be humane. Be the best of yourself!” — Designed by Color Mean Creative Studio from Dubai. preview without calendar: 320x480, 640x480, 800x480, 800x600, 1024x768, 1024x1024, 1152x864, 1280x720, 1280x800, 1280x960, 1280x1024, 1366x768, 1400x1050, 1440x900, 1600x1200, 1680x1050, 1680x1200, 1920x1080, 1920x1200, 1920x1440, 2560x1440 November Nights On Mountains “Those chill November nights when you see mountain tops covered with the first snow sparkling in the moonlight.” — Designed by Jovana Djokic from Serbia. preview without calendar: 320x480, 640x480, 800x480, 800x600, 1024x768, 1024x1024, 1152x864, 1280x720, 1280x800, 1280x1024, 1366x768, 1400x1050, 1440x900, 1600x1200, 1680x1050, 1680x1200, 1920x1080, 1920x1200, 1920x1440, 2560x1440 Red Leaves Designed by Evacomics from Singapore. preview without calendar: 320x480, 1024x768, 1280x800, 1280x1024, 1440x900, 1920x1080, 2560x1440 Me And The Key Three Designed by Bart Bonte from Belgium. preview without calendar: 640x480, 800x480, 800x600, 1024x768, 1024x1024, 1152x864, 1280x720, 1280x800, 1280x960, 1280x1024, 1400x1050, 1440x900, 1600x1200, 1680x1050, 1680x1200, 1920x1080, 1920x1200, 1920x1440, 2560x1440 Moonlight Bats “I designed some Halloween characters and then this idea came to my mind — a bat family hanging around in the moonlight. A cute and scary mood is just perfect for autumn.” — Designed by Carmen Eisendle from Germany. preview without calendar: 640x480, 800x600, 1024x768, 1280x800, 1280x960, 1440x900, 1600x1200, 1680x1050, 1680x1260, 1920x1200, 1920x1440, 2560x1440, 2560x1600 Mushroom Season “It is autumn! It is raining and thus… it is mushroom season! It is the perfect moment to go to the forest and get the best mushrooms to do the best recipe.” — Designed by Verónica Valenzuela from Spain. preview without calendar: 800x480, 1024x768, 1152x864, 1280x800, 1280x960, 1440x900, 1680x1200, 1920x1080, 2560x1440 Go To Japan “November is the perfect month to go to Japan. Autumn is beautiful with its brown colors. Let’s enjoy it!” — Designed by Veronica Valenzuela from Spain. preview without calendar: 640x480, 800x480, 1024x768, 1280x720, 1280x800, 1440x900, 1600x1200, 1920x1080, 1920x1440, 2560x1440 Tempestuous November “By the end of autumn, ferocious Poseidon will part from tinted clouds and timid breeze. After this uneven clash, the sky once more becomes pellucid just in time for imminent luminous snow.” — Designed by Ana Masnikosa from Belgrade, Serbia. preview without calendar: 320x480, 640x480, 800x480, 800x600, 1024x768, 1024x1024, 1152x864, 1280x720, 1280x800, 1280x960, 1280x1024, 1400x1050, 1440x900, 1600x1200, 1680x1050, 1680x1200, 1920x1080, 1920x1200, 1920x1440, 2560x1440 Crown Me Designed by Ricardo Gimenes from Spain. preview without calendar: 640x480, 800x480, 800x600, 1024x768, 1024x1024, 1152x864, 1280x720, 1280x800, 1280x960, 1280x1024, 1366x768, 1400x1050, 1440x900, 1600x1200, 1680x1050, 1680x1200, 1920x1080, 1920x1200, 1920x1440, 2560x1440, 3840x2160 Deer Fall, I Love You Designed by Maria Porter from the United States. preview without calendar: 320x480, 800x600, 1280x800, 1280x1024, 1440x900, 1680x1050, 2560x1440 Don’t Let Gray Win “Let’s take extra care of colors during the autumn months. November might be gray and rainy. Outside. Don’t let it inside. Take a good book, prepare a hot ginger tea, and cover your knees with a bright woolen plaid.” - Designed by Tartanify from France. preview without calendar: 1280x720, 1440x900, 1440x1024, 2560x1440, 2880x1800, 2880x2048 Little Mademoiselle “Black-and-white drawing of a little girl.” Designed by Jelena Tšekulajeva from Estonia. preview without calendar: 320x480, 1024x1024, 1280x800, 1440x900, 1680x1050 Welcome Home Dear Winter “The smell of winter is lingering in the air. The time to be home! Winter reminds us of good food, of the warmth, the touch of a friendly hand, and a talk beside the fire. Keep calm and let us welcome winter.” — Designed by Acodez IT Solutions from India. preview without calendar: 640x480, 800x480, 800x600, 1024x768, 1024x1024, 1152x864, 1280x720, 1280x960, 1280x1024, 1366x768, 1400x1050, 1440x900, 1600x1200, 1680x1050, 1680x1200, 1920x1080, 1920x1200, 1920x1440, 2560x1440 First Icicles Of The Coming Winter Designed by Aleksandra Sivoronova from Latvia. preview without calendar: 1280x800, 1440x900, 1680x1050, 1920x1080, 2560x1440 Autumn Choir Designed by Hatchers from Ukraine / China. preview without calendar: 1024x768, 1152x864, 1280x720, 1280x800, 1280x960, 1400x1050, 1440x900, 1600x1200, 1680x1050, 1680x1200, 1920x1080, 1920x1200, 1920x1440, 2560x1440 Get Featured Next Month Feeling inspired? We’ll publish the December wallpapers on November 30, so if you’d like to be part of the collection, please don’t hesitate to submit your design. We are already looking forward to it! #november #gray #designed #halloween #lost #bat #addamsfamily #cousinitt #rss #feeds #linksharing #qwibbit
WebCraft's avatar
WebCraft 1 month ago
Embracing Playful Imperfection With The CSS `random()` Function In design, we love spending hours obsessing over consistency, grids, and alignment. But when I heard that the native CSS random() function landed in Safari and is rolling out in Chrome 156, I started wondering: where does randomness actually make sense on the web? Is it something we want in our design system? To find out, I did what I always do in doubt: I built a bunch of playful CodePen demos exploring organic typography, bouncing letters, splayed cards, and a punk fanzine. As someone who loves building design systems and tinkering with CSS architecture, a big part of my day job revolves around control. We set up spacing scales, lock down typography, set up color tokens, and make sure everything aligns on a grid. Consistency is usually our bread and butter as design engineers and a proud badge of skill when creating design systems. If a card suddenly jumps 20 pixels to the left on a refresh, it’s not creative expression; it’s a bug that the project manager will log. So when I first heard that the native random() function from the CSS Values and Units Level 5 spec was shipped in Safari, and is currently rolling out in Chrome 156 (with positive signals from Mozilla on Firefox as well), my first reaction was: that’s pretty cool! And my second reaction was: wait... where would I actually use this without making a mess? How can I convince designers that random might be a good idea for a design system? Because let’s be honest: why on earth would we want randomness in our stylesheets when we’ve spent the last decade trying to make the web more predictable? Even when using flexbox or fluid typography, we’re still trying to make things as aligned and uniform as possible. The Charm Of Things Not Being 100% Straight If you step away from the browser for a second and look at physical things around you, nothing is ever truly uniform. Take an old letterpress print: the ink bleeds slightly into the paper grain, some letters have a microscopic tilt, and the baseline isn’t always that straight. Or think about a deck of Polaroid photos dropped on a coffee table; those photos aren’t perfect, probably not straight either. Or what about lights flickering in a street at night? That little bit of analog messiness is what makes things feel alive, organic, and human. On the web, we’ve gotten so good at pixel perfection that sometimes our interfaces end up feeling a bit sterile. We notice this even more now with rapidly created designs by an unguided LLM; we usually end up with the same sort of design we had 10 years ago. Everything is squared off, aligned, neat. It works, but frankly, it does get a bit boring. Randomness in CSS doesn’t have to mean throwing your design system out the window. It’s about little imperfections and playfulness. Maybe let’s even call it fun. To see what this actually looks like in practice, I spent a few hours tinkering in CodePen. The demos might feel a bit isolated, but I’m sure that many designers could make the best of this controlled chaos. But before we look at those demos, let’s take a look at the syntax. How The CSS random() Function Works The random() function is specified in CSS Values and Units Module Level 5. It generates a pseudo-random value inside your CSS without needing JavaScript or a build-time Sass loop. The formal specification looks like this: random( <random-caching-key>?, <min>, <max> [, by <step>]? ) In practice, and across current browser implementations, you can just write comma-separated arguments: /* Random angle between -3deg and 3deg */ rotate: random(-3deg, 3deg); /* Random width between 20px and 80px in steps of 10px */ inline-size: random(20px, 80px, 10px); /* Random animation duration */ animation-duration: random(1.5s, 3s, 0.2s); Matching Units It won’t be a shocker for most people, but I thought I should at least mention that your minimum and maximum bounds must share the exact same unit type. The CSS parser needs to know what dimension it’s dealing with. You can use lengths, angles, time, percentages, or plain unitless numbers: /* Good: both are angles */ rotate: random(-4deg, 4deg); /* Good: both are unitless numbers */ opacity: random(0.3, 1); /* Nope! You cannot mix units */ inline-size: random(2rem, 100px); /* Invalid */ If you ever need to combine units, you’ll have to reach for calc() inside the arguments so each side resolves properly. Stepping And Rounding The optional third argument is the step size. If you don’t add it, the browser picks from a continuous range. But if you provide a step, it rounds the random value to discrete increments: /* Only produces 0px, 15px, 30px, 45px, or 60px */ top: random(0px, 60px, 15px); This can be helpful in cases where you want things to jump around a bit, but you still want them to land on your pre-defined grid. Caching Keys: Keeping Things In Sync Normally, every time random() is evaluated on a property, it creates an independent random value. But there could be an example where you create a box that sets inline-size and block-size at random, but at the same time you need them to match so the element stays a perfect square. That’s where the caching key comes in: .card-thumbnail { /* Both properties share the key --square-size */ inline-size: random(--square-size, 60px, 120px); block-size: random(--square-size, 60px, 120px); } Because both declarations reference --square-size on that element, the browser engine shares the same computed value between them. To see this in action, I created a little example. In the top row, the tiles have uncached dimensions, which distorts each tile into an unpredictable, mismatched rectangle. In the bottom row, both inline-size and block-size share --square-size, guaranteeing that each tile remains a pristine 1:1 square. Refresh the CodePen a couple of times and notice the bottom cards keeping the same randomness: See the Pen Uncached vs cached random() [forked] by @utilitybend. /* Uncached: width and height resolve independently, creating random rectangles */ .tile-uncached { inline-size: random(4.2rem, 8.5rem); block-size: random(4.2rem, 8.5rem); rotate: random(-3.5deg, 3.5deg); } /* Cached: shared key guarantees a clean 1:1 square */ .tile-cached { inline-size: random(--square-size, 4.2rem, 8.5rem); block-size: random(--square-size, 4.2rem, 8.5rem); rotate: random(--tilt, -3.5deg, 3.5deg); } Browser Support And Progressive Enhancement Where can you test this today? WebKit / Safari: Safari was the first to land support. Chrome / Edge: Shipped and rolling out right now with Chrome 156. Firefox: Positive signals on the standards track, so hopefully won’t be too far behind. Because we’re still in the rollout phase, you’ll want to wrap your experiments in @supports: /* Baseline for all browsers */ .badge { rotate: 0deg; } /* Enhanced for browsers with random() */ @supports (rotate: random(-2deg, 2deg)) { .badge { rotate: random(-2.5deg, 2.5deg); } } The Future random-item Function There’s also another function in the spec called random-item(). While random() handles numerical ranges, random-item() lets you pick from a list of predefined tokens or keywords: /* Picking a random color from your palette */ background-color: random-item(--seed, oklch(75% 0.18 150), oklch(65% 0.22 350), oklch(85% 0.16 85)); This can be handy to randomise from a set of design tokens. This one does not have any browser support at the moment, but it certainly is something to look forward to. And now for the practical part. Demo 1: Let’s just randomize letters When I started playing with the feature, I was also doing some typography tricks with animations. So that’s where my first thought went: Typography! What if we just add a tiny bit of imperfection to a word? Think of vintage book covers. The letters aren’t misaligned by miles, but they have small imperfections. See the Pen Imperfection random() [forked] by @utilitybend. Here is the CSS powering the letters: @layer demo { .char { display: inline-block; /* A tiny tilt */ rotate: random(-2.8deg, 2.8deg); /* A micro nudge on X and Y */ translate: random(-1.5px, 1.5px) random(-2.8px, 2.8px); /* Very subtle ink variance */ opacity: random(0.8, 1, 0.02); transition-property: rotate, translate, opacity; transition-duration: 0.3s; transition-timing-function: cubic-bezier(0.34, 1.56, 0.64, 1); } /* Snap straight on hover */ .word:hover .char { rotate: 0deg; translate: 0 0; opacity: 1; } } I also added a little hover effect. While you’re reading, the word feels playful. But the second you hover over it, every character snaps back. Please Don’t Break The Screen Reader One quick accessibility warning here: If you break a word into separate <span> elements so you can style each letter, screen readers will often read it out as individual characters: “i - m - p - e - r - f - e - c - t - i - o - n”, or pause awkwardly between each one. That’s a terrible user experience. Always hide the visual spans from assistive tech and provide the full word: <h1 class="word" aria-label="Imperfection"> <span class="word-inner" aria-hidden="true"> <span class="char">i</span> <span class="char">m</span> <span class="char">p</span> <span class="char">e</span> <span class="char">r</span> <span class="char">f</span> <span class="char">e</span> <span class="char">c</span> <span class="char">t</span> <span class="char">i</span> <span class="char">o</span> <span class="char">n</span> </span> </h1> Screen reader users get the clean text, and sighted users get the fun visual quirks. Demo 2: Animating The Letters: Pure Procedural Bounce Once I had those letters sitting there with their little tilts, I couldn’t resist: what if we animated it? I started tinkering with a bounce keyframe. I was just goofing around, but the end result gave me a little smile. If you animate every letter with the exact same timing, you get that clean sine wave we’ve all seen before. But if every letter gets its own jump height, its own duration, and its own landing squash, suddenly the word looks like a bunch of little characters jumping around on a trampoline. See the Pen Bouncy imperfection with CSS random() [forked] by @utilitybend. Here is how the bounce parameters are wired up: @layer demo { .char { display: inline-block; transform-origin: center bottom; /* Procedural bounce variables */ --jump: random(-35px, -55px, 2px); --tilt: random(-8deg, 8deg, 0.5deg); --dur: random(1s, 1.2s, 0.1s); --delay: random(-3s, 0s, 0.1s); --rebound-squash: random(1.08, 1.18, 0.02); animation: letter-bounce var(--dur) linear var(--delay) infinite; } @keyframes letter-bounce { /* apex */ 0% { translate: 0 var(--jump); rotate: var(--tilt); scale: 1 1; animation-timing-function: cubic-bezier(0.65, 0.05, 0.85, 0.35); } /* touchdown */ 44% { translate: 0 0; rotate: calc(var(--tilt) * 0.2); scale: 0.96 1.05; animation-timing-function: ease-out; } /* squash */ 52% { translate: 0 0; rotate: 0deg; scale: var(--rebound-squash) calc(2 - var(--rebound-squash)); animation-timing-function: cubic-bezier(0.2, 0.8, 0.2, 1); } /* back up */ 62% { translate: 0 calc(var(--jump) * 0.2); rotate: calc(var(--tilt) * -0.4); scale: 0.98 1.03; animation-timing-function: cubic-bezier(0.15, 0.85, 0.35, 1); } 100% { translate: 0 var(--jump); rotate: var(--tilt); scale: 1 1; } } } Notice the negative animation delay (--delay: random(-3s, 0s)). If you set a positive delay, the letters sit frozen on page load, waiting for their timers to expire before jumping. By using a negative delay, the browser pretends the animation has already been running for a few seconds. The moment the page loads, every letter is already bouncing at its own rhythm. Demo 3: Tilting Cards And Dynamic Shadows We’ve built cards. Lots of cards. So many cards... Portfolio grids, blog summaries, feature lists. And most of the time, they sit in three or four neat, boring columns. For dashboards, that’s exactly what you want. But if you’re building a lifestyle portfolio, a children’s website, or a collection of vacation photos, we can be a bit more playful. In the following example, I did just that: See the Pen Random card tilt [forked] by @utilitybend. Here’s how I put that together: @layer demo { .card { /* A gentle random tilt and vertical shift */ --tilt: random(-3.5deg, 3.5deg); --shift-y: random(-6px, 6px); rotate: var(--tilt); translate: 0 var(--shift-y); /* Shadow follows the tilt angle! */ box-shadow: calc(var(--tilt) * 1.5) calc(10px + abs(var(--tilt) * 1px)) 28px oklch(20% 0.02 260 / 0.07); transition: rotate 0.4s cubic-bezier(0.2, 0.8, 0.2, 1), translate 0.4s cubic-bezier(0.2, 0.8, 0.2, 1), box-shadow 0.4s ease; /* Straighten up on hover or keyboard focus */ &:hover, &:has(.button:focus-visible) { rotate: 0deg; translate: 0 -10px; z-index: 10; box-shadow: 0 20px 44px oklch(20% 0.02 260 / 0.12), 0 2px 6px oklch(20% 0.02 260 / 0.04); } } } In the example, playing around with the shadow was a fun experiment. I will probably try more effects with that in the future. Demo 4: The Splayed Deck With sibling-index and scroll Here is where modern CSS features start getting really interesting. In the previous demo with tilting cards, we used pure randomness. But what if you have a stack of cards that needs to fan out across the screen as you scroll? In this example, I decided to use math for the structure and randomness for the human imperfection. See the Pen Scroll drivin animations with random() tilted cards [forked] by @utilitybend. Here is the setup: @layer demo { .deck-card { position: absolute; /* Mathematical fan base via sibling-index() (centered around middle card) */ --elevation: sibling-index(); --base-rot: calc((sibling-index() - (sibling-count() + 1) / 2) * 12deg); --base-x: calc((sibling-index() - (sibling-count() + 1) / 2) * 60px); --jitter-rot: random(-3.5deg, 3.5deg); --jitter-y: random(-12px, 12px); --jitter-x: random(-8px, 8px); transform-origin: center 130%; /* SDA */ animation: splay-fan linear both; animation-timeline: scroll(root); animation-range: 0% 80%; transition: scale 0.3s cubic-bezier(0.2, 0.8, 0.2, 1); &:hover { scale: 1.05; /* Hovered item on top */ z-index: calc(sibling-count() + 1); } } @keyframes splay-fan { from { rotate: 0deg; translate: 0 0; box-shadow: 0 1px 3px oklch(20% 0.02 260 / 0.1), 0 2px 8px oklch(20% 0.02 260 / 0.07); } to { rotate: calc(var(--base-rot) + var(--jitter-rot)); translate: calc(var(--base-x) + var(--jitter-x)) var(--jitter-y); /* Splayed: 1. Sharp inter-card contact edge shadow 2. Elevated atmospheric shadow scaled realistically by sibling-index() */ box-shadow: 0 calc(1px + var(--elevation) * 0.6px) 4px oklch(20% 0.02 260 / 0.1), calc(var(--base-x) * 0.15) calc(10px + var(--elevation) * 5px) calc(18px + var(--elevation) * 7px) oklch(20% 0.02 260 / 0.13); } } } Look at how cleanly this works: sibling-index() calculates the mathematical fan so cards spread out evenly around the center card, and scales --elevation so cards higher in the stack cast wider shadows. calc((sibling-index() - (sibling-count() + 1) / 2) * 12deg); makes sure the amount of cards doesn’t matter; they each will rotate the same 12deg amount. random() adds the slight wobble you'd get if a person dealt the cards by hand. animation-timeline: scroll(root) ties the entire fan and shadow transition to the scrollbar. Demo 5: Random Velocity If you’ve ever looked at brutalist or high-end fashion websites, you’ve probably seen horizontal marquee text drifting across the screen as you scroll down the page. Usually, you see developers creating classes like .drift-slow, .drift-fast, .drift-reverse, or using a hefty JavaScript scroll listener to compute transforms. With random() and a tiny bit of math, we can get procedural drift speeds in just a few lines: See the Pen Random() velocity scroll animation [forked] by @utilitybend. Here is the CSS: @layer demo { .drift-line { white-space: nowrap; /* Alternate direction between rows using math parity */ --direction: calc(pow(-1, sibling-index())); /* Velocity distance */ --travel: random(15%, 44%); /* Tied to page scroll */ animation: tectonic-glide linear both; animation-timeline: scroll(root); animation-range: entry 0% cover 100%; } @keyframes tectonic-glide { from { translate: calc(var(--direction) * -1 * var(--travel)) 0; } to { translate: calc(var(--direction) * var(--travel)) 0; } } } calc(pow(-1, sibling-index())) give image #css #function #playful #cssvalues #things #chrome #safari #straight #randomness #even #rss #feeds #linksharing #qwibbit
WebCraft's avatar
WebCraft 1 month ago
Is Your Organization Messing Up AI Adoption? The way I see most organizations roll out AI feels more like a farce than a strategy. If it were turned into a movie, reviewers would say it was unbelievable. Nobody could be that stupid. Yet here we are. And what makes it all the more frustrating is that we have been here before. Back in 2014, I wrote a book for Smashing Magazine called Digital Adaptation, looking at the mistakes being made in how organizations were approaching digital transformation and what they should be doing instead. The similarities between then and now are striking. So in this post, I want to look back at Digital Adaptation and see how the lessons in that book apply to the AI era and what we can learn from the past to help us navigate the challenges of AI today. The biggest mistake, both then and now, is approaching each as a technological challenge. It’s About People, Not Technology Sure, both digital transformation and AI are technological advances, and yes, some level of technological implementation is required. But that is the tip of a very large iceberg. Back in the midst of the digital transformation era, IT departments were rolling out CMSs, CRM systems, intranets, and so on. Meanwhile, on the customer-facing side, organizations were rolling out websites, apps, and personalization. But they were putting almost no emphasis on how people were going to use these systems. Internal systems were hard to use, and customers either didn’t care what was being built or wanted something else entirely. The same is happening with AI. Senior management are buying into the hype, and IT teams are rolling out Copilot Studio licenses company-wide and considering the job done. Sure, there is a bit of organization-wide generic training, but that’s about it. Just like before, staff are left wondering what to do with these new systems and feeling under pressure to use them and deliver results. Organizations need to recognize that AI is a cultural shift as much as a technology, and that shift has enormous implications for their staff. After all, this time around, it is even worse, because this time, staff fear for their jobs. They have read the same headlines that you have, and no amount of promises from senior management is going to make them feel any better. Why Would Staff Want To Adopt AI? I mean, think about it from a staff member’s point of view. AI offers them very little personally, even setting aside the fact that management may be intending to use it to replace them. The main reason senior management are excited about AI is that it provides additional productivity. People can do more in less time. But that does not benefit staff. They are still required to work 9 to 5, but now they are expected to do more in the same time. They don’t get any time back, and they don’t get paid more, so why would they embrace AI? So before asking staff to embrace AI, organizations need to ask themselves how they intend to motivate them to do so. One strategy is to help staff identify the parts of their job they hate and how AI can help them do those tasks more quickly and less painfully. People tend to be a lot more receptive to change when it is presented as an opportunity to improve their working lives. But, that should just be the beginning. Organizations may need to consider providing incentives for staff to adopt AI in terms of career progression, compensation, or shorter working hours. Staff Need Time And Support To Adopt AI Also, adopting AI is not a simple task. It involves challenging every working practice they have built up over (in some cases) decades. All of that procedural knowledge has to be rebuilt. That is a lot to ask of anybody in even the best of circumstances, and most employees do not find themselves in the best of circumstances. Most are overworked and struggling to stay on top of their to-do lists. They don’t have time to sit down, learn a new tool, and figure out how it fits into their workflow. That doesn’t just take time. It also takes a lot of consideration and experimentation. It is not enough to just send a member of staff on a training course and expect them to be able to use AI to its full potential. At a minimum, staff need training specific to their roles, such as the AI training I provide to UX teams. But organizations should be going even further. They need to develop sophisticated training programs that help staff from different departments understand how to use AI in their specific roles. They need ongoing support and the time to experiment with AI to find the best ways to use it. But formal training will only take you so far. In my experience, the most effective support comes from colleagues, which is why I would start with the enthusiasts rather than the resisters. Every organization has a handful of people who are already experimenting with AI, often without anybody asking them to. Bring those people together, give them the time and space to share what is working for them, and let their enthusiasm spread to everyone else. I saw this work during the digital transformation era too. In Digital Adaptation, I described an internal conference where staff showed their colleagues what they had built, and it did more for adoption than any memo from the top ever could. People are far more likely to try something when they see a colleague in a similar role using it successfully than when they are told to by senior management. Rather than trying to win over the most resistant staff first, organizations should find the people already experimenting with AI, give them time to share what they have learned, and let social proof do the heavy lifting. Unfortunately, experimentation comes with a big downside… mistakes will be made. It Needs To Be Safe To Fail Many organizations have, to be frank, a culture of fear where mistakes are seen as a sign of incompetence. However, by its very nature, learning a new tool like AI will involve making mistakes, and this can be a massive barrier to adoption. I saw this during the era of digital transformation. Senior management would demand digital transformation and were confused when it didn’t happen. What they didn’t realize was that they were sending mixed messages to staff. Sure, they were asking for digital transformation, but they were still demanding that the same key performance indicators (KPIs) be met, and they still pointed out any mistakes in their annual reviews. There was no space to fail, as the pressure to deliver was relentless. This time around, it seems to be even worse. I hear horror stories of staff being reprimanded for using too many tokens just weeks after being told to adopt AI. Or staff being lectured so much about what they should or should not do with AI that they are afraid to try anything. It is safer to just do what they have always done. If management want staff to adopt AI, then they need to make staff feel safe to experiment. They need to adjust KPIs, change how staff are reviewed, and relax some of the governance while staff are learning. Handle Governance With Care Look, I get it. AI cannot be rolled out without some governance in place, but again, this is an area that organizations have typically handled poorly. In the midst of digital transformation, governance would either be non-existent, or it would be so strict that it would stifle innovation, and unfortunately, I see the same pattern emerging with AI adoption. Staff need some governance to help them know where they stand. It helps them understand what is expected of them and what they can and cannot do. But too often organizations have been so strict that it is easier not to do anything at all. Pages of instructions about what people should and should not share with AI create that sense of fear that I mentioned earlier. Organizations need a short set of principles that would fit on a handful of posters, similar to gov.uk’s design principles. Beyond that, they need to demonstrate a degree of trust in their staff to use common sense. Of course, mistakes will get made, but that is the cost of change, and so organizations need to accept that and do what they can to mitigate that in how they roll out the technology. Adaptive Technological Rollout That said, organizations will need to be careful in how they roll out AI from an IT perspective. Once again, it is easy to lock everything down and stifle the adoption of AI. Again, this is something I highlighted back in 2014 with digital transformation. Overstretched IT teams would pick a set of technologies and roll them out organization-wide, often with little or no consultation with the individuals who would be using them. Anything outside of that set of technologies had to go through a complex approval process, normally involving a steering committee. The result was a glacial pace of change that was one of the major contributing factors to the failure rate of digital transformation projects. Today we are seeing the same thing. IT teams are opting into a tool like Copilot and calling it a day, but that often falls massively short. Take, for example, a UX team I am working with at the moment. Management is pushing hard for AI adoption, and the team is excited about the potential of creating an AI-powered research repository and even AI personas. It sounds like a wonderful case study in AI adoption, with enthusiastic management, an excited team, and innovative ideas. Unfortunately, the reality is that nothing is happening because Copilot cannot deliver on the team’s vision, and so they are currently bogged down in bureaucracy as they try to persuade the AI steering group that they need to use a different toolset. Understandably, the team’s enthusiasm is waning. Why bother? And that team is one of the more patient ones. In many organizations, staff are not waiting for the steering group at all. Just as we saw shadow IT during the digital transformation era, with people signing up for Dropbox and Google Docs because the official tools could not do what they needed, we are now seeing shadow AI. When the in-house AI tool will not let people do their jobs, they open a personal ChatGPT or Claude account on their phone or home laptop and get on with it. That is far more dangerous than the problem the restrictions were meant to prevent. Company data ends up in tools the organization has no control over, with no oversight and no record of what has been shared. In trying to lock everything down, organizations end up pushing the risk somewhere they cannot see it. The instinctive reaction is to clamp down with stricter policies, blocked websites, and warnings about disciplinary action. But that rarely works, and it drives the behavior further underground. Shadow AI is a symptom, and a useful one, because it shows exactly where the official tools are falling short. Instead of trying to stamp out shadow AI, organizations should learn from it. Talk to staff about what they are using personal accounts for and what they feel they cannot do with the AI they have been given, then use that to shape what gets rolled out next. Look, I understand the cost of a messy, out-of-control tech stack. It is not ideal. However, in the early days of adoption, we may have to live with a bit of chaos while people explore the edges of what is possible and work out common use cases. Organizations need to allow staff to explore different uses of AI and even different AI apps to find what suits their specific needs in their specific roles. They can always start locking things down later as the real organizational needs become clearer. A Dangerous Time I admit all of this feels dangerous to some organizations. They want to control the AI adoption process centrally and make sure nothing goes wrong. I understand that. But change comes with a degree of risk, and the risk of moving too slowly is greater than the risk of moving too fast. However, a bigger danger still is when organizations see this as a technological challenge and overlook the human side of things. AI adoption is not simply about rolling out new technology. Just like digital transformation, it is about people, culture, and change management. The sooner organizations realize the scope of what they are dealing with, the better. #staff #back #smashingmagazine #senior #ai #rss #feeds #linksharing #qwibbit
WebCraft's avatar
WebCraft 1 month ago
When It Makes Sense To “Block” The Main Thread We’ve all heard of the sacred rule in modern web development, the rule never to be broken. The rule of “Never block the main thread.” You almost can’t miss it as a web developer; it’s in almost every performance guide, and to be fair, it is good advice. We all know the browser’s main thread is single-threaded, meaning it can only do one thing at a time. Plus, as we know, the main thread isn’t ours alone; we share it with the browser’s rendering engine, input handlers, and other critical tasks. As a result, the less time we hold onto the main thread, the more responsive an app feels. That leads us to share tasks with background workers as we’ve convinced ourselves there should be a hard line between the UI and any computation, and that line shouldn’t be crossed. And that is what a “recommended” architecture looks like. But I dare say that sometimes**, moving the data to a worker is slower than just letting the main thread do the work. I found this out a few months ago while building a Chrome extension with screenshotting features called Fastary. I kept finding a latency of about 2 to 3 seconds in all my testing, even after using an Offscreen Document (a background process in Chrome extensions) to handle the canvas operations. A screenshot task should feel instant without lag, after all. It is quite ironic that by reflex, we move work away from the main thread to avoid freezing the UI, but sometimes the act of moving that work (e.g., serializing, copying, and deserializing) can also freeze the UI. And sometimes the recommended approach of letting the background do the work can be slower than just doing the work on the main thread. Let’s talk about that. The Architecture Of Browser Context Isolation To put things in perspective, let’s understand why we isolate browser contexts and how they communicate with each other, with emphasis on the communication part. A browser is more than a single environment. Different environments are running at the same time, each having its own memory space, what it can access, and rules: The main thread is what we are most familiar with; this is where JavaScript logic runs, where the DOM lives, where styles get rendered, and where users interact. The Web Workers are separate threads that can also execute JavaScript without DOM access. We mostly use this for heavy data tasks. The Service Workers are network-related proxies in charge of intercepting network requests and can even run when the page is closed. And then there are Chrome extension contexts, where we have background service workers, content scripts, and Offscreen Documents (the relevant ones for this article). Each one of these is isolated from the others. A web worker or background script lives in a different memory space from the main thread. They cannot just reach and read each other’s variables or logic, and this is known as the “shared-nothing” architecture. How do these isolated environments communicate? They explicitly message each other back and forth using APIs, like postMessage(). The Structured Clone Algorithm postMessage() tells the browser to take a piece of data and deliver it to the context that requested it. But to do this, the browser relies on the Structured Clone Algorithm (SCA). You’re probably familiar with JSON.stringify(). SCA is similar, but much stronger and smarter. In its simplest form, SCA is a deep, recursive copy operation, i.e., cloning. It walks through the entire data structure it is given, clones every single value, serializes it into a transportable format, ships those bytes to the target contexts, and then reconstructs the original object on the receiving side. SCA is fast, or maybe fast-ish... For a small regular config object like {theme: "dark"}, it is imperceptible; you don’t even notice it. The story changes, however, when dealing with heavy data because the SCA is a synchronous blocking O(n) operation, i.e., the cost increases linearly with the size of your data. Let’s put that into perspective. A user clicks a button, and internally, an 8MB image payload is sent to a background worker for processing. When you call postMessage(), the main thread must immediately stop what it is doing to run this serialization and copying process. So, if the time it takes to pack, ship, unpack the data, and go back to the start is longer than the time to just process the data on the main thread, why not do that instead? What About Transferable Objects? I’m sure some of you are already thinking, “Why not just use Transferable objects?” And that is a valid point. Let’s talk about that. Developers who really pursue ultra-high-performance web apps usually use Transferable objects (e.g., ArrayBuffer, ImageBitmap, or MessagePort) to bypass the Structured Clone Algorithm. This is because when you transfer an object, you’re not making a copy (like SCM). Instead, the browser switches ownership of the data from one context to another. The browser performs a hand-off whereby the sending context loses access to the data instantly, and the receiving context takes full control. It is actually insanely fast. According to Chrome Developers’ benchmark, transferring a massive 32MB ArrayBuffer can take under 7ms, compared to about 300ms when cloning with SCM. That’s a 43x speed boost. But like all good things, there are downsides. To name a few: You lose it once you send it. If the UI still needs that data (like to show an image preview), you can’t access it anymore. Not all data is transferable. A plain JS object is not. A Blob is not. Even a Base64 string is not. API limitations. In the context of browser extensions, Chrome’s internal messaging (chrome.runtime.sendMessage) traditionally forces everything through JSON serialization. So, as far as my screenshot extension went, Transferable objects were not an option. Why We Isolate Contexts Anyway Why do we even bother isolating contexts at all? Why not just leave it all to the main thread? Offloading long-running CPU tasks to a background thread is absolutely the right thing to do. The browser needs to paint a new frame every 16.6ms to keep things fluid; that means any task that takes >50ms is generally considered “long”. Offloading to the background is absolutely the right thing to do. The issue, however, is that we’ve turned this “never block the main thread” into an absolute rule, without asking is this task expensive to process or expensive to move? I have come to realize now that the rule is less “never block the main thread” than “never block the main thread for too long.” When The Right Architecture Is The Wrong Architecture My goal with the Fastary extension was to make it feel like a native app, running as smoothly and instantly as you would expect a native app to. As you already know, I took the recommended approach to use the Offscreen Document to handle DOM work in the background. But to my surprise, that took a different turn. The Offscreen Document API is a clear winner. You create a hidden, undisplayed document that runs entirely in the background. It has a DOM and supports Canvas. For example, if I want to crop a screenshot, stitch multiple screenshots together, perform heavy image manipulation, or add a watermark, Offscreen Document was made for that. Turns out that was not the best approach. This was my architecture: The background Service Worker captures a screenshot with chrome.tabs.captureVisibleTab(), which returns a Base64-encoded data URL string. The background Service Worker uses chrome.runtime.sendMessage() to ship this image payload to the Offscreen Document. The Offscreen Document receives the image, loads it into an <img> element, then draws it onto a canvas before it applies the user’s crop coordinates, encodes the result, and sends the processed image back to the background worker. But when I tested it, the screenshot didn’t feel instant. As I said earlier, there was a consistent 2–3 second lag. I figured out that when captureVisibleTab() takes a screenshot, it returns a Base64 URL string, and on a standard 1080p screen, that string could be approximately 1MB or more, depending on how detailed the image is. It gets even more interesting on modern Retina displays (e.g., MacBooks) as they tend to automatically double the image’s size by default. Keep in mind that since the image payload could be doubled and extension messaging relies on JSON serialization (as of this writing), we potentially deal with massive synchronous communication that costs an entire round trip. The image string data is JSON-serialized at least twice: once when going into the Offscreen Document and once coming back out with the processed results to the background worker. The actual image processing (cropping) done inside the Offscreen Document was fast, no doubt, but I can’t say the same about the transfer overhead. The Retina High-DPI Problem As if the latency itself wasn’t enough, I noticed a rather subtle bug — which, now that I think of it, was more of my ignorance. After a screenshot was taken, the crop result was completely off in a way that either weirdly scaled the image or resulted in incorrect coordinates. It turns out that when a user selects a region to crop, the content script gets the box coordinates using getBoundingClientRect(), which is measured in CSS pixels; this is what the DOM uses. But when the screenshot is captured natively in Chrome, the browser doesn’t crop it automatically; it instead uses the physical hardware pixels to get the full screen capture. And the browser uses devicePixelRatio (DPR) to know how many physical pixels should represent one CSS pixel. Basically, if a user on a Retinal display (DPR = 2) highlights an area of 400x300 CSS pixels, the actual captured image area is 800x600 physical pixels. Note: One CSS pixel is equal to 1 physical pixel (DPR of 1) on a standard monitor. On a Mac Retina display or a modern 4K monitor, however, the DPR is usually 2 or 3. For an accurate crop, I needed to apply these two different measurement systems with the right DPR, i.e., scale the crop coordinates by the DPR. But remember, Offscreen Documents have no physical display. Processing any image would have a default DPR equal to 1. To fix this, I would have to capture the exact devicePixelRatio from the active tab, serialize it, pass it alongside the image payload, and manually do the scaling math inside the Offscreen Document. The complexity starts to compound. What if I broke the golden rule and did the work on the main thread instead? Working On The Main Thread Some developers will argue that UI tasks are the only things that should run on the main thread, but I don’t fully agree with that. Personally, I believe that user explicitly-invoked actions that need immediate results can sometimes get a solid pass to run on the main thread, provided the work is incredibly fast (e.g., 1s). That’s what I did: scrap out the Offscreen Document and reengineer the logic. Instead of: Background → [serialize] → Offscreen Document → [serialize] → Background → Content Script …I decided to run the whole image processing in the active tab: The background Service Worker captures the screen and gets the Base64 string (same as before). The background sends the payload directly to the content script in the active tab using chrome.scripting.executeScript(). The content script (running on the main thread) receives the payload, draws it to a canvas, performs the crop using the correct DPR value, and copies the result to the clipboard. // Background Script const screenshotUrl = await chrome.tabs.captureVisibleTab(undefined, { format: "png" }); // Inject the processing function into the active tab as a content script await chrome.scripting.executeScript({ target: { tabId: activeTab.id }, func: processAndCopyImage, args: [{ base64Image: screenshotUrl, cropData: userSelection }] }); This approach completely clears out multiple context hops and round trips that JSON serialization requires. The only cross-context transfer involves sending the data URL from the background to the content script. The Retina DPI issue essentially solved itself, as the content script runs directly inside the real, active browser tab because it knows the monitor’s real devicePixelRatio. But there’s an elephant in the room that you may have noticed. Sure, the image is now processed on the main thread, and the background manipulates the canvas in the active tab. I could technically be blocking the main thread. That’s where I amended the “no blocking the main thread” rule to “no blocking the main thread for too long.” In this specific case, at least, blocking the main thread for a task the user requests for approximately one second is justifiable. It works conversely as well: maybe don’t isolate processes if the data transfer cost is greater than the processing cost. Conclusion: When To Isolate And When Not To I’ve boiled it down to a mental model that depends on whether the task is: 1. Compute-Heavy Tasks (CPU-Bound) These are tasks where the primary cost is computation and not the size of the data itself. These are tasks where most of the time is spent on doing calculations or heavy transformations, e.g., image compression, audio profiling, physics simulation, etc. The transfer cost for these tasks is minuscule compared to the actual work. 2. Data-Heavy Tasks (Data-Bound) These tasks are the exact opposite. These tasks are only expensive because of the size. The processing time is almost insignificant, but the data is expensive to transport, e.g., image cropping, filtering an array, shallow copy, etc. In my specific case, offloading the task to the background falls mostly into negative-sum efficiency. If we are talking about moving megabytes of data to perform a 50ms operation, there is no benefit to offloading it to the background. Perhaps we can think of it like this: Total Time = Serialization Cost + Transit + Background Processing Time + Deserialization Cost Looking at this, if the “background processing time” is the most dominant task in your operation, then isolation is the clear winner. But if serialization, plus deserialization, plus transit exceeds that cost, then there’s no need to isolate things. And if you can’t figure out if the task is CPU-heavy or data-heavy, it certainly doesn’t hurt to measure it, for example, using performance.mark() and performance.measure() around postMessage calls to profile the transfer cost.
WebCraft's avatar
WebCraft 1 month ago
Using and Styling the Dialog Element There's a lot of nuance to the <dialog> element, a seemingly little piece of web architecture. I've got some notes from digging into it. Using and Styling the Dialog Element originally handwritten and published with love on CSS-Tricks. You should really get the newsletter as well.
WebCraft's avatar
WebCraft 1 month ago
What’s !important #17: Custom Highlight API, CSS Navigation Matching, Fixing text-stroke, and More Plus, how to style skeleton UIs, how to enable diagonal scrolling, how images can overflow themselves, and yet, still more. Basically, how to do a lot of really cool (CSS) stuff. What’s !important #17: Custom Highlight API, CSS Navigation Matching, Fixing text-stroke, and More originally handwritten and published with love on CSS-Tricks. You should really get the newsletter as well.
WebCraft's avatar
WebCraft 1 month ago
Dark mode toggles: two states are enough Lea's pushing back on light/dark mode implementations that display three state options for visitors: light, dark, and system. Dark mode toggles: two states are enough originally handwritten and published with love on CSS-Tricks. You should really get the newsletter as well.
WebCraft's avatar
WebCraft 1 month ago
Timing Charts: A Blueprint For SMIL Animations We know that everything on the web is a box by default, but you’ll find many animated <div>s pretending to be circles. But if you’ve ever met a real <circle>, you’ll know that they’ve got a lot more going for them. Dressed in SVG, they fit into a wider range of crowds than a humble <div> wearing HTML/CSS can. <img> has a strict no .html policy. The <img> tag is not as static as its name suggests. Any embedded JavaScript unfortunately won’t run if you load an SVG file with an <img> tag, but CSS animations work perfectly fine. Many of the SVG attributes do have CSS property counterparts, and the geometry properties have been supported across the major browsers since 2024. Some attributes that you might want to animate, like viewBox, don’t have equivalents yet. Besides JavaScript and CSS, there’s another way to animate SVGs: Synchronized Multimedia Integration Language (SMIL). Despite its quirks, it’s still worth learning. Like CSS animations, SMIL animations also work in <img> tags and can fully animate everything in an SVG, without JavaScript. If you’ve never heard of SMIL or need a refresher, check out Andy Clarke’s well-named article. Then we’ll look at a way to plan an animation and make SMIL markup more manageable. The Break Up SMIL has a problem: it gets bloated quickly. Unlike CSS and JavaScript, where you can list multiple properties in each keyframe and easily reuse animations, each SMIL tag can only target one element and only one property of that element at a time. A property can be animated through a list of values. But it is still one tag, one element, one property. The shortest way you can write a color and opacity change that will run is the following: <animate attributeName="fill" to="someOtherColor" dur="someDuration" /> <animate attributeName="opacity" to="someOtherValue" dur="someDuration" /> That’s not bad, but consider that it needs to be repeated for every element included in the animation. A SMIL animation can quickly get longer than its CSS equivalent. To make things easier when starting a new animation, let’s plan all of the elements and properties we want to animate, and create a list of descriptive IDs for each tag. Charting Animation Time And Space I like to plan my animations using what's called a timing chart. A timing chart is effectively a line segment; some choose horizontal lines, others prefer vertical, which is a great analogy for animation as a whole because line segments can run parallel, overlap, and follow each other with or without a gap. Just like animations. For now, we’re only interested in when animations start and stop. When drawing our charts, we’ll forget about the in-between lines and instead draw a line for each component animation, marking the beginning and end. I like to annotate timing with a circle and a bar. You can draw your chart using whatever, and it doesn’t have to be exactly to scale, as long as the relative timing between all the little animations that make up the whole is clear. Besides, adding labels for the durations is an easy cheat to get around drawing to scale. Here is a demo of how I typically set up a timing chart with more than one animation: See the Pen colorAndOpacityChange [forked] by Johan Grobler. The important thing to note is that the timing chart lines are arranged according to how the animations are arranged in time. One piece of the animation follows the next piece, which is followed by a subsequent piece, and so forth. It visualizes how the animation’s parts run together and cascade over time. S(yncbase)MIL A big part of SMIL is synchronization. It’s even in the name, after all. And there are multiple ways to specify when an animation should start (here’s a test case to check what your browser supports). One of the most useful ways is with a syncbase value, which is a SMIL tag’s ID followed by either .begin or .end, with an optional positive or negative offset. Let’s piggyback off the previous animation example that includes changes in color and opacity. If we want the opacity animation to start 300 milliseconds before the color animation finishes, we could do arithmetic. Alternatively, the second animation can use the syncbase value colorChange.end - 300ms. This way, the relative timing between the two animations becomes explicit. <!-- Starts at an absolute time --> <animate id="colorChange" begin="1s" ... /> <!-- Starts relative to when #first ends --> <animate id="opacityChange" begin="colorChange.end - 300ms" ... /> Using syncbase values, the beginning of an animation is positioned in time relative to the .begin or .end of some other animation. A positive offset moves the start to the right (forwards in time), and a negative offset to the left (backwards in time). See the Pen syncbase.end [forked] by Johan Grobler. Something with negative offsets is that they can specify a time before the document has loaded or when a click happens. Computers can’t predict the future (at least not yet). The best they can do is jump the animation to where it would have been had the computer peeked into the future to preemptively start the animation. The second animation only runs from start to finish if there is enough room, so to speak. See the Pen syncbase.begin [forked] by Johan Grobler. Syncbase values don’t only allow you to connect animations from .end to .begin. Elect a primary animation; the animation that first comes to mind is usually the best representation of the group. All secondary animations can be set with begin="primary.begin". I’ve only used the ID #primary for emphasis. That way, all the other animations begin relative to that starting point. Stacking animations like this reduces maintenance if, say, we later want the whole group to start at a different time. Let’s put the idea to work and build a loading indicator (or spinner). Then we’re going to explore how changing the relative timing between the parts changes the effect of the whole animation: Step 1: Choose An Image Approach Browsers have wide support for the prefers-reduced-motion media feature and Val Head explains this in depth in another article. We definitely want to respect this user preference as we consider moving things around. In fact, consider it non-negotiable. There are various approaches to adhering to a user’s prefers-reduced-motion setting when it comes to SMIL. Each with its pros and cons. Evaluating early on what’s going to work best for your use case could save you a partial rewrite down the line. For example, we could consider using a <picture> element instead of a plain <img> because <picture> supports multiple <source> elements that can be used as fallbacks in a media attribute for reduced motion preferences. Or one SVG file with an inline CSS @media query that uses display: none to swap between versions. That said, it’s an approach that might cause trouble in various environments. But browsers are continuously changing, and this might not be an issue in the future. You might also consider a CSS background-image instead because we can wrap that style in a media query — @media (prefers-reduced-motion) — that sets a static image as the fallback for reduced motion preferences. There are even more options we can turn to! For example, SVG’s <view> element can also be used to swap things out for motion preferences. Or, if we prefer everything bundled together, we can use JavaScript .matchMedia() and the handy SMIL DOM interface to control which animations start instead of completely switching out files. For this, I’m avoiding any motion and sticking to opacity animations, which tend to cause less trouble. For a non-interactive animation like this, we can load it in an <img> tag. When we add motion, we can go the <picture> route to show the most appropriate version of our animation. Step 2: Draw The Graphics We’re going to do our own version of the classic three-dot spinner: See the Pen StaticDots [forked] by Johan Grobler. SVG wizards might be able to do everything directly in a text editor. I recommend using a graphic editor like Inkscape if you’re having trouble visualizing how the markup will be rendered. Once again, Andy Clarke has a great article about his process for optimizing and structuring his own drawings. Note: There’s a gotcha with Inkscape. Setting what you would expect to be an element’s ID via the Layers window actually sets the value of a metadata attribute used internally by Inkscape. Use Inkscape’s object properties or XML editor window to set the true element’s ID. Your mileage may vary with a different editor. Also, in Inkscape, remember to save the file as optimized SVG when the drawing is done to strip away unneeded metadata. Step 3: Outline The Animation OK, so we’re sticking with the opacity animation idea. The dots are going to fade in and out. We’ll use separate <animate> tags for those. Six tags in total. Our naming scheme is going to be straightforward: we’ll call them #fadeIn and #fadeOut, and to differentiate between each pair of tags, we’ll postfix the tag’s ID with either Left, Middle or Right. Try to follow a convention that makes sense to you when coming up with your own IDs. The fade-in <animate> tag for the dot on the left: <animate id="fadeInLeft" href="#leftDot" attributeName="opacity" from="0" to="1" ... /> And the fade-out <animate> for the middle dot: <animate id="fadeOutMiddle" href="#middleDot" attributeName="opacity" from="1" to="0" ... /> Step 4: Time The Animations We have an infinite number of ways in which we could space these six animations in time. Let’s look at a couple of choice examples alongside their timing charts to see how changing the arrangement of the parts impacts the visual effect of the whole animation. To narrow our choices a bit, all of the <animate> tags will use the same dur value, and none of the syncbase values will have offsets. For someone coming from a culture that reads from left to right, the dots appearing on screen along the same pattern would feel natural. Let’s also start with all the dots fading out together at the end: See the Pen dotsVersion1 [forked] by Johan Grobler. Syncbase values stagger the fade-ins and restart the loop when the dots have disappeared: <animate id="fadeInLeft" ... begin="0s; fadeOutLeft.end" /> <animate id="fadeInMiddle" ... begin="fadeInLeft.end" /> <animate id="fadeInRight" ... begin="fadeInMiddle.end" /> Since all the fade-outs end at the same time, it is an arbitrary choice which one we use to restart the loop. We’ll consider #fadeOutLeft as the primary animation here and also synchronize the other fade-outs to it with the syncbase value fadeOutLeft.begin. Later, if we want to move the fade-outs in time, all we do is change when #fadeOutLeft starts. <animate id="fadeOutLeft" ... begin="fadeInRight.end" /> <animate id="fadeOutMiddle" ... begin="fadeOutLeft.begin" /> <animate id="fadeOutRight" ... begin="fadeOutLeft.begin" /> Some Alternate Timings Instead of a group fade-out, we could stagger them just like the fade-ins: <animate id="fadeOutMiddle" ... begin="fadeOutLeft.end" /> <animate id="fadeOutRight" ... begin="fadeOutMiddle.end" /> Without adding an offset, there are a couple of points in time we could start #fadeOutLeft at. If it starts on fadeInRight.end: See the Pen dotsVersion2 [forked] by Johan Grobler. The visual effect is subtly changed by moving up a spot and starting #fadeOutLeft on fadeInMiddle.end instead: See the Pen dotsVersion3 [forked] by Johan Grobler. We can see from the charts that we could try moving up a spot further to fadeInLeft.end: See the Pen dotsVersion4 [forked] by Johan Grobler. How about starting the sequence with a fade-out: See the Pen dotsVersion5 [forked] by Johan Grobler. You might prefer to start with the dot in the middle: See the Pen centerFirstDots [forked] by Johan Grobler. As you iterate on your animation, timing charts are a great way to keep track of your work, and they make visual comparison between versions possible. And by drawing a timing chart, you might even see a pattern in the timing between the parts of the animations that you might otherwise have missed. Step 5: Adding More Animations As you animate more elements and properties, it gets harder to keep track of what starts when. To see how timing charts can help you make sense of things, let’s build on the basic spinner: See the Pen staticDotsWithClipPaths [forked] by Johan Grobler. I’ve added a <rect> for each dot to the drawing. We’ll move those into to a <cilpPath> tag and remove the fill="white". As the animation runs, the rectangles are going to move over the dots for a different approach to animating the stroke than by animating stroke-dashoffset. We only need a single <clipPath> for all three dots, but it adds structure to the document, and it’s good practice to wrap it, and similar tags, in a <defs> tag: <defs> <clipPath id="dotsClipPath"> <!-- The geometry of the rectangles and coordinates used here, and later, depends on the viewBox used for their parent <svg> element. --> <rect id="clipPathLeftRect" width="2" height="2" x="1" y="6" /> <rect id="clipPathMiddleRect" width="2" height="2" x="4" y="2" /> <rect id="clipPathRightRect" width="2" height="2" x="7" y="6"> </clipPath> </defs> Remember to set the clip path for the <circle>s. Either with CSS or using the clip-path attribute: <circle id="leftDot" ... clip-path="url(#dotsClipPath)" /> <circle id="middleDot" ... clip-path="url(#dotsClipPath)" /> <circle id="rightDot" ... clip-path="url(#dotsClipPath)" /> Because the dots now have a stroke added, to leave their size unchanged, we need to compensate by subtracting half the value of stroke-width from r: <circle ... r="0.9" stroke-width="0.2" ... /> That's all the changes the graphics need. Have a look at the animated version with its timing chart, then we'll look in more detail at the changes that have been made to the animation: See the Pen clipPathDots [forked] by Johan Grobler. There's a new animation, #moveClipPathLeft, that starts the whole sequence, and to tweak the animation's rhythm a bit, there's a 1s delay between when the fade-outs end and the loop restarts: <animate id="moveClipPathLeft" href="#clipPathLeftRect" attributeName="y" from="6" to="4" begin="0s; fadeOutLeft.end + 1s" fill="freeze" /> You could use <animateTransform>s to move the rectangles instead, but we need to move them back to their starting positions at the end for a smooth restart of the animation. You’ll need to take into account which tags can animate and set which data types if you do decide to animate the transform attribute instead of translating the rectangles with the y attribute. To change things up, the <rect> for the middle dot moves down: <animate id="moveClipPathMiddle" href="#clipPathMiddleRect" attributeName="y" from="2" to="4" begin="moveClipPathLeft.end" fill="freeze" /> We’re also using the fill-opacity property instead of the opacity property for the fade-ins, and they’ve been synchronized to start once a dot’s clipping <rect> has finished moving: <animate id="fadeInLeft" href="#leftDot" attributeName="fill-opacity" to="1" dur="1s" begin="moveClipPathLeft.end" fill="freeze" /> <animate id="fadeInMiddle" href="#middleDot" ... begin="moveClipPathMiddle.end" ... /> <animate id="fadeInRight" href="#rightDot" ... begin="moveClipPathRight.end" ... /> The fade-outs still use the normal opacity property, so both the fill and stroke fade out together. Because this arrangement is set up to use a group fade-out at the end, there are a few places the markup could be optimized. One of them is dropping the fill="freeze" to automatically reset the dot’s opacity back to its starting value once the tag finishes running: <animate id="fadeOutLeft" href="#leftDot" attributeName="opacity" to="0" dur="1s" begin="fadeInRight.end" /> <!-- We'll still consider #fadeOutLeft as the primary animation here and sync the start of the others to it. --> <animate id="fadeOutMiddle" href="#middleDot" ... begin="fadeOutLeft.begin" /> <animate id="fadeOutRight" href="#rightDot" ... begin="fadeOutLeft.begin" /> For the <animate> tags that did use fill="freeze", we’ll use <set> tags to reset those properties back to their starting values. I’ve simplified the chart a little by lumping those tags together. Because these <se
WebCraft's avatar
WebCraft 1 month ago
WordPress.com Student Plan As someone who teaches beginning web development, I find that building a WordPress site makes for a great final project. Hosting those projects has always been a roadblock though. WordPress.com Student Plan originally handwritten and published with love on CSS-Tricks. You should really get the newsletter as well.
WebCraft's avatar
WebCraft 1 month ago
Why Your Website Should Never Stop Changing This article is a sponsored by Fimo Every website is at its best the day it ships. The final branch merges, the site goes live exactly as designed, and it is briefly perfect. It will never be this good again. Not because anything breaks. The site keeps working. But the market moves, the messaging shifts, a competitor launches something, and the careful thing you built slowly stops matching the company it represents. A year later, it is a period piece. Not broken, just behind. Every team knows this decay, and almost everyone treats it as a law of nature. It doesn’t have to be that way. A website could keep improving after launch instead of drifting away from its best day, quietly optimizing itself while the team that built it works on something else. Picture it working: while you sleep, an agent catches that last week’s design-system change never propagated to the pricing page, and fixes it. Another finds a set of images shipped uncompressed in a rushed release and optimizes them. A third flags an accessibility regression a new component introduced, and either fixes it or leaves it for you to check. You wake up to a site that is measurably better than the one you left, and a short list of the few decisions the agents wanted your eyes on. That is the version worth wanting. And the moment you take that promise seriously, you run into a problem that has nothing to do with the technology: Almost nobody actually wants a website that changes entirely on its own. Why “Just Make It Autonomous” Is The Wrong Goal The obvious move, once you have capable agents, is to hand them the whole site. Let them write, edit, optimize, and publish, and get out of the way. It sounds like the natural endpoint, and it is the first thing most people picture when they hear “autonomous website.” It is also the thing almost nobody wants once it is real in front of them. We learned this the way you learn most things worth knowing: by building the opposite first. Building Fimo, an autonomous website platform, we set out to make websites fully autonomous, assumed that was the goal, and then watched what people actually did with it. What they did was hesitate. Not because they distrusted the agents, but because a website has no single owner. Different parts belong to different people, and each one wants a different amount of autonomy. So the question was never whether to trust the agents. It was where to draw the line, and for whom. Once you ask it that way, the work splits cleanly into three kinds. And they don’t stay fixed. They learn from their tasks and from what you teach them, so the boundary you set last month isn't the one you’re stuck with. What you had to approve then, you can delegate now, not because you lowered your guard but because the agent earned it. The line is not a setting you configure once. It moves as trust is earned, in the direction of less work for you. Start Narrow, and Widen As You Trust It None of this means flipping a site to autonomous on day one. In practice it goes the other way. You delegate a little, watch how it does, and loosen. And you can actually watch. Every agent’s runs, its history, its logs, and a before-and-after of what it changed are there to inspect. Trust doesn’t grow because you got used to the idea; it grows because you can see what happened and compare. The first time an agent quietly fixes something you would have missed, and you can see exactly what it did, the next delegation gets easier. Deadlines keep you from becoming the bottleneck on what you have already handed over. If you don’t weigh in, the agent proceeds. You set the terms once, and you stop being the thing the whole site waits on. The Frozen Site Is The Real Risk The worry people voice first is that an agent will change something on their site without them. Turn it around: the real risk is a site that never changes at all. A frozen site doesn’t stay safe. It just falls behind, slowly, in a way nobody notices until it represents a company that no longer exists. The point of autonomy was never to remove you from your website. It was to remove the decay. The point of autonomy is to keep the launch-day version from being the best version, and to let you spend your judgment on the handful of things that actually deserve it, while the rest takes care of itself. Draw the line where your value is. Let the agents hold everything on the other side of it. And let the line move as they prove they can.
WebCraft's avatar
WebCraft 1 month ago
CSS Navigation Matching, Early Days Apply a style when someone navigates from one specific page to another. The idea being it'd make the sources for cross-document view transitions declarative in CSS rather than managing that stuff in JavaScript. CSS Navigation Matching, Early Days originally handwritten and published with love on CSS-Tricks. You should really get the newsletter as well.
WebCraft's avatar
WebCraft 1 month ago
Rethinking Data Visualisation: A UX Approach To Dashboards That Actually Drives Decisions In organisations today, data has never been more available. Dashboards and performance decks exist for almost every function — sales, product, marketing, operations — and the tools to build them have never been more accessible. And yet, in weekly standups and quarterly reviews, the same thing happens constantly: someone shares the numbers, the room nods, and the meeting ends without a decision or clear direction. When that happens, the data usually takes the blame. The numbers weren’t granular enough, the dataset wasn’t complete, we need more information before we can act. But the data is almost never the problem. The reality is that nobody designed it to deliver insights. The chart was built from what was available, not from the question that needed answering. The audience was assumed rather than understood, and what should actually change as a result of seeing this data — that question — was never asked at all. Data visualisation and UX are solving the same underlying problem: both are trying to move the right information to the right person in a way that changes something. The vocabulary is different, but the underlying challenge is identical, and the moment you start treating them as complementary disciplines is the moment dashboards stop being a passive collection of charts and start doing something functional. For designers who work with data, analysts who present to non-technical audiences, and marketers who need their numbers to do more than sit in a slide, this read is for you. The Chart Was Never The Whole Story In 1973, the statistician Francis Anscombe (PDF) published a paper that made a quiet but clarifying point. He constructed four datasets that are statistically identical: same mean, same variance, same correlation coefficient, and same regression line. Run the numbers on any of them, and they are identical. Plot them, and they could not be more different. Anscombe’s lesson to statisticians was about diagnosis: visualisation reveals the operational truth that raw numbers conceal. But visualisation isn’t just diagnostic; it is also communicative. The form you choose is where understanding either emerges or gets lost in the noise. Does your audience walk away with numbers, or with a story they’ll quote and talk about? One of the most striking examples is Visual Capitalist’s History of Pandemics. Instead of burying the reader in a massive data table of casualty counts, it maps the death toll of major historical pandemics using a proportional bubble layout on a single timeline. Before your brain reads a single number, your visual system grasps the sheer scale of the Black Death relative to everything else on the page. The right visualisation does not just plot the data but makes the story impossible to miss. Edward Tufte codified a foundational principle for the craft with his data-ink ratio: every mark on a chart should serve the data, not decorate it. It remains a widely used framework in data visualisation, anchored in the assumption that clarity and visual hygiene are the goal. For a chart in isolation, that holds. But a chart is never read in isolation: it’s read by a person, in a specific context, under specific pressure. Strip a chart down to its cleanest form, and you might be removing the exact layer of context a decision-maker needs. Simplicity isn’t the goal in itself; appropriate complexity is. Data is a message, and the right amount of signal depends entirely on who’s receiving it. Which leads to the core principle of data UX: roughly 80% of the work that determines whether a dashboard succeeds happens before you ever draw a chart. That dependency is the thread the rest of this piece pulls on. The 80% That Happens Before The Chart The high-leverage 80% almost never happens on screen. It happens upstream: before a tool is opened, before a dataset is pulled, before a single design choice is made. It comes down to three questions, and once they become habitual, they change what you notice, what you ask, and what you push back on at the outset of every project. Context: What are we trying to show with this data? This is where you define what the visualisations actually need to serve before you touch any raw data. Writing down the precise operational questions, specifically enough to determine what gets pulled and what gets filtered, is what produces a dashboard that helps with decision-making. Audience: Who is this for, and how do they think? This is the empathy step. Knowing who’s in the room, what they’re accountable for, and how they engage with data determines how much complexity the visualisation can carry, and how it should be presented. Insight: What should change once this data lands? A decision, a new direction, a shift in understanding. If the intended strategic outcome isn’t clear during the design phase, it will remain invisible once the dashboard goes live. Context: What Are We Trying To Show With This Data? Most data-heavy projects start backward: teams pull whatever metrics their internal analytics tools already track and build visualisations around them, while the question the data was supposed to answer either gets assumed or never gets asked. This happens simply because we anchor on the data in front of us as the boundary of what’s possible. Defining a goal first sounds obvious, but in practice, it rarely happens with the necessary clarity. “Show me how the product is performing” is not a goal; “Identify which features drive retention among users who signed up in Q1” is, as it includes three things the first doesn’t: a metric, a population, and an implied action. That specificity is what converts an open-ended exploration into a constrained, answerable design problem. Which one you start from determines everything that follows: what you include, what comparisons matter, and what you leave out entirely. Starting with available data produces a dashboard that answers no particular question, because it was never built for one — every number is present, none of them pointed anywhere. Starting with the operational question does the reverse: every element on the screen earns its place, because each one is there to help answer it. For example, consider a UX team trying to fix a leaky checkout flow for an e-commerce website. A data-first approach pulls everything available, from clicks to scroll depth and device types, yielding a massive dashboard that leaves everyone asking, “Okay, but what do we actually change?” A context-first approach starts with a constraint: “At which step of the checkout do users drop off?” By filtering out 90% of the noise, the team builds a simple funnel chart, instantly spots a bottleneck on the payment screen, and knows exactly what to redesign. Audience: Who Is This For, And How Do They Think? Designing for an audience comes down to two things: accountability and familiarity. Familiarity is about data literacy. Do they read charts instinctively, or does a complex visualisation create friction? Handing a dense, multi-layered dashboard to a Head of Sales and a senior analyst is like giving the same map to someone who navigates by landmarks and someone who reads grid coordinates. The data is accurate, but it is only functional for one of them. Accountability dictates how that complexity must be presented. A chart showing a 12% decline carries vastly different weight for the executive responsible for that number versus the analyst simply reporting it. Understanding your audience means grasping this relationship; data is never processed neutrally when your performance is on the line. Together, familiarity and accountability decide one practical thing: how much you can put in front of someone. In data visualisation, simplicity is not a fixed virtue — the right level of it is contingent on who is reading, and what they need to do. An analyst relies on a high-density environment to conduct diagnostic discovery. By isolating individual behaviour nodes and mapping out raw user flows, they interrogate the data at its atomic level to uncover the hidden insights and underperforming spend that will shape future campaigns. An executive, by contrast, requires a highly synthesised translation of that data to immediately identify what is driving commercial growth. Tailoring a dashboard to your audience means adjusting the density dial, delivering maximum signal with appropriate complexity for the specific brain in the room. Insight: What Should Change Once This Data Lands? Most data projects operate on the comfortable assumption that if a chart is accurate and clear, the insight will take care of itself. In reality, information and insight are entirely different states. Information is what the data shows, whereas insight is the specific decision, shift in understanding, or course correction someone makes as a result of seeing it. If the intended business change isn’t defined before the design begins, a dashboard will default to passive reporting rather than driving action. Marketing and engineering teams experience the danger of this gap whenever a core business metric suddenly plummets. A dashboard built for information simply sounds the alarm, showing a chart that tracks a sharp 15% drop in booking rates. Because the data lacks depth, leadership defaults to panic: they immediately call the UX design team, assuming the app is broken or the checkout flow is flawed. Because the data doesn’t pinpoint the core of the problem, it triggers a costly, misplaced fire drill. A dashboard built for insight isolates the variables required to make an informed decision. Instead of a single, flat booking metric, the visualisation maps the drop against traffic sources and campaign launches — instantly revealing that while app performance and core user conversion are perfectly stable, the sitewide rate was artificially diluted by a massive influx of low-intent click traffic from a newly scaled campaign. The team doesn’t waste time redesigning a functioning app; they get the exact insight needed to pause the underperforming marketing campaign and adjust their acquisition strategy. Every visualisation implies a next step, even if that step is “nothing needs to change right now.” The question is whether the design makes that implication clear enough for the viewer to recognise it. From Questions To Dashboard: A Project Walk-through My aha moment in data visualisation happened during a project for a client-facing B2B SaaS platform focused on enterprise talent management and competency tracking in Pegasystems skills. The platform captured a massive footprint of daily telemetry, and the brief arrived open-ended: “We have an immense archive of user activity, now we need to present it to enterprise teams.” We could very easily have charted everything that was captured, but we wouldn’t be doing end users any favours if they just ended up looking at a data graveyard. My responsibility immediately moved beyond pure interface craftsmanship; it became about architecting a highly practical tool for real people who would open this dashboard routinely and need it to tell them an honest, immediate story about their workflows. Here is how the project actually went. Context The client believed this massive pool of data could help their users perform better, and wanted an interface that finally enabled that growth. Translating that broad ambition into tangible visualisations required defining the practical mechanics of performance. What variables indicate advancement vs passive usage? What does “perform better” actually mean? How do you measure it? An obvious candidate was time spent by product. Every platform tracks it. It is easy to show, and it feels meaningful. But time spent is a proxy; it tells you someone was there, not whether they got anything out of it. The more meaningful signals were competency scores by area, certification completion rates, and historical performance trajectories. Integrating time-spent data alongside these performance metrics added a useful layer of interpretation, helping us surface which modules users were underutilising and whether that directly correlated with lagging scores. Time spent became a supporting signal in the larger story. The second question was about the appropriate level of granularity. An identical metric carries completely different weight depending on who is looking at it. An individual contributor tracking their own completion rate needs to know if they are pacing correctly, whereas a manager reviewing a team aggregate needs to know precisely who requires immediate support. This distinction shaped every subsequent data-exposure and filtering decision. Defining that structural story early determined exactly what to show, and to whom. Audience The most straightforward approach to this design would have been predictable: use the same charts, but offer an individual view and an aggregated team view. Far too many dashboards rely on this shortcut, subtly tweaking the scale of identical data visualisations and labelling it “personalisation.” An authentic analysis of the audience reveals a much deeper rift. Frontline team leads and individual contributors required distinct narrative structures and design principles. Having used e-learning platforms myself, I remember the frustration of opening a tool without a clear sense of my current standing, core strengths, or slipping metrics. That personal experience directly guided the individual contributor workspace; it needed to act as a highly tailored, self-directed mirror that was granular, honest, and personal. Conversely, the manager’s interface had to bypass individual milestones initially to provide a macro pulse check on team vulnerabilities. It was designed around a different operational reality: how is the group progressing, and where are the consistent gaps? The view prioritised the aggregate picture first, while retaining an intuitive path to drill down into tactical day-to-day coordination when needed. Insight Our insight strategy was locked in during the early conceptual phase, long before wireframing a single chart. We intentionally abandoned the idea of building a dense, passive data log and focused on pacing the narrative arc. For individual contributors, the core value was self-direction, ensuring they could glance at the interface on a Monday morning and immediately derive a clear priority list for the week ahead. For managers, the goal was to fundamentally shift the timing of operational conversations, providing them with the necessary baseline to intervene before a skill gap evolved into a critical project failure. The visualisations needed to surface the exact moments when a human check-in would be useful, shifting their workflow from reactive post-mortems to proactive guidance. The comparison tool was the highlight nobody had asked for. A manager dashboard and an individual dashboard are easy to anticipate. What is harder to land is: what if a manager wants to compare two specific team members against the same metrics, side by side? That view came from a design assumption, and it turned out to be the feature that resonated most. The decisions that mattered most in this project weren’t in the initial brief — capturing data they hadn’t thought to request, and structuring it to answer questions they had not previously known how to articulate, which is the core differentiator of a user-centric data strategy. Designing The Mental Model Early The choice of visualisation layout must follow the geometric nature of the data itself. For this project, the core design problem was enabling an individual user to answer a specific question at a single glance: across eight distinct competency areas, where are my relative strengths and gaps? To solve this, we mapped the data using a radar chart. By organising multiple variables across axes radiating from a central point using polar coordinates, the interface connects the data points to form a single, unified shape. An even, balanced polygon instantly signals well-rounded proficiency, while a sharply skewed shape draws the eye immediately to an outlier area. While a traditional linear bar chart would have forced the viewer to scan eight individual bars and mentally calculate the variance, a concentric, radial layout segments the dat
↑