Whats the difference between TH and TD
thanks
| SitePoint Sponsor |
Whats the difference between TH and TD
thanks



Semantically they are meant to convey different meanings.Originally Posted by simplecode
TH says "this cell's content is meant to tell you about a row or column"
TD says "this cell's content is meant to convey the actual information in the table".
Most browsers render text in a TH centered and bold by default.
Otherwise, if I recall rightly, they may be used interchangeably, BUT they have different semantic meanings so that should be avoided.
Ed Seedhouse
how both works
drawback or advantags of both....
few example with explaination will be appriciated
thanks


TH is a table header cell. It contains the header for a column, column group, row or row group.
TD is a table data cell. It contains a piece of tabular data.
Birnam wood is come to Dunsinane
few example with explaination will be appriciated




Take this example:
The <th> (short for table heading) elements in the <thead> portion of the table, are the headings that sit at the top of each column. The scope attribute (can be row or col) tells you that they refer to the column of data below them. Think of them like an <h1> for the table column.Code:<table> <thead> <tr> <th scope="col">Some Foos</th> <th scope="col">Some Bars</th> </tr> </thead> <tbody> <tr> <td>Foo</td> <td>Bar</td> </tr> <tr> <td>Foo2</td> <td>Bar2</td> </tr> </tbody> </table>
The <td> (short for table data) elements in the <td> portion of the table contain the data that the <th> refers to.
See also: http://www.w3schools.com/html/html_tables.asp
Olly Hodgson
thinkdrastic.net


HTML Code:<table summary="Vote results: 30% yes, 70% no"> <caption>Results of the vote</caption> <thead> <tr> <th id="h-sex">Sex</th> <th id="h-yes">Yes</th> <th id="h-no">No</th> </tr> </thead> <tfoot> <tr> <th id="h-total">Total</th> <td headers="h-total h-yes">30%</td> <td headers="h-total h-no">70%</td> </tr> </tfoot> <tbody> <tr> <th headers="h-sex" id="h-m">Men</th> <td headers="h-m h-yes">36%</td> <td headers="h-m h-no">64%</td> </tr> <tr> <th headers="h-sex" id="h-w">Women</th> <td headers="h-w h-yes">28%</td> <td headers="h-w h-no">72%</td> </tr> <tbody> </table>Code:Results of the vote Sex Yes No Men 36% 64% Women 28% 72% Total 30% 70%
Birnam wood is come to Dunsinane
Bookmarks