Can a Block Element Contain Another Block Element?
Started Playing Around with Html Yesterday and I Now Have a Question. What's the Reason Why I Can't Have Two Block Elements Inside of Each Eachother? 9 1...
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?
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>