By default, the UserAgent (default stylesheet of the browser) will not randomly break a word into multiple lines. The default setting is word-break: normal
.
That means that a line-break will only appear on white-spaces, dashes, and line break opportunities (<wbr>
tag).
Alternativly, you can allow a browser to break words at any point to fit the container by using: word-break: break-all
:
div {
word-break: break-all;
}
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<p>no spaces:</p>
<div style="height:50px;width: 200px;border: 4px solid red;overflow-wrap: break-word;">helloooooooooooooooooooooooooooooooo</div>
<br>
<p>with spaces:</p>
<div style="height:50px;width: 200px;border: 4px solid red;
">hello ooooooo ooooo ooooooo ooooooooo oooooooo</div>
</body>
</html>
MDN Documentation for word-break