<th> - HTML CSS HTML Tag

HTML CSS examples for HTML Tag:th

Introduction

The th element marks a header cell and can differentiate between data and the descriptions of that data.

The th Element summary

Item Value
Element: th
Permitted Parents: The tr element
Local Attributes: colspan, rowspan, scope, headers
Tag Style: Start and end tags
New in HTML5? No
Changes in HTML5 The scope attribute is obsolete. Use the scope attribute on the th element instead. The abbr, axis, align, width, char, charoff, valign, bgcolor, height, and nowrap attributes are obsolete, use CSS instead.

Style Convention

th {
   display: table-cell;
   vertical-align: inherit;
   font-weight: bold;
   text-align: center;
}

The following code shows how to add th elements to the table to provide some context for the data values contained in the td elements.

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
   <head> 
      <title>Example</title> 
   </head> 
   <body> 
      <table> 
         <tbody>
            <tr> 
               <th>Rank</th> 
               <th>Name</th> 
               <th>Level</th> 
               <th>Size</th> 
            </tr> 
            <tr> 
               <th>Favorite:</th> 
               <td>CSS</td> 
               <td>HTML</td> 
               <td>SQL</td> 
            </tr> 
            <tr> 
               <th>2nd Favorite:</th> 
               <td>Java</td> 
               <td>C</td> 
               <td>C++</td> 
            </tr> 
            <tr> 
               <th>3rd Favorite:</th> 
               <td>Javascript</td> 
               <td>Python</td> 
               <td>Ruby</td> 
            </tr> 
         </tbody>
      </table>  
   </body><!--from w w w  . java2s .  c  o m-->
</html>

Related Tutorials