Results 1 to 8 of 8

Thread: What's the difference between <td> and <th> tag?

  1. #1
    Join Date
    May 2009
    Posts
    62
    Thanks
    19
    Thanked 3 Times in 3 Posts

    Default What's the difference between <td> and <th> tag?

    what's the big difference between <td> and <th>? When to use <td> effectively and when to use <th> effectively?

  2. #2
    Join Date
    Apr 2009
    Location
    Cognac, France
    Posts
    400
    Thanks
    2
    Thanked 57 Times in 57 Posts

    Default

    <th> defines a header cell, <td> a normal cell:

    This code will give you an example:

    HTML Code:
    <table border = "1">
    <tr>
    <th>Tag</th>
    <th>Description</th>
    </tr>
    <tr>
    <td>td</td>
    <td>Specifies a table header</td>
    </tr>
    </table>
    I rarely use <th>

  3. #3
    Join Date
    Apr 2008
    Location
    So.Cal
    Posts
    3,643
    Thanks
    63
    Thanked 517 Times in 503 Posts
    Blog Entries
    5

    Default

    the only use I have for <th> is formatting

  4. #4
    Join Date
    May 2009
    Posts
    62
    Thanks
    19
    Thanked 3 Times in 3 Posts

    Default

    so, you can use either <td> or <th> interchangeably? There is no advantage nor disadvantage in using either the two?

  5. #5
    Join Date
    Jun 2009
    Location
    Suomi
    Posts
    26
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default

    depends on how you want to comfrom to standards and how clean you want your document to be in source view.

    'i'd personaly only use <th> for its propper function as a table header.

  6. #6
    Join Date
    Jun 2009
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    It also depends on whether or not you are making a distinction between the two in your stylesheet.

    The only real inherent visual difference, as you saw in the code above, is that the <th> tag is naturally bold.

  7. #7
    Join Date
    May 2007
    Location
    Boston,ma
    Posts
    2,127
    Thanks
    173
    Thanked 207 Times in 205 Posts

  8. #8
    Join Date
    Apr 2009
    Location
    Sydney, Australia
    Posts
    110
    Thanks
    15
    Thanked 1 Time in 1 Post

    Default

    <th> is used in place of <td> to define a table header. This is used for accessibility purposes for disabled or impaired users. Not everyone can see a table (which makes accessibility for the blind difficult to interpret) so headers are encouraged by W3C accessibility guidelines to help identify and navigate a data table; with a screen reader like JAWS for example.

    <td> should only be used for data, and <th> for the values attached to that data.

    Code:
    <tr>
    		<th scope="col">Artist</th>
    		<th scope="col">Title</th>
    		<th scope="col">Price</th>
    		<th scope="col">Quantity</th>
    		<th scope="col">Sales</th>
    </tr>
    	<tr>
    		<td>Bob Dylan</td>
    		<td>Empire Burlesque</td>
    		<td>$25.00</td>
    		<td>6</td>
    		<td>$150.00</td>
    
    	</tr>

    <th> also provides print functionality.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •