Blogger Information
Blog 29
fans 0
comment 0
visits 14939
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
Html 表格和表单练习
cool442
Original
636 people have browsed it

Html 表格和表单练习

1. 表格

- 复习表格标签结构

标签 说明
<table></table> 表格
<caption></caption> 表格标题
<thead></thead> 表头
<tbody></tbody> 表格主体
<tfoot></tfoot> 表格尾部,一般用来注示说明
<tr></tr>
<th></th> 列,用于表头内
<td></td> 列,用于表格主体内
rowspan=数字 合并列属性,要删除多余的 td
colspan=数字 合并行属性,要删除多余的 td

- 练习

  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8" />
  5. <meta http-equiv="X-UA-Compatible" content="IE=edge" />
  6. <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  7. <title>小学课程表</title>
  8. </head>
  9. <body>
  10. <table
  11. border="1"
  12. width="500"
  13. cellspacing="0"
  14. cellpadding="5"
  15. align="center"
  16. >
  17. <caption>
  18. <h2>小学课程表</h2>
  19. </caption>
  20. <thead>
  21. <tr>
  22. <th>时间</th>
  23. <th>星期一</th>
  24. <th>星期二</th>
  25. <th>星期三</th>
  26. <th>星期四</th>
  27. <th>星期五</th>
  28. </tr>
  29. </thead>
  30. <tbody align="center">
  31. <tr>
  32. <td rowspan="4">上午</td>
  33. <td>语文</td>
  34. <td>语文</td>
  35. <td>语文</td>
  36. <td>语文</td>
  37. <td>语文</td>
  38. </tr>
  39. <tr>
  40. <td>语文</td>
  41. <td>语文</td>
  42. <td>语文</td>
  43. <td>语文</td>
  44. <td>语文</td>
  45. </tr>
  46. <tr>
  47. <td>语文</td>
  48. <td>语文</td>
  49. <td>语文</td>
  50. <td>语文</td>
  51. <td>语文</td>
  52. </tr>
  53. <tr>
  54. <td>语文</td>
  55. <td>语文</td>
  56. <td>语文</td>
  57. <td>语文</td>
  58. <td>语文</td>
  59. </tr>
  60. <tr>
  61. <td colspan="6">休息</td>
  62. </tr>
  63. <tr>
  64. <td rowspan="3">下午</td>
  65. <td>语文</td>
  66. <td>语文</td>
  67. <td>语文</td>
  68. <td>语文</td>
  69. <td>语文</td>
  70. </tr>
  71. <tr>
  72. <td>语文</td>
  73. <td>语文</td>
  74. <td>语文</td>
  75. <td>语文</td>
  76. <td>语文</td>
  77. </tr>
  78. <tr>
  79. <td>语文</td>
  80. <td>语文</td>
  81. <td>语文</td>
  82. <td>语文</td>
  83. <td>语文</td>
  84. </tr>
  85. </tbody>
  86. <tfoot align="center">
  87. <tr>
  88. <td>备注</td>
  89. <td colspan="5">每天下午课后辅导到18:00。</td>
  90. </tr>
  91. </tfoot>
  92. </table>
  93. </body>
  94. </html>

运行效果


2. 表单

- 复习表单常用标签

标签说明 语法
文本标签 <label for=""></label>
文本框 <input type="text" name="" id="" />
按钮 <input type="button" value="按钮" />
密码框 <input type="password" name="" id="" />
日期框 <input type="date" name="" id="" />
单选按钮 <input type="radio" name="" id="" />
多选按钮 <input type="checkbox" name="" id="">

- 练习

  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8" />
  5. <meta http-equiv="X-UA-Compatible" content="IE=edge" />
  6. <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  7. <title>小学课程表</title>
  8. </head>
  9. <body>
  10. <form>
  11. <h3>注册表单</h3>
  12. <br />
  13. <label for="call">外号:</label>
  14. <input type="text" name="call" id="call" /><br />
  15. <label>性别:</label>
  16. <label for="man"></label>
  17. <input type="radio" name="sex" id="man" />
  18. <label for="women"></label>
  19. <input type="radio" name="sex" id="women" /><br />
  20. <label for="bsd">生日:</label>
  21. <input type="date" name="bsd" id="bsd" /><br />
  22. <label for="like">爱好:</label>
  23. <label for="football">足球</label>
  24. <input type="checkbox" name="football" id="football" />
  25. <label for="baskeball">篮球</label>
  26. <input type="checkbox" name="baskeball" id="baskeball" />
  27. <label for="fish">钓鱼</label>
  28. <input type="checkbox" name="fish" id="fish" />
  29. <label for="run">跑步</label>
  30. <input type="checkbox" name="run" id="run" /><br />
  31. <label for="password">登录密码:</label>
  32. <input type="password" name="password" id="password" /><br />
  33. <input type="button" value="提交" />
  34. </form>
  35. </body>
  36. </html>

运行效果(没做样式)

Correcting teacher:PHPzPHPz

Correction status:qualified

Teacher's comments:
Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments
Author's latest blog post