Word-wrap: break-word; and word-break: break-all,

Source: Internet
Author: User

Word-wrap: break-word; and word-break: break-all,
How to distinguish word-wrap: break-word; and word-break: break-all ;?????

I just saw these two attributes, and my heart had 10 thousand million words. Why is there such an attribute? Not only is it like a mouthful, but it must be memorized. so I asked du Niang to sort out my understanding.

First, let's talk about the functions of these two attributes: sentences!

These two attributes apply to English and numbers. The browser treats numbers and long strings of English including url addresses as a word. If the row of the word cannot be displayed, the overall line feed will be processed.

If a style with a special long word that does not have a surface attribute, the area of the displayed text will overflow.

As shown below

Let's take a look at the specific role of this attribute.

Word-wrap: break-word;

This attribute means:

If a string is too long and cannot be displayed after the first line of text,

The long string is displayed from the second line. If the second line does not show any more, it is disconnected from the region boundary and the remaining string is displayed to the third line.

I don't know whether this can be understood. I simply wrote a code example and referred to it for understanding.

 

  <style type="text/css">    p{    word-wrap:break-word;    width:200px;    background:orange;    }  </style> 

 

Code execution result:

In the past, word-wrap: break-word; was not added:

Break-word: break-all;

If a frugal project manager sees that there is still so much space behind "hello", he is definitely not satisfied, saying that you are wasting your money... no worries.

Now let's take a look at break-word: break-all;

This attribute: If the row does not have enough space, it is still displayed in the row, and the excess is displayed in the next row.

Let's talk about the code.

  <style type="text/css">    p{    /*word-wrap:break-word;*/    word-break:break-all;    width:200px;    background:orange;    }  </style> 

Code execution result:

In the past, word-break: break-all; was not added:

If the frugal project manager sees you, it will definitely praise you! (@-@)

So far, I wonder if you understand the difference between word-wrap: break-word; and word-break; break-all!

 

Summary! If there are any errors, I hope you can correct them! Thank you!

 

Respect originality! Reprinted please indicate the source!

 

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.