Why sibbling div elements are rendered as children of one of them
-
13-11-2019 - |
Question
For some reason div elements change their parents during rendering in unexpected way, reproducible in Firefox and Chrome.
E.g.
<div class="main">
<div class="slot"/>
<div class="slot"/>
</div>
<div class="footer"></div>
Firefox debugger will show as this at runtime as:
<div class="main">
<div class="slot"><div class="slot"/></div></div>
<div class="footer"></div>
</div>
When I remove .slot elements(see the code attached), everything renders as expected(#footer place in tree after rendering is same as in the source).
Solution
The problem is that you use empty divs: like that
<div />
You should try to change your code to use valid divs with empty content:
<div></div>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow