Source code
Revision control
Copy as Markdown
Other Tools
Test Info:
- This WPT test may be referenced by the following Test IDs:
- /css/CSS2/box-display/block-in-inline-zero-height-margin-collapse.html - WPT Dashboard Interop Dashboard
<!DOCTYPE html>
<title>CSS Test: empty block-in-inline collapses through its own margins</title>
<link rel="match" href="block-in-inline-zero-height-margin-collapse-ref.html">
<link rel="stylesheet" type="text/css" href="/fonts/ahem.css">
<meta name="assert" content="A zero-height block-in-inline with margin-top and margin-bottom has its top and bottom margins adjoin and collapse together.">
<style>
.container { width: 100px; font: 20px/1 Ahem; }
.before { width: 100px; height: 20px; background: green; }
.empty { width: 100px; height: 0; margin-top: 30px; margin-bottom: 40px; background: red; }
.after { width: 100px; height: 20px; background: green; }
</style>
<p>Two green squares with a 40px gap; no red.</p>
<div class="container">
<div class="before"></div>
<span><div class="empty"></div></span>
<div class="after"></div>
</div>