Solution 1 :

  • Because they may still hold visible child nodes:
.no-height {
  height: 0;
};
.absolute {
  position: absolute;
}
<div class="no-height">
  <p class="absolute">still here</p>
</div>
  • Because they still can have borders or margins which could be visible
.no-height {
  height: 0;
  border: 5px solid;
  margin: 120px;
};
<div class="no-height">
</div>
I should be at top
  • Because they could have some influence on other visible nodes:
.no-height {
  height: 0;
};
<div>
  some inline<div class="no-height"></div>text
</div>

Problem :

In the context of a web browser, the Render Tree only has elements that will be visible on the webpage. So elements with display: none won’t make it to the render tree. But I understand that elements like those with height: 0 and position : absolute; left: 100% are included in the render tree, even though they won’t be visible on the webpage when rendered. So why are such elements still included in the render tree?

By