White-space

Usually we use white-space property for the texts.

The white-space property declares how white space inside the element is handled.

CSS Syntax

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

Let's see an example:

<!DOCTYPE html>
<html>
   <head>
       <title>Title of the document</title>
       <style>
         div{white-space:normal }
       </style>
   </head>
   <body>
	
       <div> Example for the white-space property.Example for the white-space property.Example for the white-space property.Example for the white-space property.Example for the white-space property.Example for the white-space property.Example for the white-space property.Example for the white-space property.Example for the white-space property. </div>      

   </body>
</html>

Let's see an another example:

<!DOCTYPE html>
<html>
   <head>
       <title>Title of the document</title>
       <style>
         p{white-space: nowrap}
       </style>
   </head>
   <body>
	
       <p> Example for the white-space property.Example for the white-space property.Example for the white-space property.Example for the white-space property.Example for the white-space property.Example for the white-space property.Example for the white-space property.Example for the white-space property.Example for the white-space property. </p>      

   </body>
</html>

Property Values

Value Descriptions
normal This is default value. Breaks lines as necessary to fill line boxes.
nowrap With this value the text will never wrap to the next line.
pre It allows to have extra spaces on the line before the first letter of the text.
pre-line Text will wrap when necessary, and on line breaks.
pre-wrap Text will wrap when necessary, and on line breaks.
initial It makes the property use its default value.
inherit It inherits the property from its parents element.