title: HTML table: column width percentage
body: <p>I have a table with 7 columns. I want the columns to be of the following widths:</p>
  
  <ul>
  <li>3 columns x <code>width=20%</code></li>
  <li>4 columns x <code>width=10%</code></li>
  </ul>
  
  <p>I have created 2 CSS classes, one per width and I am assigning them to each cell. </p>
  
  <p>The thing I have, and that does not work is this. Instead, the width always wraps the content. If I just put one letter, than the width will be very small, if I put large string, the width will be too big. I want it constant.</p>
  
  <p>CSS &amp; HTML :</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>table {
    width: 100%;
  }
  .ten {
    width: 10%
  }
  .twenty {
    width: 20%;
  }</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;table&gt;
    &lt;tr&gt;
      &lt;th class="ten"&gt;H1&lt;/th&gt;
      &lt;th class="ten"&gt;H2&lt;/th&gt;
      &lt;th class="ten"&gt;H3&lt;/th&gt;
      &lt;th class="twenty"&gt;H4&lt;/th&gt;
      &lt;th class="twenty"&gt;H5&lt;/th&gt;
      &lt;th class="twenty"&gt;H6&lt;/th&gt;
      &lt;th class="ten"&gt;H7&lt;/th&gt;
    &lt;/tr&gt;
  
    &lt;tr&gt;
      &lt;td class="ten"&gt;A1&lt;/td&gt;
      &lt;td class="ten"&gt;A2&lt;/td&gt;
      &lt;td class="ten"&gt;A3&lt;/td&gt;
      &lt;td class="twenty"&gt;A4&lt;/td&gt;
      &lt;td class="twenty"&gt;A5&lt;/td&gt;
      &lt;td class="twenty"&gt;A6&lt;/td&gt;
      &lt;td class="ten"&gt;A7&lt;/td&gt;
    &lt;/tr&gt;
  
    &lt;tr&gt;
      &lt;td class="ten"&gt;B1&lt;/td&gt;
      &lt;td class="ten"&gt;B2&lt;/td&gt;
      &lt;td class="ten"&gt;B3&lt;/td&gt;
      &lt;td class="twenty"&gt;B4&lt;/td&gt;
      &lt;td class="twenty"&gt;B5&lt;/td&gt;
      &lt;td class="twenty"&gt;B6&lt;/td&gt;
      &lt;td class="ten"&gt;B7&lt;/td&gt;
    &lt;/tr&gt;
  
  &lt;/table&gt;</code></pre>
  </div>
  </div>
  </p>
  
  <p>Could someone explain how to achieve what I want?</p>