Home  >  Article  >  Web Front-end  >  How to set automatic line wrapping in css

How to set automatic line wrapping in css

醉折花枝作酒筹
醉折花枝作酒筹Original
2021-04-15 18:05:0741827browse

In CSS, you can use the "word-wrap" attribute to set automatic line wrapping, and the syntax is "word-wrap:break-word". The word-wrap attribute sets the line wrapping method of long content. When the value is "break-word", automatic line wrapping will be performed within long words or URL addresses.

How to set automatic line wrapping in css

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

In the div css layout, when continuous English letters or consecutive numbers are displayed in a row in div, p, h2, h1 and other boxes, they will not automatically wrap according to the box width limit.

Of course, Chinese characters will automatically wrap in DIV or any box without CSS style implementation. Only consecutive letters or numbers will have the problem of not automatically wrapping, so CSS is needed to solve it.

How to set automatic line wrapping in css

Solution:

word-wrap:break-word

Explanation: When using break-word, line breaks will be forced.

Compatible with all versions of IE browsers and Google Chrome.

Complete HTML CSS code

nbsp;html>

    
        <meta>
        <title></title>
        <style>
            .p{ border:1px solid #00F; height:120px; width:200px;word-wrap:break-word} 
        </style>
    
    
        <div>aabbfjdlkfldsjfldsjfldjfljdlafjldsjflkdjflkdsjfldfjdlj
            <br>138787843748927493274392749327493</div>
    

Example effect screenshot

How to set automatic line wrapping in css

Recommended learning: css video tutorial

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

Statement:
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