Tailwind CSS Display

The tailwind display utility class allows you to control the display behavior of elements. With Tailwind's display class, you can easily modify how elements are rendered and positioned within the document flow.

Applying Tailwind Display

To apply a specific tailwind display behavior to an element, you can use the display-{value} utility class, where {value} represents the desired display behavior. Here are the common values you can use:

  • display-block: Renders the element as a block-level element, taking up the entire width of its parent container.
  • display-inline: Renders the element as an inline-level element, allowing other elements to flow around it.
  • display-inline-block: Renders the element as an inline-level block, allowing other elements to flow around it while also respecting its width and height.
  • display-hidden: Hides the element from the layout, making it effectively invisible and not taking up any space. Here's an example:
html
<div>
<p class="block">A</p>
<p class="block">B</p>
<p class="block">C</p>
<p class="block">D</p>
</div>

Preview

A

B

C

D

Responsive Tailwind Display

Tailwind CSS allows you to apply display classes responsively at different breakpoints. To use responsive tailwind display classes, you can append the breakpoint prefix to the utility class. For example, md:display-inlinesets the display behavior to inline starting from the medium breakpoint and above.

html
<div class="display-inline md:display-block">
This element is initially rendered as an inline-level element, but starting from the medium
breakpoint and above, it becomes a block-level element.
</div>

In the above example, the display behavior of the <div> element is set to inline by default (display-inline), but starting from the medium breakpoint and above, it changes to block-level (md:display-block).

Tailwind Display Class Table

ClassProperties
blockdisplay: block;
inline-blockdisplay: inline-block;
inlinedisplay: inline;
flexdisplay: flex;
inline-flexdisplay: inline-flex;
tabledisplay: table;
table-captiondisplay: table-caption;
table-celldisplay: table-cell;
table-columndisplay: table-column;
table-column-groupdisplay: table-column-group;
table-footer-groupdisplay: table-footer-group;
table-header-groupdisplay: table-header-group;
table-row-groupdisplay: table-row-group;
table-rowdisplay: table-row;
flow-rootdisplay: flow-root;
griddisplay: grid;
inline-griddisplay: inline-grid;
contentsdisplay: contents;
hiddendisplay: none;

Windframe Tailwind blocks

Logo

Build modern projects using Bootstrap 5 and Contrast

Trying to create components and pages for a web app or website from scratch while maintaining a modern User interface can be very tedious. This is why we created Contrast, to help drastically reduce the amount of time we spend doing that. so we can focus on building some other aspects of the project.

Contrast Bootstrap PRO consists of a Premium UI Kit Library featuring over 10000+ component variants. Which even comes bundled together with its own admin template comprising of 5 admin dashboards and 23+ additional admin and multipurpose pages for building almost any type of website or web app.
See a demo and learn more about Contrast Bootstrap Pro by clicking here.

ad-banner