Loading...
HTML <th> Tag

HTML <th> Tag

In this tutorial, we will learn about th tag in HTML with the help of examples.


<th> Tag

Th tag <th> is used to add footer to the HTML table.

Note : The text in <th> tag are bold and centered by default.

Syntax

<th>..........</th>

Example

<!DOCTYPE html>
<html>
  <head>
    <title>th tag</title>
  </head>
  <body>
    <table>
      <thead>
      <tr>
        <th>First Name</th>
        <th>Last Name</th>
        <th>Age</th>
      </tr>
      </thead>
      <tbody>
      <tr>
        <td>Sunny</td>
        <td>Chaudhary</td>
        <td>20</td>
      </tr>
      <tr>
      </tbody>
      <tfoot>
        <td>Anu</td>
        <td>Chaudhary</td>
        <td>19</td>
      </tr>
      </tfoot>
    </table>
  </body>
</html>

Output :

Image Not Loaded

Specific Attribute

Attribute Value Description
abbr abbreviated_text It specifies an abbreviated version of the content in a cell
align right
left
center
justify
char
It is used for visual alignment
axis name It is used to specify a category for this th
bgcolor rgb(x,x,x)
#hexcode
color_name
It specifies the background color of the table
char character It specifies which character to align text on align = char
charoff pixels
percentage(%)
It specifies an alignment offset(either in pixels or percentage value) against the first character as specified with the char attribute. It is used when align = char
colspan number It specifies the number of columns the current cell spans accross
header height It specifies a space-seperated list of header cells that contain information about this cell. The value needs to correspond with the id of the header cell(which is set using the id attribute). This attribute is useful for non-visual browsers
height pixels It specify the height of the header cell
nowrap nowrap It is used to prevents text from automatically wrapping
rowspan numbers It is used to specify the number of rows the current cell spans across
scope col
colgroup
row
rowgroup
It is used to specify whether a header cell is a header for a column, row, or group of columns or rows
valign top
middle
bottom
baseline
It is used for vertical alignment
width pixels
percentage(%)
It is used to specify the width of the table

Global Attribute

Th Tag support all the global attributes of HTML.


Event Attribute

Th Tag support all the event attributes of HTML.


Next Tutorial

We hope that this tutorial helped you develop better understanding of the concept of <th> tag in HTML.

Keep Learning : )

In the next tutorial, you'll learn about HTML <thead> Tag.

- Related Topics