I have read on quite a few posts that DOM and CSSOM get constructed parallelly. CSS is render-blocking only because it prevents the render tree from being constructed. Now consider a case in which while parsing the HTML file, a link to an external style sheet gets encountered in the <head>
tag. The stylesheet starts downloading when it is encountered but the parsing of HTML continues. Consider that the downloading completed before the whole document is parsed, for instance, somewhere in the body
tag. For simplicity assume there are no script tags in the document.
Here are my doubts: a) Does the parsing of HTML continue along with parsing of CSS in the main thread? Or does the CSS parsing gets blocked until HTML's parsing is completed or vice-versa? b) Considering CSS parsing doesn't get blocked, how is it possible for the CSSOM to be constructed without a fully constructed DOM? Consider a style for a not yet parsed HTML element in the external stylesheet. How does the parser know where to put this node with its styles in CSSOM (how does it know who is the parent of that element in other words)?