Slanted diagonal line in html or css?

Based on CSS3 linear-gradients solution except that the angle is not hard coded:

table:nth-of-type(1) td {
  background-image: linear-gradient(
    to top right,
    white 48%,
    black,
    white 52%
  );
}
table:nth-of-type(2) td {
  background-image: linear-gradient(
    to top right,
    papayawhip calc(50% - 1px),
    black,
    papayawhip calc(50% + 1px)
  );
}
/* for testing */
table {
  border-collapse: collapse;
  margin-top: 1em;
  margin-bottom: 1em;
}
td:nth-child(odd) {
  width: 10em;
}
td:nth-child(even) {
  width: 20em;
}
<table border="1">
  <tbody>
    <tr>
      <td>Narrow</td>
      <td>Wide</td>
    </tr>
    <tr>
      <td>Narrow</td>
      <td>Wide</td>
    </tr>
  </tbody>
</table>
<table border="1">
  <tbody>
    <tr>
      <td>Narrow</td>
      <td>Wide</td>
    </tr>
    <tr>
      <td>Narrow</td>
      <td>Wide</td>
    </tr>
  </tbody>
</table>

Another approach would be to use SVG as it can scale easily to the size of your container.

Example :

div {
  position: relative;
  display:inline-block;
  width: 100px;
  height: 50px;
  border: 1px solid #000;
}
.l{width:200px;}
.xl{width:300px;}
svg {
  position: absolute;
  width: 100%;
  height: 100%;
}
<div class="s">
  <svg viewBox="0 0 10 10" preserveAspectRatio="none">
    <line x1="0" y1="0" x2="10" y2="10" stroke="black" stroke-width="0.2" />
  </svg>
</div>
<div class="l">
  <svg viewBox="0 0 10 10" preserveAspectRatio="none">
    <line x1="0" y1="0" x2="10" y2="10" stroke="black" stroke-width="0.2" />
  </svg>
</div>
<div class="xl">
  <svg viewBox="0 0 10 10" preserveAspectRatio="none">
    <line x1="0" y1="0" x2="10" y2="10" stroke="black" stroke-width="0.2" />
  </svg>
</div>