JSFiddle - React, Tailwind, and code Playground
HTML
<p><code>display: table</code> tells the element to display as a table. Nested elements should be displayed as <code>table-row</code> and <code>table-cell</code>, mimicking the good old TRs and TDs.</p>
<div class="example">Live examples:
<br />This example has divs with display: table, table-row, and table-cell, all properly nested.
<div class="first table">display: table
<div class="second row">display: table-row
<div class="third cell">display: table-cell and some more content</div>
<div class="third cell">display: table-cell</div>
</div>
<div class="second row">display: table-row
<div class="third cell">display: table-cell</div>
<div class="third cell">display: table-cell</div>
</div>
</div>The outermost div of this example has display: block, and not table.
<div class="first">display: block
<div class="second row">display: table-row
<div class="third cell">display: table-cell and some more content</div>
<div class="third cell">display: table-cell</div>
</div>
<div class="second row">display: table-row
<div class="third cell">display: table-cell</div>
<div class="third cell">display: table-cell</div>
</div>
</div>This example has no divs with display: table-row
<div class="first table">display: table
<div class="third cell">display: table-cell and some more content</div>
<div class="third cell">display: table-cell</div>
</div>
</div>
CSS
div.example {
width: 25em;
border: 5px double;
padding: 5px;
}
div.example div {
margin: 0.5em;
padding: 0.5em;
}
.first {
border: 1px solid #cc0000;
}
.second {
border: 1px solid #00cc00;
}
.third {
border: 1px solid #0000cc;
}
.table {
display: table;
}
.row {
display: table-row;
}
.cell {
display: table-cell;
}