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> 

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?

1

1 Answer

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>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Elena Rostova

Elena Rostova

Lead Health, Wellness & Medical Journalist

Elena Rostova holds a Master's degree in Public Health Journalism. She covers groundbreaking medical research, holistic wellness trends, mental health awareness, and nutritional science.

Share this article
Twitter Facebook Pinterest