CSS wrap: word-wrap, word-break, and text-wrap, word-wraptext-wrap

Source: Internet
Author: User

CSS wrap: word-wrap, word-break, and text-wrap, word-wraptext-wrap

1. word-wrap: allows you to split long words and wrap them to the next line. (The processing results are the same in both Chinese and English)

Word-wrap has two values:

1. word-wrap: normal: only line breaks are allowed (the browser keeps the default processing ).

2. word-wrap: break-word: wrap a line in a long word or URL address. (That is, there are long words at the end of the container that cannot be fully displayed. The words are not truncated, but are used as a whole and are automatically wrapped)

   1: <!DOCTYPE>
   2: 
   3: 
4: <title> CSS line feed </title>
   5:    <meta http-equiv="content-type" content="text/html;charset=utf-8">
   6:    <style type="text/css">
   7:            div{
   8:                padding: 0;
   9:                margin: 0 auto;
  10:                width: 200px;
  11:                height: 100px;
  12:                border: 1px solid red;
  13:            }
  14:    </style>
  15: 
  16: <body>
  17:   <div>
  18:       Lorem ipsum dolor sit amet, consectetur adipiscing elit. 
  19:   </div>
  20: </body>
  21: 

By default:

Add style:

1: word-wrap: break-word; // same effect as above

 

2. word-break: Specifies the line feed rules for non-Chinese-Japanese text. (Line feed is normal for Chinese characters, and the English is handled according to the following instructions)

Word-break has three values:

1. word-break: normal: use the default line feed rule of the browser. (Equivalent to word-wrap: normal)

2. word-break: break-all: line breaks are allowed in words. (That is, long words cannot be fully displayed at the end of the container, and the words are truncated)

Add this rule to div

   1: word-break:break-all;

Result: The sit is intercepted.

3. word-break: keep-all: a line break can only be entered with a half-width space or a hyphen.

For demonstration, add a hyphen (-) between ipsum, dolor, and sit in the original text (-)

   1: <div>
   2:       Lorem ipsum-dolor-sit amet, consectetur adipiscing elit. 
   3:   </div>

Effect: a line break is generated after ipsum.

3. text-wrap: defines the line feed rules of text.

Text-wrap is the CSS3 attribute and has four values:

1. text-wrap: normal: line feed is allowed only at the allowed line breaks.

2. text-wrap: none: Do not wrap. Text that cannot be contained by the element overflows.

3. text-wrap: suppress: line feed in the compressed element. The browser only performs line breaks when there are no other valid line breaks in the line.

4. text-wrap: unrestricted: line feed between any two characters.

PS: currently, mainstream browsers do not support the text-wrap attribute.


Source: http://www.ido321.com/621.html



What is {word-wrap: break-word; word-break: break-all;} in the CSS of the webpage?

The content in the div container will wrap in the boundary. (word-wrap) Words in English sentences do not force line breaks. (Word-break.

Does css automatically wrap full word-break?

Automatically wrap word-break: break-all and word-wrap: break-word
Word-break: break-all and word-wrap: break-word can automatically wrap the content of a container such as DIV.
Their differences are:
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. Word-break: normal | break-all | keep-all parameter: normal: according to the text rules of the Asian and non-Asian languages, break-all can be entered in the word: this action 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 text keep-all that contains some non-Asian text: it is the same as normal in all non-Asian languages. Chinese, Korean, and Japanese cannot be disconnected. It is applicable to non-Asian text syntax that contains a small amount of Asian text: word-wrap: normal | break-word parameter: normal: allows the content to open the specified container boundary 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.
The corresponding script feature is wordWrap. For more information, see my other bibliography. Syntax: table-layout: auto | fixed parameter: auto: Default automatic algorithm. The layout is based on the content of each cell. The table is displayed only after each cell is read and computed. Slow fixed: fixed Layout Algorithm. In this algorithm, the horizontal layout is based only on the table width, the table Border width, the cell spacing, and the column width, but it has nothing to do with the table content: sets or retrieves the Layout Algorithm of a table. The corresponding script feature is tableLayout.
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.
I tried it on my website and it does not support it. You can try again by W3C.

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.