Where do ::before and ::after sit in the flow?
Both pseudo-elements, ::before and ::after, are child elements of the selected node and by default sit inside the element, but outside its main text:
::beforeis inserted before the element's content::afteris inserted after the element's content
At the same time, they:
- participate in the flow as regular inline elements, unless
displayis changed - are not rendered without
content - can be turned into blocks, absolutely positioned, etc., if the corresponding properties are set
Summary: both pseudo-elements sit inside the element in the DOM flow, but around its main content: ::before before it, ::after after it.
Short Answer
Interview readyPremium
A concise answer to help you respond confidently on this topic during an interview.