Thead with one td (full width) and tbody with 2 columns (width does not depend on thead)

Ok, a long headline. I have a table structured like this:

<table> <thead> <tr><th>longer Heading with a width of 100%</th></tr> </thead> <tbody> <tr><td>cell 1</td><td>cell 2</tr> <tr><td>cell 3</td><td>cell 4</tr> </tbody> </table> 

And I would like th to be full width and not change the width of the table cells. I suppose there is some CSS display property that would make this possible, but I haven't found a working solution yet.

+12
html html-table table
source share
3 answers
 <table> <thead> <tr><th colspan="2">longer Heading with a width of 100%</th></tr> </thead> <tbody> <tr><td>cell 1</td><td>cell 2 </td></tr> <tr><td>cell 3</td><td>cell 4 </td></tr> </tbody> 

using colspan will do the trick for you

+14
source share

It?

 <th colspan="2">...</th> 
+3
source share

It is simpler: you just need colspan for your th element.
Colspan determines how many cells an element selects:

 <table> <thead> <tr><th colspan="2">longer Heading with a width of 100%</th></tr> </thead> <tbody> <tr><td>cell 1</td><td>cell 2</tr> <tr><td>cell 3</td><td>cell 4</tr> </tbody> </table> 

See my script

0
source share

All Articles