HTML table元素
搬运,内容来自HTML Dog.
简单示例
<!DOCTYPE html> <html> <body> <table> <tr> <td>Row 1, cell 1</td> <td>Row 1, cell 2</td> <td>Row 1, cell 3</td> </tr> <tr> <td>Row 2, cell 1</td> <td>Row 2, cell 2</td> <td>Row 2, cell 3</td> </tr> <tr> <td>Row 3, cell 1</td> <td>Row 3, cell 2</td> <td>Row 3, cell 3</td> </tr> <tr> <td>Row 4, cell 1</td> <td>Row 4, cell 2</td> <td>Row 4, cell 3</td> </tr> </table> </body> </html>
The table element defines the table.
The tr element defines a table row.
The td element defines a data cell. These must be enclosed in tr tags, as shown above.
tr=table row=行
td=table date cell=列元素
示例2
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>Basic table</title> <style> td { border: 1px solid #999; padding: 0.1em 1em; } </style> </head> <body> <table> <tr> <td>Cats</td> <td>Dogs</td> <td>Lemurs</td> </tr> <tr> <td>Tiger</td> <td>Grey Wolf</td> <td>Indri</td> </tr> <tr> <td>Cheetah</td> <td>Cape hunting dog</td> <td>Sifaka</td> </tr> <tr> <td>Caracal</td> <td>Red fox</td> <td>Brown lemur</td> </tr> <tr> <td>Wildcat</td> <td>Fennec</td> <td>Dwarf lemur</td> </tr> </table> <!-- Link back to HTML Dog: --> <p><a href="http://www.htmldog.com/examples/"><img src="http://www.htmldog.com/badge1.gif" alt="HTML Dog"></a></p> </body> </html>