首页 > 代码库 > HTML之表格制作
HTML之表格制作
如何制作一个表格?
如何制作一个表格呢? 观察如下代码:
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>table</title> </head> <body> <table border=‘1‘ cellpadding="10" cellspacing=‘10‘ width="500" height="400" bgcolor="red"> <caption style="caption-side:bottom; color:red; font-size:40px"> <b>花名册</b></caption> <thead bgcolor="green"> <tr> <th align="right">姓名</th> <th style="text-align:right">班级</th> <th align="right">电话</th> </tr> </thead> <tbody bgcolor="yellow"> <tr> <td valign="bottom">张三</td> <td rowspan="2" valign="top" background="picture.jpg" ;>材料42</td> <td>88888888</td> </tr> <tr> <td valign="bottom">李四</td> <td> <ul> <li>77777777</li> <li>66666666</li> <li>55555555</li> </ul> </td> </tr> <tr> <td valign="bottom">王五</td> <td colspan="2">材料45(no phone)</td> </tr> </tbody> </table> </body> </html>
上述html便可以得到如下表格:
当然,还有不少关于表格的特性我没有表现出来,比如 在table标签使用 border-collapse=collapse; 可以用一条线分离各个数据。
上述html代码中,我在标签中用了内联样式,这是为了方便大家直接的观察,但是根据结构与变现分离的原则,这些样式的实现最好在外部新建一个css。还需要注意的是:在表格中我们最好使用<thead><tbody><tfoot>之类的标签,这种语义化明显的标签不仅方便开发人员阅读,也有利于浏览器解析代码。
HTML之表格制作
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。