Edit This Code:
See Result »
<!DOCTYPE html> <html> <head> <style> #myDIV { width: 150px; height: 100px; background-color: lightblue; border: 1px solid black; } </style> <script> var _hmt = _hmt || []; (function() { var hm = document.createElement("script"); hm.src = "//hm.baidu.com/hm.js?73c27e26f610eb3c9f3feb0c75b03925"; var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(hm, s); })(); </script> </head> <body> <p>Click the "Try it" button to change the let the DIV element wrap words:</p> <div id="myDIV">Thiscouldbeaninsainlylargeword</div> <button onclick="myFunction()">Try it</button> <script> function myFunction() { document.getElementById("myDIV").style.wordWrap = "break-word"; } </script> </body> </html>
Result: