Skip to content

feat: give <strong> and <b> one weight, wherever they land - #62

Closed
moufmouf wants to merge 1 commit into
mainfrom
feat/strong-one-weight
Closed

moufmouf wants to merge 1 commit into
mainfrom
feat/strong-one-weight

Conversation

@moufmouf

Copy link
Copy Markdown
Contributor

What

b, strong { @apply font-bold } in @layer base, next to the h1–h6 weight rule it mirrors. One line of CSS; the rest of the diff is the comment explaining it.

Conventional-commit feat:, so release-please cuts this as 3.1.0.

Why

Preflight sets b, strong { font-weight: bolder }, and bolder is not a weight — it is a step relative to the parent. The same tag therefore renders as three different things depending on what it sits in. Measured in example/ on 3.0.4, not inferred:

context 3.0.4 with this PR
<p> (400) 700 700
.light (300) 400 — no emphasis at all 700
<h1> / <h2> (700) 900 700
inside a link 700, link colour 700, link colour

The 400 row is the one that matters: inside light text a <strong> is indistinguishable from the prose around it, which is the one thing the tag exists to prevent.

How

Same fix, same reasoning, as the h1..h6 { @apply font-bold } rule directly above it — preflight took something the browser default used to give, and it goes back explicitly. That rule's comment already tells this story for headings; this is the same story one element down.

Two deliberate choices, both inherited from that rule:

  • Element selectors only. .bold is already the class for "make this bold", and consumers apply it on purpose; bolding classes here would change their meaning.
  • Colour is not set. <strong> marks importance, not interactivity — --secondary is what buttons and links are, and a reader who sees brand colour should be able to click it. So a <strong> takes the colour of the text around it, including inside a link, where it keeps the link's.

Where this came from

The marketing site (workadventure/website-migration) was carrying three different <strong> renderings, one per page family, each a faithful port of a different WordPress template — one of them blue and not bold. It has just been unified to bold-and-uncoloured with the design team (workadventure/website-migration#122), using a site-local rule that is really this one. It belongs here: the DS already asserts it piecemeal in components/features.css (.feature-content-title { strong, b { @apply font-bold } }), and @layer base already styles bare elements (*, html, body, h1–h6).

Once this ships, the site drops its local rule and depends on 3.1.0.

Verification

  • npm run build:example clean.
  • In the compiled CSS, Tailwind merges the selector into the existing heading rule — h1,h2,h3,h4,h5,h6,b,strong{font-weight:700} — emitted after preflight's b,strong{font-weight:bolder} in the same layer, so it wins on order at equal specificity. Net cost is essentially zero bytes.
  • Measured in the running example/ app before and after, across <p>, .light, .bold, <h1>, <h2>, inside a link, and for <b>: 700 in every case, colour inherited in every case.
  • Later layers still win as they should: a consumer's prose/component rule that draws its own <strong> is unaffected (this is why the site can keep @tailwindcss/typography's own bold treatment untouched).

Possible follow-up, not in this PR

components/features.css has .feature-content-title { strong, b { @apply font-bold } }, which this rule makes redundant — same value, later layer. Left alone deliberately to keep this diff to one behavioural change; happy to remove it here if you'd rather.

🤖 Generated with Claude Code

Preflight sets `b, strong { font-weight: bolder }`, and `bolder` is not a
weight — it is a step relative to the parent. So the same tag renders as three
different things depending on what it sits in. Measured in example/ on 3.0.4:

  <p> (400)          strong renders 700
  .light (300)       strong renders 400  ← no emphasis at all
  h1 / h2 (700)      strong renders 900

The 400 case is the one that matters: inside light text a <strong> is
indistinguishable from the prose around it, which is the one thing the tag
exists to prevent.

Restore an absolute weight, the same fix and the same reasoning as the
`h1..h6 { font-bold }` rule this sits next to — preflight took something the
browser default gave, and it goes back explicitly. Element selectors only, for
that rule's reason: `.bold` is already the class for "make this bold" and
consumers use it deliberately.

Colour is deliberately not set. <strong> marks importance, not interactivity;
--secondary is what buttons and links are. A <strong> keeps the colour of the
text around it, including inside a link, where it keeps the link's.

After, in example/: 700 in all three contexts above, plus inside a link, inside
.bold, and for <b>; colour inherited in every case.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@moufmouf

Copy link
Copy Markdown
Contributor Author

A design question worth answering explicitly before this merges, raised by @dan on the consumer side: shouldn't .light keep things lighter, semantically?

It is a fair reading — .light declares "this block is light", and an absolute 700 overrides that intent for the emphasised run. The argument for keeping it absolute anyway:

  • CSS's only relative mechanism is bolder, which is what this PR removes. It gives 400 in a 300 parent (no emphasis) and 900 in a heading. There is no "one visible step up" to reach for.
  • Where this design language actually made the choice, it chose 700 inside 300 text. The pricing page's feature headings pair a 300 word with a 700 one on the same line — "BASECONFIGURATION" — shipped on the live site and ported verbatim from the WordPress theme. That is a designer's answer to exactly this question, and it reads well.
  • The cases where light text currently "stays lighter" are not decisions. They are bolder falling flat, and they look like missing emphasis rather than restrained emphasis.
  • "Emphasis is subtler in light-toned blocks" is a legitimate idea, but it wants an explicit named class, not implicit inheritance. Implicit context-dependence is what produces three renderings from one tag; .light / .bold already establish the explicit pattern in this file.

If the team prefers the other answer, the shape would be .light :is(b, strong) { @apply font-medium } or similar on top of this rule — happy to add it here. I would rather it be a deliberate, named exception than the default, which is why it is not in this PR.

One real consumer impact, for the record: on the marketing site this rule bolds 22 testimonial lead sentences that were rendering at 400 inside a font-light blockquote. That is the intended fix, but it is the loudest instance of it, and it is flagged for a design read in workadventure/website-migration#122.

@moufmouf moufmouf closed this Aug 28, 2026
@moufmouf

Copy link
Copy Markdown
Contributor Author

Update on the consumer side, so this PR's "Where this came from" section is not read as more settled than it is.

The marketing site has landed its own pass (workadventure/website-migration#122), and it went a different way than that section describes: it fixed the blue-vs-bold split by deletion — dropping the blue rule and letting preflight's bolder render those font-normal headings at 700 — rather than by keeping a site-wide rule. The site-local b, strong { font-weight: 700 } was tried and then removed.

That does not weaken the case for this PR, but it changes what adopting it will do, and the DS reviewer should know:

  • This is still fixing a real DS defect, independent of any consumer. Measured in example/ on 3.0.4: a <strong> renders 400 inside .light and 900 inside an h1/h2. Neither is a decision anyone made.
  • Adopting 3.1.0 on the site will add behaviour, not just centralise it. The site has 22 testimonial lead sentences inside a font-light (300) blockquote that currently render at 400, deliberately — a site-wide rule bolded them, and that was judged too loud for a 24px pull-quote opener. This rule will bold them again. That is a fine outcome if the DS's answer is "bold is bold", but it should be a conscious adoption on the site's side, not a surprise in a patch bump.
  • The site's .pricing-page … h2 strong { 700 } becomes redundant on adoption.

Both are flagged on the site side (finding 144 in docs/editorial-findings.md), so whoever does the upgrade re-checks them.

The .light design question further up this thread is the same question in a different hat, and it is worth settling here before this merges, since this repo is where the answer will live.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant