---
title: "Designing in code: HTML, CSS, and Tailwind for designers (with interaction and animation)"
description: "How designers can design interfaces directly in code: HTML structure, Tailwind utility classes, layout with grid and flexbox, and adding interaction and animation without overcomplicating it."
url: "https://mikestilling.com/guides/designing-in-code-with-tailwind/"
date: "2026-11-20"
author: "Mike Stilling"
---

> AI-generated from Mike Stilling's work, notes, and writing.

# Designing in code

One of Mike Stilling's hot takes is that utility-first CSS is the best design tool created so far. This guide covers how Mike designs interfaces directly in code: structure in HTML, styling with Tailwind, layout with grid and flexbox, and interaction and animation without overcomplicating it. For getting set up and working with AI tools, see [prototyping in code](https://mikestilling.com/guides/prototyping-in-code-for-designers/).

## The short answer

**Most of a designer's job is placing rectangles and text on screens, and HTML and CSS are made for exactly that.** Use HTML for structure, utility classes for appearance, CSS Grid and Flexbox for layout, and reach for JavaScript last. Keep an editor and a live browser preview side by side, and design in the save-and-look loop.

## Rectangles and text

HTML describes *what* is on the page. CSS describes *how it looks*.

Think of HTML like a well-structured document. Use real headings (`h1`, `h2`, `h3`), paragraphs, lists, links, and buttons, the same way you'd use proper heading styles in a doc instead of just bolding text. You get structure, accessibility, and SEO for free.

A simple, reusable page structure:

- **Sections** are full-width horizontal bands of the page.
- **Containers** sit inside sections and set the maximum content width.
- **Components** like the nav and footer are shared across pages so everything stays consistent.

In most static site generators, each page is one file. Its front matter (the block between `---` lines at the top) holds the page title, SEO and social descriptions, and the social image. Everything about a page lives in one place.

## Styling with utility classes

With [Tailwind](https://tailwindcss.com/), you style elements with small, single-purpose classes right in the markup:

```html
<section class="border-x">
  <div class="grid grid-cols-2 gap-16 items-center py-96 px-16">
    <div>
      <h2 class="text-32/110 font-medium tracking-tight text-balance">
        A headline that wraps nicely
      </h2>
      <p class="text-18 text-gray-500">Supporting copy in a muted gray.</p>
    </div>
    <div class="aspect-16/9 bg-gray-50 border rounded-lg overflow-hidden">
      <img src="/assets/images/example.png" width="1600" height="900" class="w-full h-auto" alt="">
    </div>
  </div>
</section>
```

A few things worth knowing:

- **Tailwind isn't a UI kit.** It generates classes from a config you control. You customize the spacing scale, type sizes, and colors to match your design system. (The class names above assume a customized, pixel-based scale, which is how Mike sets up projects.)
- **One class can carry several decisions.** `text-32/110` sets font size and line height together.
- **`text-balance`** evens out ragged headline wraps, and children inherit it.
- **Arbitrary values** like `mt-[13px]` are handy when no preset exists. They're fine in prototypes, but in production they bloat your CSS. Add a real token instead.
- **Always set image `width` and `height`** so the layout doesn't jump while images load.

## Layout with grid and flexbox

CSS Grid and Flexbox are a game changer. Almost every modern layout is one or both:

- **Grid** for two-dimensional layouts: columns and rows, card grids, page structure.
- **Flexbox** for one direction: nav bars, button groups, centering, distributing space.

CSS-Tricks has excellent visual guides to both. Once you understand them, you'll also design better layouts in Figma, because auto layout is basically flexbox.

This vocabulary pays off with AI tools too. "2-column grid, 16px gap, vertically centered" gets much better results than "two things side by side." More in [prototyping in code](https://mikestilling.com/guides/prototyping-in-code-for-designers/).

## Interaction: HTML, then CSS, then JavaScript

Mike's rule: **try HTML first, then CSS, and only reach for JavaScript when necessary.** Simpler code is easier to maintain and less likely to break.

**HTML can do more than people think:**

- `<details>` and `<summary>` give you an accordion or FAQ with zero JavaScript.
- `contenteditable` makes text editable in place, which is great for prototyping copy.
- Radio inputs can be styled as tabs, toggles, or selectable cards.

**CSS handles most states:**

- `:hover`, `:focus-visible`, and `:checked` for the obvious ones.
- `:has()` lets a parent style itself based on a child's state, like a card that highlights when its radio is checked. It replaces a lot of JavaScript.

**When you do need JavaScript**, keep it simple:

- Use data attributes as hooks (`data-headline`, then `document.querySelector('[data-headline]')`). It separates behavior from styling, and anyone reading the markup can see that JavaScript is attached.
- Use `addEventListener('click', …)` for one element, or `querySelectorAll` with `forEach` for many.
- If you don't understand a snippet, ask your editor's AI to explain it line by line.

## Animation

- **Transitions** for state changes: `transition-all duration-200 ease-out` plus a `hover:` class covers most hover and focus polish.
- **Keyframes** (`@keyframes`) for simple loops like a spinner or a slowly rotating gradient.
- **A library for choreography.** For sequenced, staggered motion, use [GSAP](https://gsap.com/) or [Motion](https://motion.dev/). If you've used After Effects, a GSAP timeline will feel familiar. It's the same idea, with the keyframes written in code. Set initial states, then tween elements in with staggers and overlapping offsets.
- **Progressive enhancement.** If content is hidden until an animation reveals it, make sure it's still visible when JavaScript doesn't run.
- **Respect reduced motion.** Check `prefers-reduced-motion` and tone things down for people who ask for it.

For complex visual effects like WebGL shaders, this is where AI tools shine. Stub the element and describe the effect, then constrain the AI to no new dependencies.

## Stop agonizing over tools

The internet is full of debates about which framework, which CSS approach, and which animation library to use. Most of it is unproductive. It's like arguing over which brand of drill to use while the house doesn't get built. Pick something reasonable, learn it well, and make things.

If you're weighing platforms for a whole marketing site, there's a comparison in [Webflow vs Framer vs code](https://mikestilling.com/guides/webflow-vs-framer-vs-code/).

## Frequently asked questions

### Is Tailwind good for designers?

Yes. Utility-first CSS like Tailwind lets you style elements directly in the markup with small, predictable classes for spacing, type, color, and layout. That makes designing in a code editor fast and exact, and it maps well to how designers already think about spacing scales and type ramps.

### Is Tailwind a UI component library?

No. Tailwind generates small utility classes from a configuration you can customize. It does not give you pre-built components the way a UI kit does. You decide what things look like.

### Should I use HTML, CSS, or JavaScript for interactions?

Try HTML first, then CSS, and only reach for JavaScript when you need it. Native elements like details and summary, and CSS selectors like :hover, :focus-visible, :checked, and :has(), handle a surprising amount of interaction with less code that is less likely to break.

### What should designers learn first in CSS?

The box model, then CSS Grid and Flexbox. Grid and Flexbox are how almost every modern layout is built, and understanding them changes how you design layouts in any tool.

### How do designers animate in code?

Start with CSS transitions for hover and focus states and CSS keyframes for simple loops. For sequenced, choreographed motion, use a library like GSAP or Motion; a GSAP timeline works a lot like a timeline in After Effects, except the keyframes are written in code.
