Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the difference between "word-break: break-all" versus "word-wrap: break-word" in CSS

Tags:

css

word-wrap

I am currently wondering what is the difference between the two. When I used both they seem to break the word if it is not fitting the container. But why did W3C made two ways to do it?

like image 356
Nap Avatar asked Nov 25 '09 06:11

Nap


People also ask

What is the difference between word break break-all and word-wrap break-word in CSS?

The word-break property in CSS is used to specify how a word should be broken or split when reaching the end of a line. The word-wrap property is used to split/break long words and wrap them into the next line. word-break: break-all; It is used to break the words at any character to prevent overflow.

What is the difference between word break and word-wrap?

The two properties ( word-break and word-wrap ) differ rules and overflow of words: as mentioned earlier, word-wrap is used to break words that overflow their container, while the word-break property breaks all words at the end of a line, even those that would normally wrap onto another line and wouldn't overflow their ...

What is the difference between word break and overflow-wrap?

The overflow-wrap property breaks the word if it cannot be placed on the line without overflowing regardless of the language used. The word-break property is used for non-English languages and specifies wraps between letters of languages like Chinese, Japanese, and Korean.

What is word break CSS?

The word-break CSS property sets whether line breaks appear wherever the text would otherwise overflow its content box.


1 Answers

word-wrap: break-word recently changed to overflow-wrap: break-word

  • will wrap long words onto the next line.
  • adjusts different words so that they do not break in the middle.

word-break: break-all

  • irrespective of whether it’s a continuous word or many words, breaks them up at the edge of the width limit. (i.e. even within the characters of the same word)

So if you have many fixed-size spans which get content dynamically, you might just prefer using word-wrap: break-word, as that way only the continuous words are broken in between, and in case it’s a sentence comprising many words, the spaces are adjusted to get intact words (no break within a word).

And if it doesn’t matter, go for either.

like image 114
Bhumi Singhal Avatar answered Sep 21 '22 03:09

Bhumi Singhal