CSS mandatory line feed

Source: Internet
Author: User

In general, the element has the default white-space: normal (automatic line feed, PS: Do not wrap is white-space: nowrap ), when the entered text exceeds the defined width, it will automatically wrap, but when the entered data is a pile of characters, letters, or numbers without spaces (regular data should not have it, but some testers will do this). When the container width is exceeded, the container will be extended without line breaks.

Solution (use IE, chrome, FF as the test browser ):

{

Word-break: Break-all;/* supports IE, chrome, and ff */

Word-wrap:Break-word;/* Supports IE, chrome, FF */

}

The following describes the differences between the two methods:

1. Word-break: Break-ALL: for example, if the DIV width is PX, its content will be automatically wrapped in PX. If the end of the line has a long English word (congratulation, etc ), it truncates the word and converts it to the backend part of the row whose end is CONRA (congratulation) and the next row is tulation (conguatulation.

2. Word-wrap: the break-word example is the same as above, but the difference is that it regards the entire word congratulation as a whole. If the end width of the row is insufficient, it automatically puts the entire word in the next line, instead of truncating the word.

3. Word-break; break-all supports version: ie5 or above, which is the same as normal in the Asian language. It also allows non-Asian text lines to be broken in any word. This value is suitable for Asian texts that contain non-Asian texts.

Word-wrap: Break-word supported version: ie5.5 and above will be wrapped in the boundary. If necessary, the line feed (Word-break) also occurs. Automatic table line breaks to avoid opening.

Syntax: Word-break: normal | break-All | keep-all

Parameter: Normal: line breaks are allowed according to the text rules of the Asian and non-Asian languages.

Break-ALL: this behavior is the same as that of the Asian language normal. It also allows non-Asian text lines to be broken in any word. This value is applicable to Asian texts that contain non-Asian texts.

Keep-ALL: same as normal in all non-Asian languages. Chinese, Korean, and Japanese cannot be disconnected. Suitable for non-Asian texts that contain a small number of Asian texts

Syntax: Word-wrap: normal | break-word

Parameter: normal

Break-word: the content will wrap in the boundary. If necessary, word-break also indicates whether to disconnect or retrieve the line break when the line breaks beyond the boundary of the specified container.

Suggestion: If word-break is detected by 3c, a problem will be displayed, which may lead to Baidu snapshots.-The opera Firefox browser does not support the word-break attribute and can use white-space: normal; in this way, both Firefox and IE can get the correct line feed, and note that spaces between words cannot be replaced, otherwise the line feed cannot be correct.

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.