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> <div> </div> </div>

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

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