The white-space shorthand controls how whitespace characters and line breaks are processed in text — whether to display multiple spaces, allow automatic line wrapping, and honor newlines in the source..code {
white-space: pre;
}.chat-msg {
white-space: pre-wrap;
}normalThe default value. Sequences of whitespace collapse, newlines treated as space, automatic line wrapping allowed.preLike HTML
— preserves whitespace and newlines from source, no automatic wrapping.
nowrapWhitespace collapses, but no line wrapping (creates overflow if text is long).pre-wrapPreserves whitespace and newlines, allows automatic wrapping.pre-lineWhitespace collapses, newlines preserved, wrapping allowed.break-spacesLike pre-wrap, but trailing whitespace can force a line break at the start of the next line.noneFrom white-space-collapse: all whitespace is removed entirely.discard-beforeFrom white-space-collapse: removes whitespace before each line break.discard-afterFrom white-space-collapse: removes whitespace after each line break.discard-innerFrom white-space-collapse: removes inner whitespace (not at line edges).wrapFrom text-wrap: allows automatic line wrapping (default).CSS Text Module Level 4Editor's DraftW3CMDNIn the beginning God created the heavens and the earth.
Now the earth was formless and empty, darkness was over the surface of the deep, and the Spirit of God was hovering over the waters.
And God said, “Let there be light,” and there was light.
Show all codeEdit CSS onlineThe plugin that remembers hundreds of CSS items for youEvery CSS property — in a live demonstrationThe bilingual CSS referencedefinitionexamplessyntaxmodulespecificationsourcesvisual demonstrationpreviousnext