How I Rebranded 300+ Websites by Changing a Few CSS Values

By Julie Bam ·

I'm the sole developer behind more than 300 websites for financial advisors. Every advisor has their own branding: colours and fonts. For a long time, applying or changing that branding was slow, repetitive and easy to get wrong. Then I rebuilt our shared template around CSS design tokens, and a full rebrand became a matter of changing a few values. Here's how it works, and what I learned along the way.

The problem with hard-coded branding

Our template started the way most do: brand colours and fonts written directly into the CSS, wherever they were needed. The same hex code might appear in dozens of places, from buttons and links to headings and borders.

That worked fine when we had one consistent brand. But we started running into problems when the company I work for amalgamated with another dealer and we started onboarding independent advisors with their own brands. That brought three problems:

What design tokens are, in plain language

A design token is a named value that stands in for a design decision. Instead of writing a colour everywhere, you give it a name once and use the name everywhere else. In CSS, the simplest way to do this is with custom properties.

Before: the brand colour is repeated throughout the stylesheet.

.button { background: #0b4f8a; }
.nav a:hover { color: #0b4f8a; }
.card { border-top: 4px solid #0b4f8a; }

After: the colour is defined once as a token, and everything refers to it.

:root {
  --brand-primary: #0b4f8a;
}

.button { background: var(--brand-primary); }
.nav a:hover { color: var(--brand-primary); }
.card { border-top: 4px solid var(--brand-primary); }

Change --brand-primary and every button, link and border updates together.

How I set them up

1. Group the tokens. I organized tokens into a few clear groups so anyone could find what to change:

:root {
  /* Colour */
  --brand-primary: #0b4f8a;
  --brand-secondary: #f2a900;
  --text-on-primary: #ffffff;

  /* Type */
  --font-heading: "Georgia", serif;
  --font-body: "Helvetica Neue", Arial, sans-serif;

  /* Spacing */
  --space-sm: 0.5rem;
  --space-md: 1rem;
}

2. Override tokens per site. Each advisor's site overrides only the tokens that differ, in that advisor's own hub in the CMS:

/* advisor-smith.css */
:root {
  --brand-primary: #2e6b3f;
  --font-heading: "Merriweather", serif;
}

A new site's branding is now a handful of lines instead of a hunt through the whole stylesheet.

3. Replace the hard-coded values. The bulk of the work was going through the template and swapping every hard-coded colour, font and spacing value for its token.

The results

Bonus: tokens make accessibility easier

When colours live in one place, colour contrast can be checked in one place too. Before a new advisor's brand goes live, I check their token values against WCAG AA contrast requirements: at least 4.5:1 for normal text against its background. If a brand colour is too light for white text, I fix it once in the override file, for example by setting --text-on-primary to a dark colour, and every button and banner on that site is corrected.

Compare that with hard-coded styles, where the same fix means finding every place the colour is used.

Takeaways

If you manage more than a handful of sites from one template, design tokens are one of the highest-return refactors you can make.


I'm Julie Bam, a web specialist who runs large, accessible web estates. See more of my work at juliebam.com or connect with me on LinkedIn.