Engineering Journal
Pdf Processor
Pdf Processor

Hot Take: CSS Specificity Is Not a Bug. It's a Design Constraint You Ignored

2026-06-04

TLDR

CSS specificity collisions (like a utility class overriding display: none on inactive tabs) are not browser cascade bugs. They are ownership architecture flaws where multiple CSS rules compete to set display on an element without clear property ownership boundaries. A layout helper class should set layout properties (flex-direction, gap), while tab visibility systems strictly own display.
CSS Property OwnershipResponsible SystemScope of RuleAllowed CSS Declarations
Visibility Property (display)Tab Component System.view-panel / .view-panel.activedisplay: none / display: flex
Layout Direction PropertyLayout Helper Class.view-panel.diff-layoutflex-direction: column, gap: 8px

Problem statement: the ambiguity of display ownership

Developers frequently add layout utilities that mix display and directional rules:

/ DEFECTIVE: Utility class claims ownership over display property /
.diff-layout {
  display: flex;
  flex-direction: column;
}

When applied to a tab container managed by a visibility system (.view-panel { display: none }), both rules attempt to set the display property. If .diff-layout appears later in the source stylesheet, it wins the cascade tie at equal specificity ((0, 1, 0)), forcing the tab to remain visible permanently.


Technical architecture: single property ownership discipline

Assign single property ownership to dedicated CSS rule types:

1. Visibility system rules (owns display))

.view-panel {
  display: none; / Only the tab system controls display: none /
}

.view-panel.active { display: flex; / Only active state toggle sets display: flex / }

2. Layout specialty rules (owns flex-direction,, gap,, align-items))

/ Compound selector elevates specificity to (0, 2, 0) and avoids setting display /
.view-panel.diff-layout {
  flex-direction: column;
  gap: 12px;
}

By removing display: flex from .diff-layout, the helper class no longer competes with the tab visibility engine.

Rule of thumb: Design CSS rule boundaries so that visibility systems exclusively own display properties, leaving layout helper classes to manage layout direction and spacing.
Read this post in the full Engineering Journal →