1

I have a simple table that has a row at the top with one td element and the ones under it have 3 tds here is the structure :

<tr class="type">
  <td>
    <span>Platform</span>
  </td>
</tr>
<tr class="type__el">
  <td>OS</td>
  <td class="value">WINDOWS</td>
  <td class="score"> 8.6</td>
</tr>

So im trying to set the background color for the first row but it doesn't work properly it only highlights the text :

enter image description here

.type {
 background-color : #ccc;
}

i've tried adding 3 tds to the row and it works but not clean since i see these gaps between them : enter image description here

user121548789
  • 189
  • 1
  • 9

2 Answers2

2

You can expend <td> in first row by using property colspan="3"

Result

.type {
  background-color: #ccc;
}
<table>
  <tr class="type" bgcolor="red">
    <td colspan="3">
      <span>Platform</span>
    </td>
  </tr>
  <tr class="type__el">
    <td>OS</td>
    <td class="value">WINDOWS</td>
    <td class="score"> 8.6</td>
  </tr>
</table>
hisbvdis
  • 1,376
  • 1
  • 8
  • 11
1

You have to use the colspan attribute, a value of 3 should work

.type {
 background-color : #ccc;
}
<table>
  <tbody>
    <tr class="type" bgcolor="red">
      <td colspan="3">
        <span>Platform</span>
      </td>
    </tr>
    <tr class="type__el">
      <td>OS</td>
      <td class="value">WINDOWS</td>
      <td class="score"> 8.6</td>
    </tr>
  </tbody>
</table>

You can read more about it on this question

GammaGames
  • 1,617
  • 1
  • 17
  • 32