wpt / css / CSS2 / box-display / block-in-inline-zero-height-margin-collapse.html

Status: PASS | Duration: 9ms | Subtests: 1/1 | Open test on wpt.live | Open ref on wpt.live | wpt.fyi

/css/CSS2/box-display/block-in-inline-zero-height-margin-collapse.html

<!DOCTYPE html>
<title>CSS Test: empty block-in-inline collapses through its own margins</title>
<link rel="help" href="https://www.w3.org/TR/CSS21/visuren.html#anonymous-block-level">
<link rel="help" href="https://www.w3.org/TR/CSS21/box.html#collapsing-margins">
<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>

/css/CSS2/box-display/block-in-inline-zero-height-margin-collapse-ref.html

<!DOCTYPE html>
<title>CSS Reference</title>
<link rel="stylesheet" type="text/css" href="/fonts/ahem.css">
<style>
.container { width: 100px; font: 20px/1 Ahem; }
.before { width: 100px; height: 20px; background: green; }
.gap { width: 100px; height: 40px; background: white; }
.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>
    <div class="gap"></div>
    <div class="after"></div>
</div>