CSS--How to force text to be wrapped

Source: Internet
Author: User

  

When we were writing HTML,

Sometimes it is often necessary to use some table properties on the mobile side to present some data. If we say that there are no consecutive numbers or letters in our data, the display will not be error-free.

Cases:

But this is often the case if we want to present data that is numeric or long-letter information.

Cases:

  

The text does not wrap as we expected, and the width of the setting is not valid.

What is the reason for this?

The reason is that when the browser is parsing our page, if we give him consecutive numbers or letters, the browser will not parse separately, but will directly use this long string as a word , so we set the width is invalid, does not automatically cut off the string and line wrapping.

Solution:

If we want the text in the table to force a newline (especially in the case of a long string of English text and no space between them), in order to make the text that is too long to break the table, you need to add the following two lines of code to the style:

1 Word-wrap:break-word; 2 Word-break:break-all;

What's the use of these two lines of code?

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

1,word-break:break-all

Allows line wrapping within a word. Given a div width, characters that are longer than the specified width are automatically wrapped. If there is an English word at the end of the line that is long (confidence, etc.), it truncates the word to the end of the line as con (the first half of the confidence), and the next behavior fidence (the back part of Fidence).


2,word-wrap:break-word

Allow long words to wrap to the next line. The example is the same as above, but the difference is that it will confidence the whole word as a whole, and if the end of the line is not wide enough to display the whole word, it will automatically put the whole word on the next line without truncating the word.

Compatibility issues:

Both the Word-break and Word-wrap properties support all major browsers.

    

CSS--How to force text to be wrapped

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.