Can a Block Element Contain Another Block Element?

Started playing around with html yesterday and I now have a question.

Whats the reason why I can't have two block elements inside of each eachother?

9

1 Answer

yes a block element can contain another block element. The default display value for most elements is block or inline.

.parent-div{
  display:block;
  background:#000;
  width:100px;
  height:100px;
  overflow: hidden;
}
.child-div{
  display:block;
  width:50px;
  height:50px;
  background:#fff;
  margin-top:25px;
  margin-left:25px;
}
<div class="parent-div">
<div class="child-div">

</div>
</div>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Robert Thorne

Robert Thorne

Automotive & Future Transportation Editor

Robert Thorne covers electric vehicle innovations, autonomous driving systems, global mobility trends, and automotive engineering developments.

Share this article
Twitter Facebook Pinterest