1

I would like to make a table with one row (header for all columns) and then with rows and cols below header (just a regular table after the header). I have something like this for now on:

<table style="margin: auto;" border="1">
    <colgroup>
        <col align="left">
        <col align="right">
        <col align="right">
        <col align="right">
        <col align="right">
    <thead style="background: #F0F0F0" colspan="6" scope="colgroup">
        <tr>
            <th>header
    <thead style="background: #F0F0F0">
        <tr>
            <th>a 
            <th> a 
            <th> a 
            <th> a <br> b 
            <th> a 
            <th> a
</table>

but now, 'header' is in the first column only and I would like it to be stretched for all columns.

4

4 回答 4

3

You need to use colspan on the th tag and not on the thead

<thead>
     <tr>
         <th colspan="6">Head</th>
     </tr>
</thead>

Demo

于 2013-09-21T10:59:31.367 回答
2

Try this,it works fine.

just did few changes to your code.

<table style="margin: auto; border:1">
        <colgroup>
            <col align="left">
            <col align="right">
            <col align="right">
            <col align="right">
            <col align="right">
            <col align="right">
            </colgroup>
            <thead style="background: #F0F0F0"  scope="colgroup">
                <tr>
                    <th colspan="6">
                        header
                    </th>
                </tr>
            </thead>
            <thead style="background: #F0F0F0">
                <tr>
                    <th>
                        a
                    </th>
                    <th>
                        a
                    </th>
                    <th>
                        a
                    </th>
                    <th>
                        a
                        <br>
                        b
                    </th>
                    <th>
                        a
                    </th>
                    <th>
                        a
                    </th>
                </tr>
            </thead>
            <tbody style="background: #FFFFFF">
            </tbody>
         </table>
于 2013-09-21T11:10:17.250 回答
1

Try this.

<TABLE style=\margin: auto;\ border=1><COLGROUP><COL align="left"><COL align=right><COL align="right"><COL align="right"><COL align=right>
<THEAD style="background: #F0F0F0" colspan="6" scope="colgroup"><TR> <TH colspan="6">header
<THEAD style="background: #F0F0F0"><TR> <TH>a <TH> a <TH> a <TH> a <br> b <TH> a <TH> a
</TABLE>
于 2013-09-21T11:03:58.293 回答
0

try this code

<TABLE style=\margin: auto;\ border=1>
<COLGROUP><COL align=left><COL align=right><COL align=right><COL align=right><COL align=right>
    <THEAD style=\background: #F0F0F0 \ colspan=\6\ scope=\colgroup\><TR> <TH colspan="6">header
    <THEAD style=\background: #F0F0F0 \><TR> <TH>a <TH> a <TH> a <TH> a <br> b <TH> a <TH> a
    <TBODY style=\background: #FFFFFF\>
    </TABLE>
于 2013-09-21T10:58:40.053 回答