CSS White Space

The CSS white space property is used to specify how to display the content within an element. It is used to handle the white spaces inside an element.

CSS White Space values

There are many white space values that can be used to display the content inside an element.

ValueDescription
normalThis is a default value. in this value, text is wrapped when necessary. sequences of white space will collapse into a single whitespace.
nowrapSequences of white space will collapse into a single whitespace. in this value, text will never wrap to the next line and only break when <br> tag is used.
preWhitespace is preserved by the browser. it is act like html <pre> tag. text will only wrap on line breaks.
pre-lineSequences of white space will collapse into a single whitespace. texts are wrapped when necessary, and on line break.
pre-wrapWhitespace is preserved by the browser. texts are wrapped when necessary, and on line break.
initialIt sets this property to its default value.
inheritIt inherits this property from its parent element.

CSS White Space Example

    <!DOCTYPE html>  
    <html>  
    <head>  
    <style>  
    p {  
        white-space: nowrap;  
    }  
    </style>  
    </head>  
    <body>  
    <p>  
    Write some text..Write some text..Write some text..  
    Write some text..Write some text..Write some text..  
    Write some text..Write some text..Write some text..  
    Write some text..Write some text..Write some text..  
    Write some text..Write some text..Write some text..  
    </p>  
    </body>  
    </html>  

Was this article helpful?

Related Articles

Leave A Comment?