Javascript examples for CSS Style Property:wordWrap
The wordWrap property gets and sets how long words can be broken and wrapped onto the next line.
Value | Description |
---|---|
normal | Break words only at allowed break points |
break-word | break the unbreakable words |
initial | Sets this property to its default value. |
inherit | Inherits this property from its parent element. |
Item | Value |
---|---|
Default Value: | normal |
Return Value: | A String, representing the word-wrap property of an element |
CSS Version | CSS3 |
Allow long words to be able to break and wrap onto the next line:
<!DOCTYPE html> <html> <head> <style> #myDIV {/* w ww . j av a 2 s. c om*/ width: 150px; height: 100px; background-color: lightblue; border: 1px solid black; } </style> </head> <body> <div id="myDIV">thisthisthisthisthsithsithsithsithsi</div> <button onclick="myFunction()">Test</button> <script> function myFunction() { document.getElementById("myDIV").style.wordWrap = "break-word"; } </script> </body> </html>