Roberto
Roberto

Reputation: 809

Is there a tag for grouping "td" or "th" tags?

Does a tag for grouping th or td elements exist?

I need something like this:

<table>
  <thead>
    <tr>
      <th></th>
      <th></th>
      <GROUP>
        <th></th>
        <th></th>
      </GROUP>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td></td>
      <td></td>
      <GROUP>
        <td></td>
        <td></td>
      </GROUP>
    </tr>
  </tbody>
</table>

No, col and colgroup (which must be inserted before the first element) are not a solution.

Upvotes: 2

Views: 1807

Answers (2)

BoltClock
BoltClock

Reputation: 724252

Does exists a tag for grouping th or td element?

Yes, it's called colgroup.

Don't want to use a colgroup? Sorry, that's how grouping table columns is done in HTML. Use the tools given to you, or don't.

Upvotes: 1

ScaisEdge
ScaisEdge

Reputation: 133380

for grouping cols (or rows ) in a html table you can use colspan (or rowspan) attribute

  <table> 
      <caption>Test Caption </caption> 
      <tr> <th colspan="2">65</th> 
        <th colspan="2">40</th> 
        <th colspan="2">20</th> 
      </tr> 
      <tr> 
        <th>Men</th> 
        <th>Women</th> 
        <th>Men</th> 
        <th>Women</th> 
        <th>Men</th> 
        <th>Women</th> 
      </tr> 
      <tr> 
        <td>82</td> 
        <td>85</td> 
        <td>78</td> 
        <td>82</td> 
        <td>77</td> 
        <td>81</td> 
      </tr>
  </table>

(or nested table)

Upvotes: 0

Related Questions