Dùng thuộc tính wordWrap trong JavaScript để cho phép từ dài bị phá vỡ và xuống dòng tiếp theo.
Ví dụ
Bạn có thể chạy mã sau để học cách làm việc với thuộc tính wordWrap −
<!DOCTYPE html> <html> <head> <style> #box { width: 150px; height: 150px; background-color: lightblue; border: 1px solid black; } </style> </head> <body> <button onclick = "display()">Đặt</button> <div id = "box"> ThisisDemoText.ThisisDemoText.ThisisDemoText.ThisisDemoText.Thisis DemoText.ThisisDemoText. </div> <script> function display() { document.getElementById("box").style.wordWrap = "break-word"; } </script> </body> </html>