Word-wrap and word-break

Source: Internet
Author: User

I. Word-wrap

1. browser support

All mainstream browsers support word-wrap attributes

2. Definition and usage

The word-wrap attribute allows long words or URLs to wrap into the next line.

Syntax

word-wrap: normal|break-word;
Value Description
Normal Wrap only at the allowed broken word points (the browser keeps processing by default ).
Break-word Wrap a line in a long word or URL address.

 

 

 

*********************

1. Default display for div + span layout Browser

        .divOne {            width: 200px;            border: 2px solid blue;        }        .spanTwo {            color: red;        }
    <div class="divOne">        <span class="spanTwo">12341234324        </span>        <span>11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111        </span>        <span class="spanTwo">abcdef        </span>    </div>

Display result:

If you use the work-wrap attribute:

        .divOne {            width: 200px;            border: 2px solid blue;            word-wrap: break-word;        }

 

 

2. Word-break

1. browser support

All mainstream browsers support the work-break attribute.

2. Definition and usage

The word-break attribute specifies the handling method for automatic line feed.

Tip: You can use the word-break attribute to wrap a line at any position in the browser.

Default Value: Normal
Inheritance: Yes
Version: Css3
Javascript Syntax: Object. Style. wordbreak = "Keep-all"

 

 

 

 

Syntax
word-break: normal|break-all|keep-all;
Value Description
Normal Use the default line feed rule of the browser.
Break-all Line breaks are allowed in words.
Keep-all You can only wrap a line at a halfwidth space or a hyphen.

 

 

 

 

*********************

3. Use the word-break attribute

        .divOne {            width: 200px;            border: 2px solid blue;            word-break:break-all;        }

Display result:

 

Word-wrap and word-break

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.