Table head

if i want to include all tables heading in the head element how can i do it with morning, afternoon and Evening??

Saturday Sunday
Morning Work Relax
Afternoon
Evening Dinner

Hi there,

If you’re asking what I think you’re asking:

<table>
  <thead>
    <tr>
      <th>Morning</th>
      <th>Afternoon</th>
      <th>Evening</th>
    </tr>
  </thead>
</table>

If this isn’t what you’re looking for, could you supply the code you’re working with? :slight_smile:

1 Like

thank you but the th are not in one tr .this is the code

https://www.codecademy.com/courses/learn-html/lessons/html-tables/exercises/rowspan
in the left there is exemple

<table>
  <tr> <!-- Row 1 -->
    <th></th>
    <th>Saturday</th>
    <th>Sunday</th>
  </tr>
  <tr> <!-- Row 2 -->
    <th>Morning</th>
    <td rowspan="2">Work</td>
    <td rowspan="3">Relax</td>
  </tr>
  <tr> <!-- Row 3 -->
    <th>Afternoon</th>
  </tr>
  <tr> <!-- Row 4 -->
    <th>Evening</th>
    <td>Dinner</td>
  </tr>
</table>

If you look at the example, “Morning,” “Afternoon,” and “Evening” are all headings–as shown with the <th> tag (denoting a table header)

If you’re asking if those headers can be included within the <thead> tag, they cannot. The table header (<thead>) always renders at the top of a table. (<tfoot> always rendering at the bottom of a table)

1 Like

thank you so much . so if i nested them (“Morning,” “Afternoon,” and “Evening”) in tbody is that okey??

Semantics wise this–

<table>
  <thead>
    <tr>
      <th></th>
      <th>Saturday</th>
      <th>Sunday</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <th>Morning</th>
      <td>Work</td>
      <td>Relax</td>
    </tr>
    <tr>
      <th>Afternoon</th>
      <td></td>
      <td></td>
    </tr>
    <tr>
      <th>Evening</th>
      <td>Dinner</td>
      <td></td>
    </tr>
  </tbody>
</table>

–is what you would want to do.

yes, exactly. because at the beginning i want to sectioned my table to : thead , t body and tfoot
i was think that : Saturday, Sunday, Morning, Afternoon are thead.
but after your reply i ask if they are not thead so can i add them like tbody ?
thank you again.

1 Like

This topic was automatically closed 41 days after the last reply. New replies are no longer allowed.