The normal value and nowrap value of the white-space attribute

normal: The text automatically handles newlines, and the content that reaches the border of the container will automatically go to the next line.

nowrap: Display all text on the same line until the end of the text or
a tag after the text.

The property of white-space:normal is actually not very useful to me...

I tried in the div and li tags, whether there is normal or not, it will automatically wrap.

code:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        div{
            width: 300px;
            height: 150px;
            background-color:darkcyan;
            /* white-space: nowrap; */
             white-space: normal;
        }
    </style>
</head>
<body>
    <div>
        <h3>这是一段很高的文字这是一段很高的文字
            这是一段很高的文字这是一段很高的文字
            这是一段很高的文字这是一段很高的文字
            这是一段很高的文字这是一段很高的文字
            这是一段很高的文字这是一段很高的文字
            这是一段很高的文字这是一段很高的文字</h3>
    </div>
</body>
</html>

What about the running result:

This is true whether there is a normal effect in the div,

(I tried the lip tag as well)

If nowrap, the effect is as follows:

Searching for four days, I found out that normal is blank at the end of writing, and the browser defaults to blank, so half of my first blog is in... imitation leather.

Guess you like

Origin blog.csdn.net/sslovly/article/details/120231367