Home > Web Front-end > CSS Tutorial > How to set div beyond line wrap in css

How to set div beyond line wrap in css

WBOY
Release: 2021-11-19 14:38:58
Original
8027 people have browsed it

In CSS, you can use the "word-break" attribute to achieve the div beyond line break effect. This attribute allows the div content to automatically wrap at the end. The syntax is "div{word-break:break-all;} ".

How to set div beyond line wrap in css

The operating environment of this tutorial: Windows 7 system, CSS3&&HTML5 version, Dell G3 computer.

How to set div beyond line wrapping in css

In css, you can use the word-break attribute to specify the processing method of automatic line wrapping.

By using the word-break attribute, the browser can achieve a line break at any position.

The syntax is:

word-break: normal|break-all|keep-all;
Copy after login

It should be noted that:

  • normal means using the browser’s default line wrapping rules.

  • #break-all indicates that line breaks are allowed within words.

  • #keep-all means line breaks can only be made at half-width spaces or hyphens.

Let’s take an example to see how to set the div beyond the new line. The example is as follows:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>
<body>
    <style type="text/css">
    div{
        width:50px;
        word-break:break-all;
    }
    </style>
    <div>
        aaaaaaaaaaaaaaaaaaaaaaaaaaaa
    </div>
</body>
</html>
Copy after login

Output result:

How to set div beyond line wrap in css

For more programming-related knowledge, please visit: Programming Video! !

The above is the detailed content of How to set div beyond line wrap in css. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
css
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template