4 ms·
CSS selectors were carefully designed to have simple and performant implementations, cleanly separated from properties they set, and initially to be looking str
by pornel 5y ago
CSS selectors were carefully designed to have simple and performant implementations, cleanly separated from properties they set, and initially to be looking strictly forward and deeper down the tree, so they can be applied in one pass.
The flow model that gave CSS reputation for being unable to center things vertically was also deliberate to allow rendering in one pass (which was the model of early web browsers before dynamic HTML). It’s notable that the slowest and messiest layout algorithm in CSS is tables, which predates CSS, and CSS tried to resist for a long time.
Parsing model of CSS is pretty nice too. It can be implemented with a simple recursive parser, and the forward-compatible error handling is relatively easy in such parser.
These properties may seem unremarkable, but often it takes just one cool feature to break them and cause complications down the line.