<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/using-maths-to-balance-your-heading-styles-dlctwi54e" -->

---
title: Using maths to balance your heading styles | daily.dev
description: A practical CSS technique uses modular scales, rooted in music-theory ratios, to size six heading levels in a balanced, accessible way without relying on...
canonical: https://daily.dev/posts/using-maths-to-balance-your-heading-styles-dlctwi54e
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: Using maths to balance your heading styles | daily.dev
og:description: A practical CSS technique uses modular scales, rooted in music-theory ratios, to size six heading levels in a balanced, accessible way without relying on...
og:url: https://daily.dev/posts/using-maths-to-balance-your-heading-styles-dlctwi54e
og:image: https://api.daily.dev/og/posts/dLctWi54e.png
og:image:alt: Using maths to balance your heading styles
og:image:width: 1200
og:image:height: 630
og:locale: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Using maths to balance your heading styles

**[Craig Abbott](https://daily.dev/sources/craigabbott)** · 18 min read · 0 upvotes · 0 comments

## Summary

A practical CSS technique uses modular scales, rooted in music-theory ratios, to size six heading levels in a balanced, accessible way without relying on colour, italics, or block capitals (all of which cause accessibility issues). Font size, whitespace, and font weight are ranked as visual cues in that order, with CSS custom properties calculating spacing above and below headings using the 'lobotomized owl' selector and prose-flow technique. A tricky gap between h3 and h4 sizes is solved using the geometric mean, calculated in CSS via sqrt() (or alternatively pow() with an exponent of 0.5), giving a mathematically consistent half-step size anchored to the scale's ratio. Full CSS implementation and a live demo are included.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://www.craigabbott.co.uk/blog/2026/using-maths-to-balance-your-heading-styles>

## Questions this post answers

### How do I calculate a half step between two sizes on a modular scale in CSS?

Multiply the base size by the square root of the scale's ratio, using the CSS sqrt() function, for example calc(var(--s0) * sqrt(var(--ratio))). This finds the geometric mean, which is the mathematically correct midpoint on a multiplicative scale, unlike simply averaging two values which only works on additive scales. Equivalently, pow(var(--ratio), 0.5) produces the same result.

_daily.dev surfaces practical CSS techniques like this for developers refining heading hierarchies._

### Why shouldn't headings rely on color alone to look different from body text?

Color-only distinctions fail WCAG 1.4.1 Use of Color and disadvantage users with color vision deficiency. Additionally, Windows high contrast themes and browser forced-colors modes replace all text colors with a single system color, erasing any color-based difference entirely, so font size, spacing, and weight must carry the visual hierarchy instead.

_Developers building accessible design systems can track WCAG-driven CSS patterns via daily.dev._

### What CSS ratio should I use for a modular type scale?

A ratio of 1.5 works well because it also matches the recommended line-height for accessibility, keeping the whole system coherent; 1.618, the Golden Ratio, is another common option. The specific ratio matters less than consistency: as long as every size is calculated from the same ratio and base value, the result stays visually balanced.

_daily.dev helps developers compare type-scale ratios when designing consistent heading systems._

## Similar posts on daily.dev

- [Typographic Scales in CSS with :heading\(\), sibling-index\(\), and pow\(\)](https://daily.dev/posts/typographic-scales-in-css-with-heading-sibling-index-and-pow--1qgzcdtlc) · Always Twisted · 1 upvotes · 0 comments
- [Building Fluid Typographic Scales with clamp\(\) and :heading\(\)](https://daily.dev/posts/building-fluid-typographic-scales-with-clamp-and-heading--nxpmqzaqh) · Always Twisted · 0 upvotes · 0 comments
- [Setting type like a printed page](https://daily.dev/posts/setting-type-like-a-printed-page-z83t7dy2y) · Creative Design Technologist · 9 upvotes · 2 comments
- [Responsive Letter Spacing](https://daily.dev/posts/responsive-letter-spacing-zsikazax5) · Cloud Four · 0 upvotes · 0 comments
- [My CSS layout strategy](https://daily.dev/posts/my-css-layout-strategy-lfp48ynra) · Blogging and all that Malarkey · 49 upvotes · 2 comments

---

Tags: [#css](https://daily.dev/tags/css), [#ui-design](https://daily.dev/tags/ui-design), [#accessibility](https://daily.dev/tags/accessibility), [#typography](https://daily.dev/tags/typography)

[View this post on daily.dev](https://daily.dev/posts/using-maths-to-balance-your-heading-styles-dlctwi54e)

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://daily.dev/#organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180},"sameAs":["https://twitter.com/dailydotdev","https://github.com/dailydotdev","https://www.linkedin.com/company/daily-dev-ltd"]},{"@type":"WebSite","@id":"https://daily.dev/#website","url":"https://daily.dev","name":"daily.dev","publisher":{"@id":"https://daily.dev/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://daily.dev/search?q={search_term_string}"},"query-input":"required name=search_term_string"}}]}
{"@context":"https://schema.org","@type":"TechArticle","headline":"Using maths to balance your heading styles","url":"https://daily.dev/posts/using-maths-to-balance-your-heading-styles-dlctwi54e","mainEntityOfPage":{"@type":"WebPage","@id":"https://daily.dev/posts/using-maths-to-balance-your-heading-styles-dlctwi54e"},"datePublished":"2026-09-20T07:44:10.786Z","dateModified":"2026-09-20T07:48:58.964Z","description":"A practical CSS technique uses modular scales, rooted in music-theory ratios, to size six heading levels in a balanced, accessible way without relying on...","image":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/a0ffc407e6f6c1b75eadc5a3e5dc0325?_a=AQAEuop","thumbnailUrl":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/a0ffc407e6f6c1b75eadc5a3e5dc0325?_a=AQAEuop","isAccessibleForFree":true,"articleSection":"Craig Abbott","inLanguage":"en","publisher":{"@type":"Organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180}},"author":{"@type":"Organization","name":"Craig Abbott","logo":"https://media.daily.dev/image/upload/s--7L_KxzEH--/f_auto,q_auto/v1789890198/logos/craigabbott?_a=BAMAMicg0","url":"https://daily.dev/sources/craigabbott"},"commentCount":0,"discussionUrl":"https://daily.dev/posts/using-maths-to-balance-your-heading-styles-dlctwi54e","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":0},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":0}],"keywords":"css,ui-design,accessibility,typography","timeRequired":"PT18M"}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"Craig Abbott","item":"https://daily.dev/sources/craigabbott"},{"@type":"ListItem","position":3,"name":"Using maths to balance your heading styles"}]}
{"@context":"https://schema.org","@type":"FAQPage","@id":"https://daily.dev/posts/using-maths-to-balance-your-heading-styles-dlctwi54e#faq","mainEntity":[{"@type":"Question","name":"How do I calculate a half step between two sizes on a modular scale in CSS?","acceptedAnswer":{"@type":"Answer","text":"Multiply the base size by the square root of the scale's ratio, using the CSS sqrt() function, for example calc(var(--s0) * sqrt(var(--ratio))). This finds the geometric mean, which is the mathematically correct midpoint on a multiplicative scale, unlike simply averaging two values which only works on additive scales. Equivalently, pow(var(--ratio), 0.5) produces the same result. daily.dev surfaces practical CSS techniques like this for developers refining heading hierarchies."}},{"@type":"Question","name":"Why shouldn't headings rely on color alone to look different from body text?","acceptedAnswer":{"@type":"Answer","text":"Color-only distinctions fail WCAG 1.4.1 Use of Color and disadvantage users with color vision deficiency. Additionally, Windows high contrast themes and browser forced-colors modes replace all text colors with a single system color, erasing any color-based difference entirely, so font size, spacing, and weight must carry the visual hierarchy instead. Developers building accessible design systems can track WCAG-driven CSS patterns via daily.dev."}},{"@type":"Question","name":"What CSS ratio should I use for a modular type scale?","acceptedAnswer":{"@type":"Answer","text":"A ratio of 1.5 works well because it also matches the recommended line-height for accessibility, keeping the whole system coherent; 1.618, the Golden Ratio, is another common option. The specific ratio matters less than consistency: as long as every size is calculated from the same ratio and base value, the result stays visually balanced. daily.dev helps developers compare type-scale ratios when designing consistent heading systems."}}]}
```

