Ptree: Interactive Tree of Life Explorer Blog & articles

Blog · Frontend · · 2 min read

Against BEM and component wrappers

Front-end engineering spent the last fifteen years treating the CSS cascade like a toxic spill that had to be contained inside isolated components, shadow trees, CSS-in-JS hashes, and BEM naming schemes (card__header--highlighted). Every one of those tools exists to solve one organizational problem: keeping a large team of developers from accidentally breaking each other's styles.

If you are not trying to protect forty strangers from each other, neutralizing the cascade throws away the most powerful part of the browser.

BEM destroys algebra

A BEM class name fuses an element's container, its role, and its state into one opaque token. That forces you to restate every shared relationship over and over, and it makes composition impossible.

In Ptree, classes compose algebraically. A segmented toolbar control is not .toolbar__button--first-selected; it is <input class="Raised Start"> whose checked state inherits from one global rule (input.Raised:checked + :is(label, button)). A tile is .tile, an expandable tile adds .expandable, a leaving element adds .leaving, and a shared container toggles .Common, .Filtering, or .Colored.

Every class owns a rule of its own:

  • A class with no CSS rule is dead weight and gets deleted.
  • A class whose only job is to undo another rule means the first rule was scoped too broadly. Fix the scope instead of layering a patch on top.
  • A state that already exists natively (:checked, aria-busy, aria-expanded, aria-current) never gets a parallel class or data-* mirror beside it.

Because rules are global and algebraic, a new view or a new property inherits the whole visual grammar (focus rings, selection borders, extinct daggers, common-name staggered fades, and print layout) without copying a single component stylesheet.

Wrapper divs are structural noise

Component frameworks normalize wrapping every two elements in three nested <div>s so each component has its own box, props boundary, and styling scope. Those wrappers are not free. They break CSS Grid and Subgrid alignment, hide parent-child semantics from sibling selectors, bloat the DOM across thousands of tree nodes, and force JavaScript to coordinate what CSS could have inherited directly.

Flat, semantically truthful markup carries more information in fewer nodes. Ptree's categorical legend is one <dl> of <dt> cells; its property menu is one <menu> of <input> + <li> pairs; its tree view is one <div class="plane"> holding <svg> and <ul> layers. When a divider bar is needed between two facets of a multi-question legend (like Ontogeny's three axes), the legend does not wrap each facet in a grouping <div>. The first cell of each facet publishes an anchor-name, and <dl> draws the dividing bars with ::before and ::after.

Deletion as proof

Earlier in Ptree's development, the property legend had its own JavaScript subsystem rebuilding legend DOM whenever you switched properties or hovered taxa. Deleting that dynamic-legend subsystem and replacing it with permanent HTML keys plus registered @property custom properties made the legend faster, smoother, and more capable. Continuous morphing, hover-peeking, and range filtering came straight from the cascade.

Once you use the cascade as a global compute engine instead of fighting it, most of the component machinery modern front-end recommends has nothing left to do.