Cyborg29
Cyborg29

Reputation: 73

Create a nested table that is three columns long with only html

This is my problem:

<table border= '1' width= '100%' >
 <tr>
   <td> Apple </td>
   <td> Banana </td>
   <td> Strawberry </td>
 </tr>

 <tr> 
   <td> <table border='1' width= '100%'> </td>
   <td> Healthy </td>
   <td> Fruits </td>
   <td> Banana </td>
   </table>
 </tr>
 </table> 

Table

The second row is only one column wide but I want it to be three columns wide. And from what I tested colspan doesnt work on the nested table. Is it even possible to do what I want?

Upvotes: 1

Views: 991

Answers (1)

charlietfl
charlietfl

Reputation: 171698

It's not totally clear what the layout needs to be but once you fix the html structure so cell holding nested table is closed properly, and it's cells have <tr> and add some colspans the following should get you close to what you want.

Note that nesting tables is not used a lot any more. It is very old school

<table border='1' width='100%'>
  <tr>
    <td> Apple </td>
    <td> Banana </td>
    <td> Strawberry </td>
  </tr>
  <tr>
    <td colspan='2'>
      <table border='1' width='100%'>
        <tr>
          <td> Healthy </td>
          <td> Fruits </td>
          <td> Banana </td>
        </tr>
      </table>
    </td>
    <td>Last Cell</td>
  </tr>
</table>

Upvotes: 1

Related Questions