The word-wrap property for CSS specifies whether the user agent may break at otherwise disallowed points within a line to prevent overflow, when an otherwise-unbreakable string is too long to fit within the line box.
object.style.wordWrap = "value"; <'word-wrap'> = normal | break-word | anywhere normal Lines may break only at allowed break points.
break-word As for anywhere except soft wrap opportunities introduced by break-word are not considered when calculating min-content intrinsic sizes.
anywhere An otherwise unbreakable sequence of characters may be broken at an arbitrary point if there are no otherwise-acceptable break points in the line.
<!doctype html>
<html>
<head>
<style>
p
{
background-color: yellow;
width: 20px;
word-wrap: break-word;
}
</style>
</head>
<body>
<p>break-word break-word break-word break-word break-word break-word break-word break-word break-word break-word break-word break-word break-word break-word break-word break-word break-word break-word break-word break-word break-word break-word break-word break-word break-word break-word break-word break-word break-word break-word break-word break-word break-word break-word break-word break-word break-word break-word break-word break-word break-word break-word break-word break-word break-word break-word break-word break-word break-word break-word break-word break-word break-word break-word break-word break-word break-word break-word break-word break-word break-word break-word break-word break-word break-word break-word break-word break-word break-word break-word break-word break-word break-word break-word break-word break-word break-word break-word break-word break-word break-word break-word break-word break-word break-word break-word break-word break-word break-word break-word break-word break-word break-word break-word break-word break-word break-word break-word break-word break-word</p>
</body>
</html>
<!doctype html>
<html>
<head>
<style>
p
{
background-color: yellow;
width: 20px;
word-wrap: normal;
}
</style>
</head>
<body>
<p>normal normal normal normal normal normal normal normal normal normal normal normal normal normal normal normal normal normal normal normal normal normal normal normal normal normal normal normal normal normal normal normal normal normal normal normal normal normal normal normal normal normal normal normal normal normal normal normal normal normal normal normal normal normal normal normal normal normal normal normal normal normal normal normal normal normal normal normal normal normal normal normal normal normal normal normal normal normal normal normal normal normal normal normal normal normal normal normal normal normal normal normal normal normal normal normal normal normal normal normal</p>
</body>
</html>
<!doctype html>
<html>
<head>
<style>
p
{
background-color: yellow;
width: 20px;
}
</style>
</head>
<body>
<button>initial</button>
<button>anywhere</button>
<button>break-word</button>
<button>normal</button>
<p>word-wrap word-wrap word-wrap word-wrap word-wrap word-wrap word-wrap word-wrap word-wrap word-wrap word-wrap word-wrap word-wrap word-wrap word-wrap word-wrap word-wrap word-wrap word-wrap word-wrap word-wrap word-wrap word-wrap word-wrap word-wrap word-wrap word-wrap word-wrap word-wrap word-wrap word-wrap word-wrap word-wrap word-wrap word-wrap word-wrap word-wrap word-wrap word-wrap word-wrap word-wrap word-wrap word-wrap word-wrap word-wrap word-wrap word-wrap word-wrap word-wrap word-wrap word-wrap word-wrap word-wrap word-wrap word-wrap word-wrap word-wrap word-wrap word-wrap word-wrap word-wrap word-wrap word-wrap word-wrap word-wrap word-wrap word-wrap word-wrap word-wrap word-wrap word-wrap word-wrap word-wrap word-wrap word-wrap word-wrap word-wrap word-wrap word-wrap word-wrap word-wrap word-wrap word-wrap word-wrap word-wrap word-wrap word-wrap word-wrap word-wrap word-wrap word-wrap word-wrap word-wrap word-wrap word-wrap word-wrap word-wrap word-wrap word-wrap word-wrap</p>
<script>
function myfunction(myparameter)
{
document.querySelector("p").style.wordWrap = myparameter.target.innerHTML;
}
for(const mybutton of document.querySelectorAll("button"))
{
mybutton.addEventListener("mouseover", myfunction);
}
</script>
</body>
</html>