Difference of table <tr><th><tb>

(1) Let's talk about the <tr> tag first

<table> is the upper level tag of
<tr> <tr> must be in a <table></table>, it cannot be used alone, it is equivalent to the attribute tag of <table>. 
<tr>...</tr> Definition A row of tags, multiple groups of cells defined by <td> or <th> tags can be created within a group of row tags.
<table> indicates a table, <tr> indicates a row in the middle of the table 
<td> indicates a column in the row, which needs to be nested in the middle of <tr></tr>

Here is an example: (two rows and two columns) 

Java code 
  1. <table>   
  2. <tr>   
  3. <td>Name</td>  
  4. <td>数量</td>   
  5. </tr>   
  6. </table>  

 

 

(2) <th> tag

<th> needs to be nested in <tr>, and <tr> is nested in <table>.
<th>...</th> defines the header cell. The text in the table will appear in bold. <th> and <td> also mark a cell, the difference is that the text in the cell marked by <th> appears in bold, which can be seen as:
<th>Website</th> The display effect is equivalent to <td><b>text</b></td>

When used, the <th> tag must be placed inside the <tr> tag

 

(3) <td> tag

<td>...</td> defines cell tags, a group of <td> tags will create a cell, <td> tags must also be placed inside <tr> tags.

<th> is the table title, the attribute summary is the abstract, the <caption> tag is the header description, the <thead> tag is the table header, the <tbody> tag is the table body content, and the <tfoot> tag is the table tail.

Tip: Some of the differences that are often encountered in common use:

<th> is not only bold, but also centered
<caption> is also centered, and if the table has a border, the caption is not within the border.
Valid tags contained within the tfood element are: 
td 
th
tr
Any given table object is only Can define a tfoot.

 

The basic code format for making a table: 

Java code 
  1. <table>  
  2. <caption></caption>  
  3. <thead>  
  4. <tr>  
  5. <th></th>  
  6. </tr>  
  7. </thead>  
  8. <tbody>  
  9. <tr>  
  10. <td></td>  
  11. </tr>  
  12. </tbody>  
  13. <tfoot>  
  14. <tr>  
  15. <td></td>  
  16. </tr>  
  17. </tfoot>  
  18. </table>  

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326520843&siteId=291194637