Whitespace

Utilities for controlling an element's white-space property


Class reference

ClassProperties
whitespace-normalwhite-space: normal;
whitespace-nowrapwhite-space: nowrap;
whitespace-prewhite-space: pre;
whitespace-pre-linewhite-space: pre-line;
whitespace-pre-wrapwhite-space: pre-wrap;

# Normal

Use .whitespace-normal to cause text to wrap normally within an element. Newlines and spaces will be collapsed.

Lorem ipsum dolor sit amet, consectetur adipisicing elit. Omnis quidem itaque beatae, rem tenetur quia iure, eum natus enim maxime laudantium quibusdam illo nihil,

reprehenderit saepe quam aliquid odio accusamus.

<div class="w-3/4 ...">
<div class="whitespace-normal ...">Lorem ipsum dolor sit amet, consectetur adipisicing elit. Omnis quidem itaque beatae, rem tenetur quia iure,
eum natus enim maxime
laudantium quibusdam illo nihil,

reprehenderit saepe quam aliquid odio accusamus.</div>

# No Wrap

Use .whitespace-nowrap to prevent text from wrapping within an element. Newlines and spaces will be collapsed.

Lorem ipsum dolor sit amet, consectetur adipisicing elit. Omnis quidem itaque beatae, rem tenetur quia iure, eum natus enim maxime laudantium quibusdam illo nihil,

reprehenderit saepe quam aliquid odio accusamus.

<div class="w-3/4 overflow-x-auto ...">
<div class="whitespace-nowrap ...">Lorem ipsum dolor sit amet, consectetur adipisicing elit. Omnis quidem itaque beatae, rem tenetur quia iure,
eum natus enim maxime
laudantium quibusdam illo nihil,

reprehenderit saepe quam aliquid odio accusamus.</div>

# Pre

Use .whitespace-pre to preserve newlines and spaces within an element. Text will not be wrapped.

Lorem ipsum dolor sit amet, consectetur adipisicing elit. Omnis quidem itaque beatae, rem tenetur quia iure, eum natus enim maxime laudantium quibusdam illo nihil,

reprehenderit saepe quam aliquid odio accusamus.

<div class="w-3/4 overflow-x-auto ...">
<div class="whitespace-pre ...">Lorem ipsum dolor sit amet, consectetur adipisicing elit. Omnis quidem itaque beatae, rem tenetur quia iure,
eum natus enim maxime
laudantium quibusdam illo nihil,

reprehenderit saepe quam aliquid odio accusamus.</div>

# Pre Line

Use .whitespace-pre-line to preserve newlines but not spaces within an element. Text will be wrapped normally.

Lorem ipsum dolor sit amet, consectetur adipisicing elit. Omnis quidem itaque beatae, rem tenetur quia iure, eum natus enim maxime laudantium quibusdam illo nihil,

reprehenderit saepe quam aliquid odio accusamus.

<div class="w-3/4 ...">
<div class="**whitespace-pre-line** ...">Lorem ipsum dolor sit amet, consectetur adipisicing elit. Omnis quidem itaque beatae, rem tenetur quia iure,
eum natus enim maxime
laudantium quibusdam illo nihil,

reprehenderit saepe quam aliquid odio accusamus.</div>

# Pre Wrap

Use .whitespace-pre-wrap to preserve newlines and spaces within an element. Text will be wrapped normally.

Lorem ipsum dolor sit amet, consectetur adipisicing elit. Omnis quidem itaque beatae, rem tenetur quia iure, eum natus enim maxime laudantium quibusdam illo nihil,

reprehenderit saepe quam aliquid odio accusamus.

<div class="w-3/4 ...">
<div class="**whitespace-pre-wrap** ...">Lorem ipsum dolor sit amet, consectetur adipisicing elit. Omnis quidem itaque beatae, rem tenetur quia iure,
eum natus enim maxime
laudantium quibusdam illo nihil,

reprehenderit saepe quam aliquid odio accusamus.</div>

# Responsive

To control the whitespace property of an element only at a specific breakpoint, add a {screen}: prefix to any existing whitespace utility. For example, adding the class md:whitespace-pre to an element would apply the whitespace-pre utility at medium screen sizes and above.

<div class="whitespace-normal **md:whitespace-pre** ...">
<!-- ... -->
</div>

For more information about Elements’ responsive design features, check out the Responsive Design documentation.