Setting the maximum width of a table
<p>I'm trying to set the maximum width of a table, but it doesn't seem to be working. If a word inside the table is too long, it automatically expands the width of the table. How do I stop that from happening, and instead have the word that's too long go to the next line?</p>
<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-css lang-css prettyprint-override"><code>&lt;style&gt;table {
  max-width: 300px;
}

table,
td {
  border: 1px solid red;
}

div {
  border: 1px solid blue;
  word-wrap: break-word;
}

&lt;/style&gt;</code></pre>
<pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;table&gt;

  &lt;tr&gt;
    &lt;td&gt;
      &lt;div&gt; hellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohello
      &lt;/div&gt;
    &lt;/td&gt;
  &lt;/tr&gt;

&lt;/table&gt;</code></pre>
</div>
</div>
</p>