Examples
Display Block
.db { display: block; }
<span class="db"></span>
Block will inherently set width to 100% of its parent element. It will also cause a line break, even if the declared width doesn’t take up the full width of the parent.
block
block
Display Inline-Block
.dib { display: inline-block; }
<span class="dib"></span>
Inline-block will wrap around content inline. It also allows you to set
height and width properties on the element, which display inline does not allow
you to do. It does render the white-space inbeween elements, so if you set
width: 25% to four elements they will not just render as a 4 column layout by
default.
display: inline-block
display: inline-block
display: inline-block
display: inline-block
Display Inline
.di { display: inline; }
<div class="di"></div>
Set content inline. Inline doesn’t respect height or width values. It does not render white space between elements.
display: inline
display: inline
display: inline
display: inline
Display Table
.dt { display: table; }
.dtc { display: table-cell; }
<div class="dt">
<div class="dtc"></div>
<div class="dtc"></div>
</div>
The display table can be combined with display table-cell to render a table
without table markup. This can be useful for vertically aligning content
or for auto-calculating a variable number of table cells. To auto-calculate even
widths for all cells, you must extend display table with .dt--fixed
to set
table-layout: fixed.
display
table
will automatically
compute cell width
Display Table
<div class="dt dt--fixed w-100">
<div class="dtc"></div>
<div class="dtc"></div>
</div>
display table
with table-layout: fixed
will automatically
make every cell the same width regardless of the content
Display None
.dn { display: none; }
<div class="dn"></div>
You can set the display of any element to none by tacking on the dn
class.