White-space

Control how white-space and text wrapping inside an element is handled.

Syntax
      white-space: normal | nowrap | pre | pre-line | pre-wrap | inherit ;

normal - Sequences of whitespace will collapse into a single space character. Text will wrap when necessary. (default)
nowrap - Sequences of whitespace will collapse into a single space character. Text will not wrap unless a <br> tag is encountered.
pre - Whitespace is preserved by the browser (like the <pre> tag). Text will not wrap unless a <br> tag is encountered.
pre-line - Sequences of whitespace will collapse into a single space character. Text will wrap when necessary, and on line breaks.
pre-wrap - Whitespace is preserved by the browser. Text will wrap when necessary, and on line breaks
inherit - inherit from the parent element.

When applied to a floated element, white-space will not change the normal float behaviour, but will just prevent the whitespace characters within the float from wrapping.

Examples:
h1 { white-space: pre; }
.emw3class { white-space: nowrap; }

#emw3id { white-space: pre-wrap; }

Try it:

This text has been typed, with a number of extra consecutive spaces. By default these will collapsed into single spaces.

(CSS 1) Browser Support: All major browsers.

“Space, the final frontier. These are the voyages of the Starship Enterprise. Its five-year mission: to explore strange new worlds, to seek out new life and new civilizations, to boldly go where no man has gone before” ~ Gene Roddenberry (Star Trek)

Related:

text-align - Horizontal alignment of text.
text-overflow - What should happen when text overflows the containing element.
word-spacing - Increase or decrease the space between words in a text.


Copyright © 2013-2022 Emw3.com
Some rights reserved