The web seems like it was deliberately designed to make any form of composability impossible. It’s one of the worst things about it as a platform.
I’m sure some purist argument has driven this somewhere.
I look back longingly at the promise of XML services in the early days of Web 2.0. Before the term just meant JavaScript everywhere.
All sorts of data could be linked together to display or remix by user agents.
I think of all the “hygienic macro” sorts of problems. You really ought to be able to transclude a chunk of HTML and the associated CSS into another document but you have to watch out for ‘id’ being unique never mind the same names being used for CSS classes. Figuring out the rendering intent for CSS could also be complicated: the guest CSS might be written like
Where the container is basically the whole guest document but you still want those rules to apply…. Maybe, you want the guest text to appear in the same font as the host document but you still want colors and font weights to apply. Maybe you want to make the colors muted to be consistent with the host document, maybe the background of the host document is different and the guest text isn’t contrasts enough anymore, etc.