| <!DOCTYPE html> |
| <!-- |
| | Bottom margin of a last in-flow child and bottom margin of its parent margins |
| | are not adjoining if the parent has computed height other than "auto", |
| | and thus they do not collapse. |
| | https://www.w3.org/TR/CSS21/box.html#collapsing-margins |
| --> |
| <html> |
| <head> |
| <style> |
| .outer-green { |
| background-color: #00e676; |
| margin-bottom: 10px; |
| height: 100px; /* This line prevents margin collapsing. */ |
| } |
| .inner-green { |
| background-color: #00c853; |
| height: 100px; |
| margin-bottom: 100px; |
| width: 100px; |
| } |
| .outer-blue { |
| background-color: #03a9f4; |
| height: 100px; |
| width: 100px; |
| } |
| </style> |
| </head> |
| <body> |
| <div class="outer-green"> |
| <div class="inner-green"></div> |
| </div> |
| <div class="outer-blue"></div> |
| </body> |
| </html> |