小白教程
所有教程
关于
Search
172.70.100.232
172.70.100.232
参数设置
贡献
退出
操作
编辑
移动
保护
信息
历史
删除
查看“HTML表格”的源代码
本页内容
上一节:
HTML网站图标Favicon
下一节:
HTML表格边框
因为以下原因,您没有权限编辑本页:
您请求的操作仅限属于该用户组的用户执行:
用户
您可以查看和复制此页面的源代码。
[[Category:HTML教程|22]] HTML 表格允许 Web 开发人员将数据排列成行和列。 <html> <table class="table"> <thead> <tr> <th scope="col">#</th> <th scope="col">First</th> <th scope="col">Last</th> <th scope="col">Handle</th> </tr> </thead> <tbody> <tr> <th scope="row">1</th> <td>Mark</td> <td>Otto</td> <td>@mdo</td> </tr> <tr> <th scope="row">2</th> <td>Jacob</td> <td>Thornton</td> <td>@fat</td> </tr> <tr> <th scope="row">3</th> <td colspan="2">Larry the Bird</td> <td>@twitter</td> </tr> </tbody> </table> </html> == 定义 HTML 表格 == HTML 中的表格由行和列内的表格单元格组成 <sample title="" hererun="s" desc="一个简单的 HTML 表格:" > <table> <tr> <th>姓名</th> <th>年龄</th> <th>性别</th> </tr> <tr> <td>小白</td> <td>11</td> <td>男</td> </tr> <tr> <td>教程</td> <td>22</td> <td>女</td> </tr> </table> </sample> == 单位表格 == 每个表格单元格由一个 ''' <nowiki><td></nowiki> '''和一个''' <nowiki></td></nowiki> '''标签定义。 ''' <nowiki>td</nowiki> ''' 代表表格数据。 ''' <nowiki><td></nowiki> '''和之间''' <nowiki></td></nowiki> '''的所有内容都是表格单元格的内容。 <sample title="" hererun="s" desc="" > <table> <tr> <td>Emil</td> <td>Tobias</td> <td>Linus</td> </tr> </table> </sample> <blockquote> 注意:表格数据元素是表格的数据容器。 可以包含各种 HTML 元素;文本、图像、列表、其他表格等。 </blockquote> == 表行 == 每个表格行都以 a 开头, 以标签''' <nowiki><tr></nowiki> '''结尾。''' <nowiki></tr></nowiki> ''' ''' <nowiki>tr</nowiki> ''' 代表表格行。 <sample title="" hererun="s" desc="" > <table> <tr> <td>Emil</td> <td>Tobias</td> <td>Linus</td> </tr> <tr> <td>16</td> <td>14</td> <td>10</td> </tr> </table> </sample> 您可以在表格中包含任意数量的行,只需确保每行中的单元格数相同。 注意:有时一行中的单元格可能少于或多于另一行。您将在后面的章节中了解这一点。 == 表头 == 有时您希望您的单元格成为标题,在这些情况下使用 ''' <nowiki><th></nowiki> '''标签而不是 ''' <nowiki><td></nowiki> '''标签: <sample title="" hererun="s" desc="让第一行成为表格标题:" > <table> <tr> <th>Person 1</th> <th>Person 2</th> <th>Person 3</th> </tr> <tr> <td>Emil</td> <td>Tobias</td> <td>Linus</td> </tr> <tr> <td>16</td> <td>14</td> <td>10</td> </tr> </table> </sample> 默认情况下,''' <nowiki><th></nowiki> '''元素中的文本是粗体且居中的,但您可以使用 CSS 进行更改。
返回至“
HTML表格
”。
上一节:
HTML网站图标Favicon
下一节:
HTML表格边框