CSS - white-space
The white-space property is used to alter the user agent's handling of whitespace in an element.
normal − Any sequence of whitespaces within the element is converted to a single space.
pre − All whitespace in the element is honored, including multiple spaces and carriage returns.
nowrap − Any sequence of whitespaces within the element is converted to a single space, but word wrapping is disabled.
All the Block level elements.
object.style.whiteSpace = "pre";
Following is the example which demonstrates how white space inside an element is handled.Live Demo
<html> <head> </head> <body> <p style = "white-space:pre;"> This text has a line break and the white-space pre setting tells the browser to honor it just like the HTML pre tag. </p> </body> </html>
This will produce following result −