Skip to content

White Space

White space utilities set white-space. They decide whether text wraps, whether runs of spaces collapse, and whether line breaks in the source are honored.

Class white-space
white-space-normal normal
white-space-nowrap nowrap
white-space-pre pre
white-space-pre-line pre-line
white-space-pre-wrap pre-wrap
<code class="white-space-pre">keeps its spacing</code>
<p class="white-space-nowrap">A single line that will not wrap</p>

pre keeps every space and line break but does not wrap; pre-wrap keeps them and still wraps long lines. pre-line collapses spaces but honors line breaks.

<p class="white-space-nowrap white-space-lg-normal">One line until there is room</p>

Responsive: white-space-sm-nowrap … white-space-2xl-pre-wrap.

These classes are in the separate responsive module: import nightcss/utilities/responsive after the base bundle, or use nightcss/full.

  • Use nowrap on short labels and table cells, not on paragraphs. Long unbreakable text overflows its container.
  • pre is for code and preformatted text. On a page that also has prose, prefer pre-wrap so long lines do not force a horizontal scrollbar.
  • To clip a single line with an ellipsis, use Truncation instead of nowrap alone.