CSS White Space
The white-space
property in CSS controls how white space within an element is handled, such as spaces, tabs, and line breaks.
Basic Usage of the white-space
Property
The white-space
property can take several values:
white-space: normal;
: Default behavior, sequences of spaces and tabs are collapsed to a single space. Line breaks wrap content as necessary.white-space: nowrap;
: Collapses white space as innormal
, but does not allow line breaks.white-space: pre;
: Preserves white space formatting exactly as in the HTML code.white-space: pre-wrap;
: Preserves white space and allows wrapping.white-space: pre-line;
: Collapses multiple spaces into a single space, but preserves line breaks.