Designing CSS for a website means planning a small set of foundational rules—colors, type, spacing, and layout conventions—before you style individual pages, then writing component styles that read from those foundations and adapting them with media queries and browser checks. The key condition is consistency: a stylesheet you can extend without duplicating rules. If you skip the planning step, the first redesign usually turns into an unlayered patchwork of overrides.

That difference shows up fast. A planned stylesheet changes a brand color in one place; an unplanned one buries it in dozens of rules under slightly different names. The workflow below moves from planning through layout, typography, components, responsive behavior, and testing, and it works for a small brochure site as well as a multi-page application, though the scale of each step changes.

Start with a stylesheet plan before you write a rule

The first hour of CSS work isn't CSS. It's a short planning pass that decides what your design system needs to express and how you'll name it. Skip this and you'll rename classes three times before the first release.

Work through these prerequisites in order:

1: Inventory what repeats. List the elements that appear on most pages: header, navigation, buttons, cards, forms, footers. These deserve shared component styles; one-off page sections don't. 2: Collect design tokens. Gather the actual values from the design, if one exists: palette, typefaces and sizes, spacing steps, corner radii, shadow levels, breakpoints. Write them down as a flat list. You're looking for roughly 8–12 colors, 5–8 type sizes, and a spacing scale. 3: Choose a naming approach. Most projects pick one convention, like BEM (block__element--modifier) or utility classes with a small set of semantic components, and keep it. Consistency matters more than which you pick. 4: Decide where styles live. A single compiled stylesheet, per-page styles, or CSS Modules and utility builds each change how you organize files. Pick one architecture now; mixing them later is the common cause of specificity fights. 5: Set the browser baseline. Decide which browsers and versions you're supporting and whether you can use newer features such as CSS nesting, container queries, or the :has() selector. Check current support for each feature you plan to rely on rather than assuming.

A practical success check: after planning, you should be able to point to a token name for every color and every spacing value you'll use in the first three pages. If you can't, the design isn't mapped tightly enough yet, and the gap will leak into the CSS.

Build a token layer with custom properties

Custom properties (--color-brand, --space-2) give you one authoritative value you can change and reuse. Define them on :root for global tokens and on component scopes for local overrides. The pattern looks like this:

The mechanical payoff is real: changing the brand color is one edit, and a dark theme becomes a second block of token overrides rather than a duplicated stylesheet. Two limits matter, though. First, custom properties cascade, so a token defined on a component inherits into every child—useful, but easy to overuse. Second, older browsers may not support some optional token-adjacent features; the core var() mechanism is broadly supported in current browsers, but verify anything you ship.

A sensible check: search your CSS for hex colors and raw pixel values outside the :root block. If the count is high, move those values into tokens.

Choose a layout system and commit to it

Layout decisions—Flexbox or Grid, a container width, a spacing rhythm—determine what most components will look like. Pick these deliberately before writing component styles.

Page container: set a maximum content width and center it, so text lines don't run the full width of a wide monitor. A class like .container { width: min(100% - 2rem, 72rem); margin-inline: auto; } handles it. Spacing rhythm: use the same spacing scale for margins and padding everywhere. Uneven gaps are the most visible sign of unplanned CSS. Layout primitives: use Flexbox for one-dimensional arrangements (a nav row, a button group) and Grid for two-dimensional ones (a card grid). CSS Grid's repeat(auto-fit, minmax(...)) handles responsive card grids without media queries:

That rule produces as many 16rem-minimum columns as fit, expanding to fill the row. It's fewer rules and fewer breakpoints than a hand-tuned grid. One failure case: if content inside the grid items is wider than 16rem (a long unbreakable URL, a wide table), minmax won't shrink it and the grid overflows. Fix that with min-width: 0 on the grid children and overflow-wrap: break-word on the text.

A check for this section: resize the browser from mobile width to ultra-wide. Reflow should be continuous, not a set of abrupt jumps at breakpoints—if it's jumpy, your grid or spacing scale is fighting the viewport.

Set a typography and color system that survives edits

Type and color are the two systems most likely to be tweaked after launch, so build them for easy adjustment.

Typography. Choose one or two typefaces with distinct roles (body and heading are common), scale sizes with a consistent ratio, and keep line lengths readable—roughly 45–75 characters per line for body text. A modular scale with a 1.25 ratio from a 16px base yields sizes near 16, 20, 25, 31, 39, and 49 pixels. Set relative units (rem) so users who change browser font size get a proportionate result. The most common failure is fixed line heights that clip or crowd larger headings; set line-height per size family, tight for headings and around 1.5 for body copy.

Color and contrast. Pick a text color with strong contrast against its background, a brand color for actions, and a small set of neutral grays. Color contrast ratios are defined by WCAG: normal body text needs at least 4.5:1 against its background, and large text at least 3:1 in the standard levels. Use a contrast checker before you commit a palette, especially for text on brand-colored buttons. A quick audit: spot-check your default and hover states for buttons, links, and disabled controls—disabled states that look pretty but read at 2:1 contrast are a common accessibility miss.

Write component styles, then prove they survive reuse

Component styles cover discrete, reusable pieces: buttons, cards, form fields, navigation, badges. Two habits make those styles reliable.

Prefer low specificity and single-class selectors. .card beats .content .grid .card, and it doesn't break when the card moves elsewhere on the page. If you're nesting selectors deeply, that's usually a sign a component needs to accept a modifier class instead.

Style states deliberately. Buttons, links, and inputs all have hover, focus, active, disabled, loading, and (for inputs) invalid states. A component isn't finished until the focus state is visible—outline or a ring on :focus-visible—and the disabled state is clearly distinguishable. Hover-only affordances fail on touch devices, so never make a function accessible only on hover.

Test reuse before you scale. Build one card and one button, then actually place them in three contexts: a sidebar, a grid, and a full-width banner. If they break in any of those, fix the component now; the cost of remediation multiplies with every page that adopts the broken version.

Handle responsive behavior and real devices deliberately

Responsive design isn't a set of device sizes. It's a set of content breakpoints where the layout stops working, and styles that adjust there. Work mobile-first: write the base styles for narrow screens and add complexity in min-width media queries. That order keeps the small-screen stylesheet honest and usually produces less override code.

Breakpoints vary by project; common choices cluster around 40–48rem for small-tablet widths, 64rem for desktop, and higher for wide layouts. Verify by resizing the viewport in developer tools, not by emulating a specific phone model. Then confirm on at least one actual device—touch, zoom, and mobile browser UI change how your layout behaves in ways a desktop emulator doesn't reproduce.

Two checks catch most responsive bugs: text should never overflow its container at any width from roughly 320px up, and touch targets should be large enough to hit comfortably—around 44 by 44 pixels is the widely used minimum.

Test, audit, and maintain the stylesheet

A stylesheet is finished only when it's been verified and has an owner.

1: Check the cascade and specificity. Use browser developer tools to inspect computed styles on the components you built; look for rules that are overridden unintentionally. 2: Run a contrast audit on text and interactive elements, including hover and disabled states. 3: Keyboard-test navigation. Tab through the page and confirm focus is visible and order is logical. 4: Check fragmenting and pagination behavior of any print styles, if the site offers printing. 5: Watch file size and unused rules. Unused CSS doesn't break a page, but it makes future changes slower and riskier. Periodically compare the rules your pages actually use against what's in the stylesheet.

For maintenance, keep the token layer separate from component rules so a redesign changes tokens rather than rewriting pages. When you do need to change a shared rule, check every component that consumes it before shipping; CSS failures are usually cross-component, not local.

Stop condition: if you're changing shared layout primitives or a vendor framework's internals to fix one page, pause. That's a signal the system needs a deliberate revision, not a spot patch. Take it to whoever owns the design system or site infrastructure before continuing, rather than layering more overrides on top.

A worked example: a three-component page

To see the pieces together, take a simple homepage with a header, a three-card grid, and a call-to-action button. The plan: one container width, rem spacing scale, four-color palette (text, background, brand, neutral border), one typeface.

The CSS touches each layer once:

Tokens sit in :root, and the container uses min() for responsive width. The header is a Flexbox row that wraps on narrow screens. The card grid uses auto-fit with a 16rem minimum, so it's two columns at tablet width and three on desktop without any breakpoints at all. The button uses the brand token, a single class, and visible :focus-visible and :hover states. One media query handles nav collapse.

Total: roughly 50–70 lines. The same page written ad hoc usually runs into hundreds of lines with repeated colors and near-identical card rules. The estimate is illustrative, not measured from a specific project, but the shape holds: the plan pays for itself on the first page and keeps paying through every page after.

Reference date and what to verify locally

As of this November 2026 writing, the stable principles—custom properties, Grid and Flexbox, mobile-first media queries, low-specificity selectors—apply across current evergreen browsers. Feature availability can shift with releases, so confirm any newer technique (container queries, nesting, :has()) against current browser support documentation for the browsers you're targeting. Breakpoints, spacing scales, and the 45–75 character measure are conventions, not fixed rules; adapt them to your typefaces and audience, then test against real content.

Frequently asked questions

Should I use a CSS framework or handwrite the CSS? A framework gives you working components quickly and a built-in convention; handwriting gives you full control and less unused CSS. The deciding factor is team maintenance: if multiple people will edit the styles for years and the project is large, the framework's shared conventions usually pay off. For small, design-forward sites, a tokens-plus-components approach like the one above is often leaner.

How many breakpoints does a site need? As many as its content needs and no more. Many sites work with two to four; adding breakpoints speculatively adds maintenance without fixing a real problem. Find the widths where your layout visibly breaks, and add a rule there.

Why does my CSS override not take effect? Almost always specificity or source order. A more specific selector, an inline style, or a later rule with equal specificity wins. The developer tools show which rule applies and which is crossed out; fix the competing selector rather than adding !important.