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.
Classes
Section titled “Classes”| 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.
Responsive white space
Section titled “Responsive white space”<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.
Guidance
Section titled “Guidance”- Use
nowrapon short labels and table cells, not on paragraphs. Long unbreakable text overflows its container. preis for code and preformatted text. On a page that also has prose, preferpre-wrapso long lines do not force a horizontal scrollbar.- To clip a single line with an ellipsis, use Truncation
instead of
nowrapalone.