Utility-First CSS

Utility-First CSS

Utility-First CSS is a method for styling web pages: instead of writing custom styling rules for every element, the look is assembled from many tiny, pre-built building blocks. The approach became well known through the tool Tailwind CSS.

Every web page consists of two parts: the content and the styling rules that determine how that content looks. These rules define things like font size, color, or spacing. Traditionally, such rules are written in their own files and given descriptive names like “main menu” or “product card”. Utility-First CSS turns this around. Here there are hundreds of tiny rules, each doing exactly one thing: one for red text, one for four pixels of spacing, one for bold text. The developer combines these building blocks directly where the content sits.

Why developers want to save themselves the naming

The biggest problem with traditional styling rules is naming. For every new element, someone has to come up with a name. Is the box called “info-box”, “notice”, or “small card”? In large projects with many contributors, this quickly produces hundreds of names that nobody can keep track of anymore.

There’s a second problem on top of that. Nobody dares to delete old rules. Maybe some page still uses them that isn’t currently top of mind. So the styling file keeps growing, even though half of it is long dead. With Utility-First CSS, this growth doesn’t happen, because the building blocks are fixed from the start and get reused again and again.

The approach is therefore primarily an answer to an organizational problem, not a technical one. It doesn’t make the page faster or more beautiful. It makes it easier for a team to maintain. This is exactly why the approach has become so widespread in recent years.

Building blocks instead of custom rules

A utility is a rule that sets exactly one property. It carries a short, technical name that describes what it does. A building block named “text-red” colors text red, “p-4” creates inner spacing. These names are deliberately not creative, but systematically constructed.

A blue button with rounded corners then doesn’t come from a rule called “button”. It’s made up of four or five building blocks side by side: blue background, white text, inner spacing, rounded corners. Anyone who wants to change the button swaps out a building block and immediately sees what happens. There’s no need to jump to another file for that.

So that the page isn’t shipped with thousands of unused building blocks, there’s an intermediate step. Before publishing, a program scans the entire project code and keeps only the building blocks that actually occur. Often only a few kilobytes remain. Without this step, the approach would hardly be practical.

Tailwind, Bootstrap, and the criticism

The best-known tool of this kind is Tailwind CSS, which has existed since 2017 and today is used in a great many new web projects. Anyone looking at the source code of modern pages recognizes it by the long chains of short class names in the code. Ready-made UI toolkits are increasingly built on top of it as well.

The approach should be distinguished from libraries like Bootstrap. Those deliver ready-made components, i.e. a complete button or a complete menu. Utility-First only delivers the individual pieces and leaves the assembly to the developer. This is more work, but leads to designs that look less like standard templates.

There is plenty of criticism. The code becomes cluttered, because a single line can contain ten building blocks. Some consider this a step backward to the early days of the web. Defenders respond that repetition can be bundled into reusable components in modern toolkits anyway. The debate around this is one of the most enduring points of contention in web development.

Subscribe free. Unsubscribe the second it sucks.

High-signal news across AI, business, UX, and tech. Every morning.