Tell us what’s happening:
Describe your issue in detail here.
I do not understand the margin part, I think when we add top-margin:20px to the div class=“one”, this div one should be below the div class=“canvas” by 20px, but instead of that, the top margin of the div one is outside the div canvas. Can you explain to me why? Thank you.
Please create your own topic when you have specific questions about your own challenge code. Only respond to another thread when you want to provide help to the original poster of the other thread or have follow up questions concerning other replies given to the original poster.
The easiest way to create a topic for help with your own solution is to click the Ask for Help button located on each challenge. This will automatically import your code in a readable format and pull in the challenge url while still allowing you to ask any question about the challenge or your code.
Top-margin of .one element COLLAPSE with top-margin of .canvas element, which is called Collapsing margin.
Relevant explanation from the W3C spec:
8.3.1 Collapsing margins
In CSS, the adjoining margins of two or more boxes (which might or might not be siblings) can combine to form a single margin. Margins that combine this way are said to collapse, and the resulting combined margin is called a collapsed margin.
no line boxes, no clearance, no padding and no border separate them (Note that certain zero-height line boxes (see 9.4.2) are ignored for this purpose.)
both belong to vertically-adjacent box edges, i.e. form one of the following pairs:
top margin of a box and top margin of its first in-flow child
The left and right margins behave as you expect because: