博客列表 >2020年4月3日作业--HTML5网页元素

2020年4月3日作业--HTML5网页元素

暴宇
暴宇原创
2020年04月13日 19:52:48677浏览

HTML5网页元素

1.链接元素

1.1代码

  1. <a href="" alt="">这是一个链接</a>
  2. <img src="1.jpg" alt="" width="100" />

1.2效果

链接元素效果图

2.列表元素

2.1代码

  1. <ul>
  2. <li>无序列表1</li>
  3. <li>无序列表2</li>
  4. <li>无序列表3</li>
  5. </ul>
  6. <ol>
  7. <li>有序列表1</li>
  8. <li>有序列表2</li>
  9. <li>有序列表3</li>
  10. </ol>

2.2效果

列表元素效果图

3.表格元素

3.1代码

  1. <table>
  2. <caption>表格标题</caption>
  3. <thead>
  4. <tr>
  5. <th>列标题1</th>
  6. <th>列标题2</th>
  7. </tr>
  8. </thead>
  9. <tbody>
  10. <tr>
  11. <td>1组内容1</td>
  12. <td>1组内容2</td>
  13. </tr>
  14. </tbody>
  15. <tbody>
  16. <tr>
  17. <td>2组内容1</td>
  18. <td>2组内容2</td>
  19. </tr>
  20. </tbody>
  21. <tfoot>
  22. <tr>
  23. <td colspan="2">页脚内容</td>
  24. </tr>
  25. </tfoot>
  26. </table>

3.2效果

表格元素

4.表单元素

4.1代码

  1. <h3>常用表单类型</h3>
  2. <form action="reg.php" method="POST" id="formid">
  3. <section>
  4. <label for="username">用户名:</label>
  5. <input type="text" id="username" name="username" required autofocus />
  6. </section>
  7. <section>
  8. <label for="password">密码:</label>
  9. <input type="password" id="password" name="password" required />
  10. </section>
  11. <section>
  12. <label for="telid">电话:</label>
  13. <input type="tel" name="tel" id="telid" />
  14. </section>
  15. <section>
  16. <label for="">性别:</label>
  17. <input type="radio" id="radiom" name="radiom" value="男" />
  18. <label for="radiom"></label>
  19. <input type="radio" id="radiow" name="radiow" value="女" />
  20. <label for="radiow"></label>
  21. <input type="radio" id="radiow" name="radiox" value="保密" checked />
  22. <label for="radiox">保密</label>
  23. </section>
  24. <section>
  25. <label for="">兴趣:</label>
  26. <input
  27. type="checkbox"
  28. id="checkbox1"
  29. name="checkbox[]"
  30. value="php"
  31. checked
  32. />
  33. <label for="checkbox1">php</label>
  34. <input
  35. type="checkbox"
  36. name="checkbox[]"
  37. id="checkbox2"
  38. value="html"
  39. checked
  40. />
  41. <label for="checkbox2">html</label>
  42. </section>
  43. <section>
  44. <label for="file">上传头像:</label>
  45. <input type="file" name="file" id="file" />
  46. </section>
  47. <section>
  48. <label for="listdata">选择学习内容:</label>
  49. <input type="text" id="listdata" name="listdata" list="listdataid" />
  50. <datalist id="listdataid">
  51. <option value="php"></option>
  52. <option value="css"></option>
  53. <option value="javascript"></option>
  54. </datalist>
  55. </section>
  56. <section>
  57. <label for="imgbutton">图片形式的提交按钮:</label>
  58. <input
  59. type="image"
  60. src="button.jpg"
  61. alt="submit"
  62. name="submit"
  63. width="100"
  64. id="imgbutton"
  65. />
  66. </section>
  67. <section>
  68. <label for="hidden">隐藏域:</label>
  69. <input type="hidden" name="hidden" id="hidden" />
  70. </section>
  71. </form>
  72. <hr />
  73. <h3>新增表单类型</h3>
  74. <section>
  75. <label for="emil">邮箱:</label>
  76. <input type="email" name="email" id="email" form="formid" />
  77. </section>
  78. <section>
  79. <label for="dateid">日期:</label>
  80. <input type="date" name="datename" id="dateid" form="formid" />
  81. </section>
  82. <section>
  83. <label for="localdate">本地日期:</label>
  84. <input
  85. type="datetime-local"
  86. name="localdate"
  87. id="localdate"
  88. form="formid"
  89. />
  90. </section>
  91. <section>
  92. <label for="urlid">URL地址:</label>
  93. <input type="url" name="urlname" id="urlid" form="formid" />
  94. </section>
  95. <section>
  96. <label for="numberid">数值:</label>
  97. <input type="number" name="number" id="numberid" form="formid" />
  98. </section>
  99. <section>
  100. <label for="rangeid">范围拖动条:</label>
  101. <input
  102. type="range"
  103. name="range"
  104. id="rangeid"
  105. form="formid"
  106. min="1"
  107. max="10"
  108. />
  109. </section>
  110. <section>
  111. <label for="secrchid">搜索框:</label>
  112. <input type="search" name="search" id="searchid" form="formid" />
  113. </section>
  114. <section>
  115. <label for="colorid">拾色器:</label>
  116. <input type="color" name="color" id="colorid" />
  117. </section>
  118. <button
  119. type="submit"
  120. formaction="reg.php"
  121. formmethod="POST"
  122. formtarget="_blank"
  123. >
  124. POST提交
  125. </button>
  126. <button
  127. type="submit"
  128. formaction="reg.php"
  129. formmethod="GET"
  130. formtarget="_blank"
  131. >
  132. GET提交
  133. </button>

4.2效果

表单元素

5.总结

5.1网页元素主要包含以下元素

  • 链接元素,如<a>,<img>
  • 列表元素,如无序列表<ul><li>,有序列表<ol><li>
  • 表格元素,如表格<table>,表格标题<caption>,列标题<thead>,表格主体<tbody>,表格注脚<tfoot>
  • 表单元素,如表单<form>,文本框<input>,标签<label>,按钮<button>

    5.2网页元素的属性

    (1)链接元素的常用属性

  • herf:a链接地址
  • src:img链接地址

    (2)列表元素的常用属性

  • start:设置起始序号

    (3)表格元素的常用属性

  • border:设置表格边框
  • cellpadding:设置单元格内边距
  • cellspacing:设置边框间隙
  • align:单元格内容水平居中
  • bgcolor:设置背景色
  • width:设置表格宽度
  • height:设置表格高度

(4)表单元素的常用属性

  • type:设置文本框的类型,主要有文本text,密码password,单选radio,多选checkbox,图片image,文件file,隐藏hidden,邮件email,日期date,时间datetime,本地时间datetime-local,电话tel,数值number,拖动条range,搜索search,拾色器color
  • form:控件所属表
  • disabled:禁用元素
  • name:请求参数的名称
  • value:请求参数的值
  • 事件属性:onclick鼠标单击触发,onchange失去焦点且值变化时触发,oninput值变化时触发(不失去焦点),onfocus获取焦点时触发,onblur失去焦点时触发,onkeydown按下键盘触发,onkeyup抬起键盘触发,onselect选择文本时触发
声明:本文内容转载自脚本之家,由网友自发贡献,版权归原作者所有,如您发现涉嫌抄袭侵权,请联系admin@php.cn 核实处理。
全部评论
文明上网理性发言,请遵守新闻评论服务协议