0

I am wondering if this table layout in HTML possible? here is what I have in Reactjs:

enter image description here

I am getting errors trying to do a colspan.

What I want to achieve is this layout:

enter image description here

Many thanks in advance and greatly appreciate any helps

Nat
  • 679
  • 1
  • 9
  • 24

3 Answers3

3

yes it is possible with colspan, here is the example code

<table>
  <tr>
    <th>name</th>
    <th>title</th>
    <th>edit</th>
  </tr>
  <tr>
    <td>Jhon doe</td>
    <td>Sales</td>
    <td>Edit</td>
  </tr>
  <tr>
    <td colspan="3">Remark : blablabla</td>
  </tr>
   <tr>
    <td>Jane doe</td>
    <td>Sales</td>
    <td>Edit</td>
  </tr>
  <tr>
    <td colspan="3">Remark : blablabla</td>
  </tr>
</table>

but you will need css to add borders

table, th, td {
  border: 1px solid black;
  border-collapse: collapse;
}
I_love_vegetables
  • 1,575
  • 5
  • 12
  • 26
3

That's how you wanted your table to be, use colspan after which cell you need divided columns.

table,
th,
td {
  border: 1px solid black;
  border-collapse: collapse;
}

table {
  border: 1px solid black;
  width: 60%;
  text-align: left;
}

th,
td {
  padding: 10px;
}
<table>
  <thead>
    <tr>
      <th>Name</th>
      <th>Name</th>
      <th>Name</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td>Text</td>
      <td>Text</td>
      <td>Text</td>
    </tr>
    <tr>
      <td colspan="3">Text</td>
    </tr>
    <tr>
      <td>Text</td>
      <td>Text</td>
      <td>Text</td>
    </tr>
    <tr>
      <td colspan="3">Text</td>
    </tr>
    <tr>
      <td>Text</td>
      <td>Text</td>
      <td>Text</td>
    </tr>
    <tr>
      <td colspan="3">Text</td>
    </tr>
    <tr>
      <td>Text</td>
      <td>Text</td>
      <td>Text</td>
    </tr>
  </tbody>
</table>
2

Yes, it is. You can read this link.

But to save your time you just need to set colspan=3 in your td where you want it to be expanded.

N. Tajalli
  • 21
  • 1
  • 4