HTML - tags - th tag

revision:


Content

"th" tag : defines a header cell in a table syntax some examples


"th" tag : defines a header cell in a table

top

The <th> tag defines a header cell in an HTML table. An HTML table has two kinds of cells: header cells, which contain header information (created with the <th> element), and data cells, which contain data (created with the <td> element). The text in "th" elements are bold and centered by default. The text in "td" elements are regular and left-aligned by default.

Attributes: the <th> element supports the global attributes and events attributes.Specific attributes are:

abbr ; value: text;

specifies an abbreviated version of the content in a header cell.

colspan ; value: number;

specifies the number of columns a header cell should span.

headers ; value:header_id;

specifies one or more header cells a cell is related to.

rowspan ; value: number;

specifies the number of rows a header cell should span.

scope ; value: col, colgroup, row, rowgroup;

specifies whether a header cell is a header for a column, row, or group of columns or rows.


Syntax

top

<th> . . . </th>


some examples

top
Month Savings
January $100
January $80
Codes:
                  <style>
                      table, th, td {border: 1px solid black; margin-left: 4vw;}
                  </style>
                  <table>
                      <tr>
                        <th>Month</th>
                        <th>Savings</th>
                      </tr>
                      <tr>
                        <td>January</td>
                        <td>$100</td>
                      </tr>
                      <tr>
                        <td>January</td>
                        <td>$80</td>
                      </tr>
                    </table>
              
Month Savings
January $100
January $80
Codes:
                  <table style="background-color:#00FF00">
                      <tr>
                        <th>Month</th>
                        <th>Savings</th>
                      </tr>
                      <tr>
                        <td>January</td>
                        <td>$100</td>
                      </tr>
                      <tr>
                        <td>January</td>
                        <td>$80
                      </tr>
                    </table>