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

前端 未结 10 1341
离开以前
离开以前 2020-11-22 07:39

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 wa

10条回答
  •  独厮守ぢ
    2020-11-22 08:06

    word-break:break-all :

    word to continue to border then break in newline.

    word-wrap:break-word :

    At first , word wrap in newline then continue to border.

    Example :

    div {
       border: 1px solid red;
       width: 200px;
    }
    
    span {
      background-color: yellow;
    }
    
    .break-all {
      word-break:break-all;
     }
    .break-word {
      word-wrap:break-word;  
    }
    word-break:break-all
    
    
    This text is styled with soooooooooooooooooooooooooome of the text formatting properties.
    word-wrap:break-word
    This text is styled with soooooooooooooooooooooooooome of the text formatting properties.

提交回复
热议问题