Hi, I'm @squidfunk

- 10+ years of debugging and fixing broken layouts
- I love to build products front to back
- I'm on the quest of solving cross browser layout
- I'm actively researching (i.e. deconstructing) CSS
by Martin Donath, @squidfunk
What resources (space and time) are necessary to solve a problem?
If computational complexity increases,
performance decreases
How difficult is the code to read and understand?
If cognitive complexity increases,
productivity decreases
What resources (space and time) are necessary to solve a problem?
If computational complexity increases,
performance decreases
How difficult is the code to read and understand?
If cognitive complexity increases,
productivity decreases
What's the background and text color of the first link?
The elements (i.e. subtrees) a rule applies to
/* All links */
a { ... }
/* All external links */
a.ext { ... }
/* All external header links */
header a.ext { ... }
The ordering of rules, in case multiple rules match an element
The weight of a rule given by a tuple, e.g. [0, 0, 1, 1]
The weight of a rule given by a tuple, e.g. [0, 0, 1, 1]
/* Specificity: [0, 0, 1, 3] */
nav a:hover::before { ... }
/* Specificity: [0, 1, 1, 2] */
ul#primary-nav li.active { ... }
Try the specificity calculator at specificity.keegan.st
A rule expresses scope and precedence at the same time
/* Large scope, low precedence */
a { ... }
/* Medium scope, medium precedence */
a.ext { ... }
/* Small scope, high precedence */
header a.ext { ... }
What's the background and text color of the first link?
Maximum number of matched selectors per element
Other factors that add to cognitive complexity
BEM, OOCSS, SMACSS, Atomic CSS, ...
Web Components, CSS Modules (CSS-in-JS)
Analyse statistical properties of styles (#, avg, min, max)
Try the static code analyser at projectwallace.com
Analyse statistical properties of styles (#, avg, min, max)
Visualise precedence (location and specificity)
a { ... }
header a { ... }
nav ul a { ... }
header ul li a { ... }
a.ext { ... }
nav a.ext { ... }
a.ext:visited { ... }
#home header a { ... }
How the specificity graph should look
Visualise precedence (location and specificity)
a { ... }
a.ext { ... }
a.ext:visited { ... }
header a { ... }
#home header a { ... }
header ul li a { ... }
nav ul a { ... }
nav a.ext { ... }
How the specificity graph actually looks
Visualise precedence (location and specificity)
a { ... }
a.ext { ... }
a.ext:visited { ... }
header a { ... }
#home header a { ... }
header ul li a { ... }
nav ul a { ... }
nav a.ext { ... }
How the specificity graph for a component architecture looks
Visualise element-selector relations
Visualise dependencies between selectors
Managing cognitive complexity strategically is crucial
visit ginseng.ai to stay updated