monks/white_space
The white-space CSS property sets how {{Glossary(“whitespace”, “white space”)}} inside an element is handled.
Values
pub const normal: #(String, String)
- : Sequences of white space are collapsed. Newline characters in the source are handled the same as other white spaces. Lines are broken as necessary to fill line boxes. Equivalent to
collapse wrap.
pub const pre: #(String, String)
- : Sequences of white space are preserved. Lines are only broken at newline characters in the source and at {{HTMLElement(“br”)}} elements. Equivalent to
preserve nowrap.
pub const pre_line: #(String, String)
- : Sequences of white space are collapsed. Lines are broken at newline characters, at {{HTMLElement(“br”)}}, and as necessary to fill line boxes. Equivalent to
preserve-breaks wrap.> [!NOTE]> Thewhite-spaceproperty as a shorthand is a relatively new feature (see browser compatibility). Originally, it had six keyword values; now, the valuenowrapis instead interpreted as a value for {{cssxref(“text-wrap-mode”)}}, while the valuebreak-spacesis interpreted as a value for {{cssxref(“white-space-collapse”)}}. The above four keywords are still specific towhite-space, but they have longhand equivalents. The change to makewhite-spacea shorthand expands acceptable values to even more keywords and combinations, such aswrapandcollapse.The following table summarizes the behavior of these fourwhite-spacekeyword values:
A tab defaults to 8 spaces and can be configured using theNew lines Spaces and tabs Text wrapping End-of-line spaces End-of-line other space separators normalCollapse Collapse Wrap Remove Hang prePreserve Preserve No wrap Preserve No wrap pre-wrapPreserve Preserve Wrap Hang Hang pre-linePreserve Collapse Wrap Remove Hang tab-sizeproperty. In the case ofnormal,nowrap, andpre-linevalues, every tab is converted to a space (U+0020) character.> [!NOTE]> There is a distinction made between spaces and other space separators. These are defined as follows:>> - spaces> - : Spaces (U+0020), tabs (U+0009), and segment breaks (such as newlines).> - other space separators> - : All other space separators defined in Unicode, other than those already defined as spaces.>> Where white space is said to hang, this can affect the size of the box when measured for intrinsic sizing.
pub const pre_wrap: #(String, String)
- : Sequences of white space are preserved. Lines are broken at newline characters, at {{HTMLElement(“br”)}}, and as necessary to fill line boxes. Equivalent to
preserve wrap.
pub const preserve_breaks: #(String, String)
preserve-breaks value of white-space
pub const preserve_spaces: #(String, String)
preserve-spaces value of white-space
pub const revert_layer: #(String, String)
pub fn var(variable: String) -> #(String, String)
Enter a variable name to be used for white-space.
It will be wrapped in var() and have -- prepended.