Let the browser be allowed to break lines with long words, if they overflow the container:
div {
overflow-wrap: break-word;
}
Try it Yourself »
The overflow-wrap
property specifies whether or not the browser can break lines with long words, if they overflow the container.
Default value: | normal |
---|---|
Inherited: | yes |
Animatable: | no. Read about animatable |
Version: | CSS3 |
JavaScript syntax: | object.style.overflowWrap="normal" Try it |
The numbers in the table specify the first browser version that fully supports the property.
Property | |||||
---|---|---|---|---|---|
overflow-wrap | 23.0 | 18.0 | 49.0 | 6.1 | 12.1 |
overflow-wrap: normal|anywhere|break-word|initial|inherit;
Value | Description | Demo |
---|---|---|
normal | Long words will not break, even if they overflow the container. This is default | Demo ❯ |
anywhere | Long words will break if they overflow the container | Demo ❯ |
break-word | Long words will break if they overflow the container | Demo ❯ |
initial | Sets this property to its default value. Read about initial | |
inherit | Inherits this property from its parent element. Read about inherit |
CSS tutorial: CSS Overflow
截取页面反馈部分,让我们更快修复内容!也可以直接跳过填写反馈内容!