The best way is
Word-wrap: break-word; overflow: hidden;
Instead
Word-wrap: break-word; word-break: break-all;
Neither
Word-wrap: break-word; overflow: auto;
There is no problem in IE. In FF, long strings of English will be overwritten.
Differences between word-wrap and word-break
Word-wrap:
Normal Default. Content exceeds the boundaries of its container.
Break-word Content wraps to next line, and a word-break occurs when necessary. If necessary, the word-break is triggered.
Word-break:
Normal Default. Allows line breaking within words. It seems to work only for Asian text.
Break-all
Behaves the same as normal for Asian text, yet allows the line to break
Arbitrarily for non-Asian text. This value is suited to Asian text that
Contains some excerpts of non-Asian text.
Keep-all Does not allow
Word breaking for Chinese, Japanese, and Korean. Functions the same way
As normal for all non-Asian ages. This value is optimized for text
That must des small amounts of Chinese, Japanese, or Korean.
Summary:
Word-wrap controls line breaks.
When break-word is used, a line break is forced. There is no problem with Chinese and no problem with English statements. However, long strings do not work in English.
Break-word controls whether words are disconnected.
Normal is the default condition, and English words are not separated.
Break-all, which is a broken word. When a word reaches the boundary, the next letter automatically goes to the next line. It mainly solves the problem of long strings in English.
Keep-all refers to continuous Words in Chinese, Japanese, and Korean. That is to say, in this case, word-wrap is not used, and the Chinese text will not wrap. (The English statement is normal .)
Ie:
Use word-wrap: break-word; all are normal.
Ff:
If none of the two are used, Chinese will not cause any problems. There are no problems with English statements. However, long strings may cause problems in English.
To solve the problem of long strings in English, word-wrap: break-word; word-break: break-all; is generally used ;. However, this method causes the words in Common English statements to be disconnected (also in ie ).
At present, the main problem is that long strings of English and English words are disconnected. In fact, long strings of English are just a long word.
That is, should an English word be disconnected? It is obvious that the problem should not be broken.
For long strings of English, it is malicious and you don't have to worry about it. However, we also need to find some way to prevent it from making the container large.
With: overflow: auto; ie, the long string is automatically folded. FF, the long string will be covered.
Therefore, in summary, the best way is word-wrap: Break-word; overflow: hidden; instead of word-wrap: Break-word; Word-break: Break-all ;.
Word-wrap: Break-word; overflow: auto; no problem in IE. In ff, long strings will be covered by some content.
In addition, the test code is as follows:
<Style>
. C1 {width: 300px; Border: 1px solid red}
. C2 {width: 300px; Word-wrap: Break-word; Border: 1px solid yellow}
. C3 {width: 300px; Word-wrap: Break-word; Word-break: Break-all; Border: 1px solid green}
. C4 {width: 300px; Word-wrap: Break-word; Word-break: Keep-all; Border: 1px solid blue}
. C5 {width: 300px; Word-break: Break-all; Border: 1px solid black}
. C6 {width: 300px; Word-break: Keep-all; Border: 1px solid red}
. C7 {width: 300px; Word-wrap: Break-word; overflow: auto; Border: 1px solid yellow}
</Style>
. C1 {width: 300px; Border: 1px solid red}
<Div class = "C1"> safjaskflasjfklsajfklasjflksajflksjflkasjfksafj </div>
<Div class = C1> This is all English. </div>
<Div class = C1> All are Chinese characters. It's all Chinese. It's all Chinese. </Div>
<Div class = C1> mix Chinese and English. Chinese and English. Mixed Chinese and English. Chinese and English. </div>
. C2 {width: 300px; Word-wrap: Break-word; Border: 1px solid yellow}
<Div class = "C2"> safjaskflasjfklsajfklasjflksajflksjflkasjfksafj </div>
<Div class = c2> This is all English. </div>
<Div class = c2> All are Chinese characters. It's all Chinese. It's all Chinese. </Div>
<Div class = c2> mixed Chinese and English. Chinese and English. Mixed Chinese and English. Chinese and English. </div>
. C3 {width: 300px; word-wrap: break-word; word-break: break-all; border: 1px solid green}
<Div class = "c3"> safjaskflasjfklsajfklasjflksajflksjflkasjfksafj </div>
<Div class = c3> This is all English. </div>
<Div class = c3> All are Chinese characters. It's all Chinese. It's all Chinese. </Div>
<Div class = c3> mix Chinese and English. Chinese and English. Mixed Chinese and English. Chinese and English. </div>
. C4 {width: 300px; word-wrap: break-word; word-break: keep-all; border: 1px solid blue}
<Div class = "c4"> safjaskflasjfklsajfklasjflksajflksjflkasjfksafj </div>
<Div class = c4> This is all English. </div>
<Div class = c4> All are Chinese characters. It's all Chinese. It's all Chinese. </Div>
<Div class = c4> mixed Chinese and English. Chinese and English. Mixed Chinese and English. Chinese and English. </div>
. C5 {width: 300px; word-break: break-all; border: 1px solid black}
<Div class = "c5"> safjaskflasjfklsajfklasjflksajflksjflkasjfksafj </div>
<Div class = c5> This is all English. </div>
<Div class = c5> All are Chinese characters. It's all Chinese. It's all Chinese. </Div>
<Div class = c5> mixed Chinese and English. Chinese and English. Mixed Chinese and English. Chinese and English. </div>
. C6 {width: 300px; word-break: keep-all; border: 1px solid red}
<Div class = "c6"> safjaskflasjfklsajfklasjflksajflksjflkasjfksafj </div>
<Div class = c6> This is all English. </div>
<Div class = c6> All are Chinese characters. It's all Chinese. It's all Chinese. </Div>
<Div class = c6> mix Chinese and English. Chinese and English. Mixed Chinese and English. Chinese and English. </div>
. C7 {width: 300px; word-wrap: break-word; overflow: auto; border: 1px solid yellow}
<Div class = "c7"> safjaskflasjfklsajfklasjflksajflksjflkasjfksafj </div>
<Div class = c7> This is all English. </div>
<Div class = c7> all Chinese characters are used. It's all Chinese. It's all Chinese. </Div>
<Div class = c7> mix Chinese and English. Chinese and English. Mixed Chinese and English. Chinese and English. </div>