Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

table header inside another

Tags:

html

i want to span a heading element to include another sub headings elements like that:

<thead>   
<th rowspan="2">main heading1</th>   
<th rowspan="2">main heading2</th>   
<th colspan="3">main heading3
    <thead>
     <tr>
     <th>sub heading1</th>
     <th>sub heading2</th>
     <th>sub heading3</th>
     <tr>
    <thead>   
</th>   
<th rowspan="2">main heading4</th> 
</thead>

is that possible ?

like image 525
user796767 Avatar asked Jul 04 '11 22:07

user796767


People also ask

How do you put a heading inside a table in HTML?

Learn HTML To create table header in HTML, use the <th>… </th> tag. A table header tag is surrounded by the table row <tr>… </tr>.

How do you put th inside th in HTML?

If you want a table inside a table, you need to use the <table> element again. You can't just place another thead inside the thead . You're also missing <tr> tags and if you want a table inside a table using rowspan and colspan incorrectly. Option 1: You could use 2 rows in your thead .

How do I make a table with multiple headers?

To apply the header row formatting to multiple rows in the table: after the table style is applied, select the rows you want included in the "header row" and on the Table tools > Layout tab, click Repeat Header Rows. If header row is ticked in Design tab > Table style options, you will see your header row formatting.


1 Answers

If you want a table inside a table, you need to use the <table> element again. You can't just place another thead inside the thead. You're also missing <tr> tags and if you want a table inside a table using rowspan and colspan incorrectly.

Option 1: You could use 2 rows in your thead.

<thead>   
  <tr>
    <th rowspan="2">main heading1</th>   
    <th rowspan="2">main heading2</th>   
    <th colspan="3">main heading3</th>   
    <th rowspan="2">main heading4</th> 
  </tr>
  <tr>
    <th>sub heading1</th>
    <th>sub heading2</th>
    <th>sub heading3</th>
  </tr>
</thead>

Option 2: A table inside a table.

<thead>   
  <tr>
    <th>main heading1</th>   
    <th>main heading2</th>   
    <th>main heading3
      <table>
        <thead>
         <tr>
           <th>sub heading1</th>
           <th>sub heading2</th>
           <th>sub heading3</th>
         <tr>
        <thead>  
      </table> 
    </th>   
    <th>main heading4</th> 
  </tr>
</thead>
like image 148
Francois Deschenes Avatar answered Sep 20 '22 15:09

Francois Deschenes