The difference between forcing a newline word-break, Word-wrap, and White-space in CSS

Source: Internet
Author: User
CSS forced line word-break, Word-wrap, White-space Difference instance description, the need for friends can refer to the following

The HTML code for the test

<p class= "C1" >safjaskflasjfklsajfklasjflksajflksjflkasfdsafdsfksafj</p><p Class=c1>This is all 中文版. This is all 中文版. All english.</p><p class=c1> are in Chinese. It's all in Chinese. It's all in Chinese. </p><p class=c1> in Chinese and English mixed in the situation. Chinese and 中文版. In Chinese and English mixed row situation. Chinese and english.</p> Copy code

The code is as follows:

. c1{width:300px;word-break:normal;border:1px solid Red;} [Object Object]


If the content is a long English string, IE6 will open the container, other browsers will only overflow, will not open

The code is as follows:

. c1{width:300px;word-break:break-all;border:1px solid Red;}



Long English strings cannot be wrapped in Firefox.

The code is as follows:

. c1{width:300px;word-break:keep-all;border:1px solid Red;}




IE6, English long words A and Chinese long sentences will open the container, IE7, IE8 Direct overflow, Firefox only long English strings will overflow.

The code is as follows:

. c1{width:300px;word-wrap:normal;border:1px solid Red;}

This is the same as the first case.

The code is as follows:

. c1{width:300px;word-wrap:break-word;border:1px solid Red;}


All browsers are wrapped.

The code is as follows:

. c1{width:300px;white-space:normal;border:1px solid Red;}

Same as in the first case.

The code is as follows:

. c1{width:300px;white-space:pre;border:1px solid Red;}



IE6 under all open, IE7, IE8, Firefox all overflow

The code is as follows:

. c1{width:300px;white-space:nowrap;border:1px solid Red;}

Same as 7

The above is the whole content of this article, I hope that everyone's learning has helped, more relevant content please pay attention to topic.alibabacloud.com!

Related Article

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.