TheDeveloperBlog.com

Home | Contact Us

C-Sharp | Java | Python | Swift | GO | WPF | Ruby | Scala | F# | JavaScript | SQL | PHP | Angular | HTML

HTML th Tag

HTML th Tag with html tutorial, tags, anchor, img, div, entity, textarea, marquee, p tag, heading tag, h1, h2, table, formatting, attribute, elements, ol, ul, Input Types, block element tag, inline element tag, html tags, phrase tag, head, body, form, lists, symbols etc.

<< Back to HTML

HTML <th> tag

In an HTML table there are two types of cells:

  • Header cell - It contains the header information (created using <th> element)
  • Data Cells - It contains the main data of the table (created using <td> element).

HTML <th> tag is used to define the header cells of an HTML table. The header cell renders as bold and centered by default on the browser, but you can change its default style using CSS properties.

The <th> tag must be used as a child element of the <tr> element within <table> element. The size of the table is auto-adjustable as per the content size.

Syntax

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

Following are some specifications about the HTML <th> tag

Display None
Start tag/End tag Both Start and End tag
Usage HTML Tables

Example

<!DOCTYPE html>
<html>
<head>
	<title>HTML th Tag</title>
	<style>
	table{
                     border-collapse: collapse; 
	       width: 70%;}
	  th,td{
		background-color: #528b8b;
		padding: 10px;
		}
</style>
</head>
<body>
 <h2>Example of th tag</h2>
  <table border="1">
  	   <tr>
  	   <th>Month</th>
  	    <th>Date</th>
  	    </tr>
                <tr>
        	     <td>January</td>
                  <td>20.01.2018</td>
            </tr>
        	<tr>
        	       <td>February</td>
        	       <td>01.02.2018</td>
        	</tr>
        	<tr>
        	    <td>March</td>
        	    <td>15.03.2018</td>
               </tr>
  </table>
</body>
</html>
Test it Now

Output:

HTML th tag

Attribute:

Tag-specific attributes:

Attribute Value Description
abbr text It defines the abbreviated version of content of the header cell. (Not Supported in HTML5)
align left
right
center
justify
char
It specifies the alignment of the content of the header cell. (Not Supported in HTML5)
axis category_name It Categorizes header Cells(Not Supported in HTML5)
bgcolor rgb(x,x,x)
#xxxxxx
Color_name
It sets the background color of the header cell. (Not Supported in HTML5)
char character It specifies the alignment of the content of the header cell to the character. (Not Supported in HTML5)
charoff number It specifies the number of characters the header cell content will be aligned from the character specified by the char attribute. (Not Supported in HTML5)
colspan number It determines the number of columns a header cell should span.
headers header_id It determines a space-separated list of header cells which contains information of the cells is related.
height %
pixels
It determines the height of a table header cell. (Not Supported in HTML5)
nowrap nowrap If it sets then content inside the header cell should not wrap. (Not Supported in HTML5)
rowspan number It determines the number of rows a cell should span.
scope col
colgroup
row
rowgroup
It specifies the cells that the header element relates to. (Not Supported in HTML5)
valign top
middle
bottom
baseline
It determines the vertical alignment of the cell content. (Not Supported in HTML5)
width %
pixels
It determines the width of the header cell.(Not Supported in HTML5)

Global attribute:

The <th> tag supports the Global attributes in HTML.

Event attribute:

The <th> tag supports the Event attributes in HTML.

Supporting Browsers

Elementchrome browser Chromeie browser IEfirefox browser Firefoxopera browser Operasafari browser Safari
<th>YesYesYesYesYes
Next TopicHTML thead Tag




Related Links:


Related Links

Adjectives Ado Ai Android Angular Antonyms Apache Articles Asp Autocad Automata Aws Azure Basic Binary Bitcoin Blockchain C Cassandra Change Coa Computer Control Cpp Create Creating C-Sharp Cyber Daa Data Dbms Deletion Devops Difference Discrete Es6 Ethical Examples Features Firebase Flutter Fs Git Go Hbase History Hive Hiveql How Html Idioms Insertion Installing Ios Java Joomla Js Kafka Kali Laravel Logical Machine Matlab Matrix Mongodb Mysql One Opencv Oracle Ordering Os Pandas Php Pig Pl Postgresql Powershell Prepositions Program Python React Ruby Scala Selecting Selenium Sentence Seo Sharepoint Software Spellings Spotting Spring Sql Sqlite Sqoop Svn Swift Synonyms Talend Testng Types Uml Unity Vbnet Verbal Webdriver What Wpf