Home/Josh Comeau
Source

Josh Comeau

79 articles from Josh Comeau.

Frontend — Getting Started with Anchor Positioning

Getting Started with Anchor Positioning

For decades, one of the most notoriously-challenging problems on the web has been sticking one element to another element, for things like tooltips and nested menus. The CSSWG has decided to provide a first-class solution to this problem, and it’s pretty friggin’ cool! In this tutorial, I’ll share the most useful parts I’ve found from this modern CSS feature.

JWJosh W. Comeau·July 6, 2026Frontend
Performance — CSS vs. JavaScript

CSS vs. JavaScript

There are a bunch of JavaScript animation libraries out there, and you might have wondered whether there’s a performance cost compared to traditional CSS transitions and keyframe animations. In this blog post, we’ll compare the same animation across several different strategies and see the differences firsthand. There’s some interesting nuance here!

JWJosh W. Comeau·May 26, 2026Performance
Frontend — Scroll-Driven Animations

Scroll-Driven Animations

The new Animation Timeline API allows us to create dynamic scroll animations without any JavaScript! It’s honestly a very lovely API, and in this blog post, we’ll explore some of the super cool things we can do with it.

JWJosh W. Comeau·April 28, 2026Frontend
Frontend — Squash and Stretch

Squash and Stretch

Have you ever heard of Disney’s 12 Basic Principles of Animation? In this tutorial, we’ll explore how we can use the very first principle to create SVG micro-interactions that feel way more natural and believable. It’s one of those small things that has a big impact.

JWJosh W. Comeau·April 13, 2026Frontend
Frontend — Sneaky Header Blocker Trick

Sneaky Header Blocker Trick

There is a lil’ UI detail on this blog. Most people don’t even notice it, but the ones who do often reach out, asking how on earth it works. It feels like it defies the rules of CSS! In this blog post, I’ll break down the surprisingly-straightforward implementation so you can start using this trick yourself.

JWJosh W. Comeau·March 23, 2026Frontend
Frontend — Sprites on the Web

Sprites on the Web

In game development, it’s common to use spritesheets for animation, but this technique isn’t as widely used on the web these days. Which is a shame, because we can do some pretty cool stuff with sprites! In this post, we’ll share the niche CSS function you can use to leverage this technique, and explore some of the potential use cases.

JWJosh W. Comeau·February 23, 2026Frontend
Frontend — Brand New Layouts with CSS Subgrid

Brand New Layouts with CSS Subgrid

Subgrid allows us to extend a grid template down through the DOM tree, so that deeply-nested elements can participate in the same grid layout. At first glance, I thought this would be a helpful convenience, but it turns out that it’s so much more. Subgrid unlocks exciting new layout possibilities, stuff we couldn’t do until now. ✨

JWJosh W. Comeau·November 25, 2025Frontend
Frontend — Springs and Bounces in Native CSS

Springs and Bounces in Native CSS

The “linear()” timing function is a game-changer; it allows us to model physics-based motion right in vanilla CSS! That said, there are some limitations and quirks to be aware of. I’ve been experimenting with this API for a while now, and in this post, I’ll share all of the tips and tricks I’ve learned for using it effectively. ✨

JWJosh W. Comeau·October 28, 2025Frontend
Frontend — The Big Gotcha With @starting-style

The Big Gotcha With @starting-style

CSS has been on fire lately, with tons of great new features. @starting-style is an interesting one; it allows us to use CSS transitions for enter animations, something previously reserved for CSS keyframe animations. But is the juice worth the squeeze?

JWJosh W. Comeau·September 22, 2025Frontend
Frontend — Color Shifting in CSS

Color Shifting in CSS

A little while ago, I was trying to animate an element’s background color, so that it cycled through the rainbow. Seems easy, but it turns out, browsers have a surprisingly big limitation when it comes to color processing! In this tutorial, we’ll dig into the issue, and I’ll share a couple of strategies you can use to work around this limitation.

JWJosh W. Comeau·September 8, 2025Frontend
Frontend — An Interactive Guide to SVG Paths

An Interactive Guide to SVG Paths

SVG gives us many different primitives to work with, but by far the most powerful is the element. Unfortunately, it’s also the most inscrutable, with its compact Regex-style syntax. In this tutorial, we’ll demystify this infamous element and see some of the cool things we can do with it!

JWJosh W. Comeau·August 18, 2025Frontend
Frontend — A Friendly Introduction to SVG

A Friendly Introduction to SVG

SVGs are one of the most remarkable technologies we have access to on the web. They’re first-class citizens, fully addressable with CSS and JavaScript. In this tutorial, I’ll cover all of the most important fundamentals, and show you some of the ridiculously-cool things we can do with this massively underrated tool. ✨

JWJosh W. Comeau·July 21, 2025Frontend
Frontend — Partial Keyframes

Partial Keyframes

CSS Keyframe animations are so much more powerful than most developers realize. In this tutorial, I’ll show you something that completely blew my mind, a technique that makes our keyframe animations so much more reusable and dynamic! 🤯

JWJosh W. Comeau·June 10, 2025Frontend
Frontend — The Height Enigma

The Height Enigma

One of the most perplexing and befuddling things in CSS for me, for many years, was the behaviour of percentage-based heights. Sometimes, seemingly at random, setting height: 100% would have no effect at all. When I finally figured out what was going on, it was like a puzzle piece snapping into place; everything made so much more sense! In this post, I’ll share the epiphany I had, and we’ll explor

JWJosh W. Comeau·May 12, 2025Frontend
AI & ML — The Post-Developer Era

The Post-Developer Era

When OpenAI released GPT-4 back in March 2023, they kickstarted the AI revolution. The consensus online was that front-end development jobs would be totally eliminated within a year or two.Well, it’s been more than two years since then, and I thought it was worth revisiting some of those early predictions, and seeing if we can glean any insights about where things are headed.

JWJosh W. Comeau·April 14, 2025AI & ML
Engineering — A Million Little Secrets

A Million Little Secrets

I spent the past few weeks packing as many easter eggs as I could into my latest project, and in this blog post, I want to dig into some of the more interesting details! If you’re interested in animations/interactions, you’ll want to check this one out; I share a bunch of my favourite secrets and tricks. 😄

JWJosh W. Comeau·February 24, 2025Engineering
Systems — Container Queries Unleashed

Container Queries Unleashed

Container queries expand the universe of designs that can be implemented, giving us whole new superpowers. Now that container queries are broadly available, I think it’s time we start exploring this potential! In this post, I’ll share the “killer pattern” I can’t stop using in my work, and explore what’s possible with this new capability.

JWJosh W. Comeau·January 27, 2025Systems
Design & UX — Next-level frosted glass with backdrop-filter

Next-level frosted glass with backdrop-filter

Glassy headers have become a core part of the “slick startup” UI toolkit, but they’re all missing that final 10% that really makes it shine. In this tutorial, you’ll learn how to create the most realistic lush frosted glass anywhere on the internet.

JWJosh W. Comeau·December 2, 2024Design & UX
Frontend — A Framework for Evaluating Browser Support

A Framework for Evaluating Browser Support

Lots of exciting new features have been landing in CSS recently, and it can be tough trying to figure out if they’re safe to use or not. We might know that a feature is available for 92% of users, but is that sufficient? Where do we draw the line? In this blog post, I’ll share the framework I use for deciding whether or not to use a modern CSS feature

JWJosh W. Comeau·November 26, 2024Frontend
Systems — A Friendly Introduction to Container Queries

A Friendly Introduction to Container Queries

It’s been a couple of years since container queries started landing in browsers… so why isn’t anyone using them? It turns out that container queries are kinda tricky; they’re not as straightforward as media queries. In this tutorial, we’ll break it all down and make sense of them, so that you can start using them in your work.

JWJosh W. Comeau·November 4, 2024Systems
Engineering — How I Built My Blog

How I Built My Blog

I recently launched a brand new version of this blog, and in this post, I share how it’s built! We’ll examine the tech stack and see how all of the pieces fit together, as well as dig into some of the details to see how they work.

JWJosh W. Comeau·September 24, 2024Engineering
Frontend — The Undeniable Utility Of CSS :has

The Undeniable Utility Of CSS :has

Of all the latest and greatest CSS features, the “:has” pseudo-class wasn’t exactly at the top of my wishlist. Once I started using it, however, I kept discovering incredible things I could do with it. It’s now become a core part of my toolkit! In this blog post, I'll show you some practical real-world problems I solved using “:has”, as well as some wild experiments that blew my mind!

JWJosh W. Comeau·September 9, 2024Frontend
Frontend — Promises From The Ground Up

Promises From The Ground Up

The “Promises” API is a surprisingly tricky part of modern JavaScript. Without the right context, it doesn’t make much sense at all! In this tutorial, you’ll build an intuition for how Promises work by getting a deeper understanding of JavaScript and its limitations.

JWJosh W. Comeau·June 3, 2024Frontend
Performance — Snappy UI Optimization with useDeferredValue

Snappy UI Optimization with useDeferredValue

useDeferredValue is one of the most underrated React hooks. It allows us to dramatically improve the performance of our applications in certain contexts. I recently used it to solve a gnarly performance problem on this blog, and in this tutorial, I'll show you how! ⚡

JWJosh W. Comeau·May 13, 2024Performance
Frontend — CSS in React Server Components

CSS in React Server Components

You can’t make an omelette without cracking a few eggs, and when the core React team unveiled their vision for the future of React, some of my favourite libraries got scrambled 😅. In this blog post, we’re going to explore the compatibility issues between React Server Components and CSS-in-JS libraries like styled-components. You’ll understand what the issue is, what the options are, and what’s on

JWJosh W. Comeau·April 15, 2024Frontend
Frontend — How To Center a Div

How To Center a Div

Back in the day, centering an element was one of the trickiest things in CSS. As the language has evolved, we’ve been given lots of new tools we can use… But how do we pick the best option? When do we use Flexbox, or CSS Grid, or something else? Let's dig into it.

JWJosh W. Comeau·February 13, 2024Frontend
Frontend — An Interactive Guide to CSS Grid

An Interactive Guide to CSS Grid

CSS Grid is an incredibly powerful tool for building layouts on the web, but like all powerful tools, there's a significant learning curve. In this tutorial, we'll build a mental model for how CSS Grid works and how we can use it effectively. I'll share the biggest 💡 lightbulb moments I've had in my own learning journey.

JWJosh W. Comeau·November 21, 2023Frontend
Frontend — Understanding the JavaScript Modulo Operator

Understanding the JavaScript Modulo Operator

One of the most commonly-misunderstood operators is Modulo (%). In this tutorial, we'll unpack exactly what this little bugger does, and learn how it can help us solve practical problems.

JWJosh W. Comeau·September 18, 2023Frontend
Frontend — Making Sense of React Server Components

Making Sense of React Server Components

This year, the React team unveiled something they've been quietly researching for years: an official way to run React components exclusively on the server. This is a significant paradigm shift, and it's caused a whole lot of confusion in the React community. In this tutorial, we'll explore this new world, and build an intuition for how it works, and how we can take advantage of it.

JWJosh W. Comeau·September 6, 2023Frontend
Frontend — Animated Pride Flags

Animated Pride Flags

Happy Pride month! In this tutorial, I'll share a handful of my favourite animation tricks. You'll learn how to build an animated wavy pride flag using CSS keyframes and linear gradients. We'll also see how to make it dynamic using React. 🏳️‍🌈

JWJosh W. Comeau·June 6, 2023Frontend
Frontend — The “const” Deception

The “const” Deception

The “const” keyword in JavaScript is used to create constants, variables that can't change. Curiously, though, we do seem to be able to edit objects and arrays that are created using “const”. In this tutorial, we're going to dig into the incredibly-important distinction between “assignment” and “mutation” in JavaScript.

JWJosh W. Comeau·April 24, 2023Frontend
AI & ML — The End of Front-End Development

The End of Front-End Development

Large language models like GPT-4 are becoming increasingly capable, at an alarming rate. Within a couple of years, we won't need developers any more! …Or at least, that's the narrative going viral on social media. I'm much more optimistic about what these AI advancements mean for the future of software development.

JWJosh W. Comeau·March 20, 2023AI & ML
Frontend — Common Beginner Mistakes with React

Common Beginner Mistakes with React

I used to teach React at a local coding bootcamp, and I noticed that students kept getting tripped up by the same handful of things. In this article, we're going to go through 9 of the most dastardly gotchas. I'll show you how to solve these common problems, so you can avoid a lot of potential frustration!

JWJosh W. Comeau·March 6, 2023Frontend
Frontend — Data Binding in React

Data Binding in React

As developers, we don't like working with forms, but they're a critical part of most web applications! In this tutorial, you'll learn exactly how to wire up all of the different form controls in React. Never forget how to data-bind a checkbox or radio button again!

JWJosh W. Comeau·January 9, 2023Frontend
Frontend — Color Formats in CSS

Color Formats in CSS

CSS gives us so many options when it comes to expressing color—we can use hex codes, rgb, hsl, and more. Which option should we choose? This turns out to be a surprisingly important decision! In this article, we'll take a tour of color formats in CSS, and see which option will serve us best.

JWJosh W. Comeau·November 28, 2022Frontend
Engineering — An Interactive Guide to Flexbox

An Interactive Guide to Flexbox

When we truly learn the secrets of the Flexbox layout mode, we can build absolutely incredible things. Fluid layouts that stretch and shrink without arbitrary breakpoints. In this action-packed interactive tutorial, we'll pop the hood on the Flexbox algorithm and learn how to do remarkable things with it. ✨

JWJosh W. Comeau·November 22, 2022Engineering
Career & Teams — A World-Class Code Playground with Sandpack

A World-Class Code Playground with Sandpack

No developer blog or technical documentation site is complete without an interactive code playground. The CodeSandbox team recently released a wonderful tool called Sandpack, to help us create these live-updating code editors. In this tutorial, I'll show you how I use it on this blog.

JWJosh W. Comeau·October 11, 2022Career & Teams
Frontend — Understanding useMemo and useCallback

Understanding useMemo and useCallback

What's the deal with these two hooks?! Lots of devs find them confusing, for a whole host of reasons. In this tutorial, we'll dig deep and understand what they do, why they're useful, and how to get the most out of them.

JWJosh W. Comeau·August 30, 2022Frontend
Performance — Why React Re-Renders

Why React Re-Renders

In React, we don't update the DOM directly, we tell React what we want the DOM to look like, and React tackles the rest. But how exactly does it do this? In this tutorial, we'll unpack exactly when and why React re-renders, and how we can use this information to optimize the performance of our React apps.

JWJosh W. Comeau·August 16, 2022Performance
Frontend — Statements Vs. Expressions

Statements Vs. Expressions

One of the most foundational things to understand about JavaScript is that programs are made up of statements, and statements have slots for expressions. In this blog post, we'll dig into how these two structures work, and see how building an intuition about this can help us solve practical problems.

JWJosh W. Comeau·July 11, 2022Frontend
Frontend — My Wonderful HTML Email Workflow

My Wonderful HTML Email Workflow

If you've ever had the misfortune of being tasked with building a template for HTML emails, you know it's tricky business! In this blog post, I share the approach I took to build responsive, client-friendly emails without a single tag.

JWJosh W. Comeau·June 27, 2022Frontend
Design & UX — The Surprising Truth About Pixels and Accessibility

The Surprising Truth About Pixels and Accessibility

“Should I use pixels or rems?”. In this comprehensive blog post, we'll answer this question once and for all. You'll learn about the accessibility implications, and how to determine the best unit to use in any scenario.

JWJosh W. Comeau·May 17, 2022Design & UX
Design & UX — You Don’t Need a UI Framework

You Don’t Need a UI Framework

As developers, it can be tempting to grab a pre-styled UI framework like Material UI or Bootstrap. Seems like a great way to outsource design and save a bunch of time, right? In my experience, this is an unrealistic expectation, and things don’t quite work out that way.

JWJosh W. Comeau·May 3, 2022Design & UX
Frontend — The Front-End Developer's Guide to the Terminal

The Front-End Developer's Guide to the Terminal

If you want to learn a modern JavaScript framework like React or Angular, you better be familiar with the terminal! So many frameworks and tools assume that you're proficient with it, without ever explaining it. This blog post is your missing manual, covering all of the most important fundamentals.

JWJosh W. Comeau·April 19, 2022Frontend
Frontend — Understanding Layout Algorithms

Understanding Layout Algorithms

As front-end developers, we often learn CSS by focusing on individual properties. Instead, we should focus on how the language uses those properties to calculate layouts. In this blog post, we'll pop the hood on CSS and see how the language is structured, and how to learn it effectively.

JWJosh W. Comeau·March 28, 2022Frontend
Frontend — Delightful React File/Directory Structure

Delightful React File/Directory Structure

How should we structure components and other files in our React apps? I've iterated my way to a solution I'm really happy with. In this blog post, I'll share how it works, what the tradeoffs are, and how I mitigate them.

JWJosh W. Comeau·March 15, 2022Frontend
Engineering — Make Beautiful Gradients

Make Beautiful Gradients

Have you ever noticed that gradients tend to look a little gray and washed-out in the middle? This happens because of a mathematical quirk with RGB colors. Fortunately, we can work around this quirk, and create beautiful, lush, saturated gradients.

JWJosh W. Comeau·January 11, 2022Engineering
Frontend — A Modern CSS Reset

A Modern CSS Reset

I have a set of baseline CSS styles that come with me from project to project. In the past, I'd use a typical CSS reset, but times have changed, and I believe I have a better set of global styles!

JWJosh W. Comeau·November 23, 2021Frontend
Frontend — Introducing “Shadow Palette Generator”

Introducing “Shadow Palette Generator”

In order to create lush, realistic shadows in CSS, we need to use multiple layers and colors. How do we come up with all of the parameters, though? I've built a tool that'll help.

JWJosh W. Comeau·November 16, 2021Frontend
Frontend — An Interactive Guide to Keyframe Animations

An Interactive Guide to Keyframe Animations

CSS keyframe animations are incredibly flexible and powerful, but they’re also a bit weird. In this deep-dive tutorial, we'll learn how CSS keyframes work from the ground up, and see how to use them to build high-quality animations.

JWJosh W. Comeau·August 31, 2021Frontend
Frontend — The World of CSS Transforms

The World of CSS Transforms

The “transform” property is such a powerful part of the CSS language! In this blog post, we'll take a deep look at this property and see some of the nifty things it can do.

JWJosh W. Comeau·August 9, 2021Frontend
Engineering — How To Learn Stuff Quickly

How To Learn Stuff Quickly

As software developers, we're always learning new things; it's practically the whole gig! If we can learn to quickly pick up new languages/frameworks/tools, we'll become so much more effective at our job. It's sort of a superpower.

JWJosh W. Comeau·July 19, 2021Engineering
Engineering — How I Built My Blog

How I Built My Blog

An in-depth look at the technical stack behind this very blog! We'll see how I use Next's API routes to implement my hit and like counters, how I use MDX to add interaction and customization, and how I organize my codebase, among others.

JWJosh W. Comeau·April 20, 2021Engineering
Frontend — Building a Magical 3D Button

Building a Magical 3D Button

Every action we take on the web starts with a button click, and yet most buttons are ho-hum and uninspired. In this tutorial, we'll build an animated 3D button with HTML and CSS that sparks joy.

JWJosh W. Comeau·March 30, 2021Frontend
Frontend — The Importance of Learning CSS

The Importance of Learning CSS

I know so many super-talented developers who share the same achilles heel: CSS. Instead of trying to “outrun” CSS, this article explores why leaning in and going deeper can be a tremendous boon for your development life and your career.

JWJosh W. Comeau·March 3, 2021Frontend
Engineering — What The Heck, z-index??

What The Heck, z-index??

The z-index property can be a tricky little bugger. Sometimes, no matter how much you crank up the number, the element never rises to the top! In this article, we explore stacking contexts, and see how they can thwart our efforts to use z-index. We'll also learn how to use this mechanism to our advantage.

JWJosh W. Comeau·February 22, 2021Engineering
Frontend — An Interactive Guide to CSS Transitions

An Interactive Guide to CSS Transitions

This comprehensive guide shows how to use CSS transitions! A back-to-basics look at the fundamental building blocks we need to create microinteractions and other animations.

JWJosh W. Comeau·February 9, 2021Frontend
Frontend — The styled-components Happy Path

The styled-components Happy Path

styled-components is a wonderfully powerful styling library for React, and over the years I've learned a lot about how to use it effectively. This article shares my personal “best practices”.

JWJosh W. Comeau·January 25, 2021Frontend
Frontend — Let's Bring Spacer GIFs Back!

Let's Bring Spacer GIFs Back!

The 90s web gave us many delightful things: web rings, guestbooks, “under construction” animations, and spacer GIFs. In this article, we'll see how I use a Spacer component to solve common layout problems, and why it's often a great tool for the job in the modern web.

JWJosh W. Comeau·January 11, 2021Frontend
Engineering — Refreshing Server-Side Props

Refreshing Server-Side Props

Next allows you to do server-side data-fetching, but what happens when that data needs to change on the client? This brief tutorial shows how to re-fetch the props without doing a full server reload.

JWJosh W. Comeau·December 14, 2020Engineering