> It sounds like you wanted a circular dependency: widths in CSS depend on parents' widths, not children's widths. (This is important for document layouts to work at all.)
But aren't there are HTML elements everywhere where the size is determined by their content --- trivially, the P element which is showing this text. Less trivially, I've just put an explicitly sized DIV inside an unsized inline-block DIV, and the outer one is definitely sized according to its child.
> I've seen these pure-JS layout engines, and they are invariably much slower than the browser's implementation.
> But aren't there are HTML elements everywhere where the size is determined by their content
The height is. Not the actual width. Remember, widths are computed top-down, while heights are computed bottom-up.
> Less trivially, I've just put an explicitly sized DIV inside an unsized inline-block DIV, and the outer one is definitely sized according to its child.
That's because inline-block uses intrinsic width (specifically, shrink to fit width), which is computed separately from actual width in a bottom-up pass. Intrinsic width is a weird thing that is kind of a hack, and an ill-specified one to boot (although a useful one). It doesn't fundamentally change the fact that widths depend on parents' widths only.
But aren't there are HTML elements everywhere where the size is determined by their content --- trivially, the P element which is showing this text. Less trivially, I've just put an explicitly sized DIV inside an unsized inline-block DIV, and the outer one is definitely sized according to its child.
> I've seen these pure-JS layout engines, and they are invariably much slower than the browser's implementation.
I think this is it: http://famous.org/
Although I can't find their blog post on performance. And I've never used it, of course.