博主信息
博文 41
粉丝 0
评论 1
访问量 41602
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
HTML 常用表单属性值
kong
原创
644人浏览过

参考

https://developer.mozilla.org/zh-CN/docs/Web/HTML/Element/Input

  1. input标签 type属性值:
  2. button: 按钮
  3. checkbox: 复选框
  4. radio: 单选
  5. color: 取色器
  6. date: 年、月、日
  7. month: 年和月
  8. time: 只有时间
  9. datetime-local: 日期和时间
  10. email: 邮箱地址
  11. file: 上传文件
  12. hidden: 隐藏不显示
  13. image: 可以加入图片,要有src,alt属性搭配
  14. number: 数字
  15. password: 密码
  16. range: 范围组件
  17. reset: 重置
  18. submit: 提交
  19. search: 搜索
  20. tel: 电话
  21. text: 文本,默认值
  22. url: 支持验证参数
  23. week: 年和周数组成的日期

代码结构

  1. <form action="login.php" method="POST">
  2. <fieldset style="display: inline-grid; gap: 1em">
  3. <legend>账号注册</legend>
  4. <div class="name">
  5. <label for="name">账号</label>
  6. <input
  7. type="text"
  8. placeholder="创建昵称"
  9. name="names"
  10. id="name"
  11. required
  12. autofocus
  13. />
  14. </div>
  15. <div class="name">
  16. <label for="html">html</label>
  17. <input type="checkbox" id="html" name="html" required />
  18. <label for="php">php</label>
  19. <input type="checkbox" id="php" name="php" required />
  20. </div>
  21. <div class="name">
  22. <label for="htmls">html</label>
  23. <input type="radio" id="htmls" name="web" required />
  24. <label for="phps">php</label>
  25. <input type="radio" id="phps" name="web" required />
  26. </div>
  27. <div class="color">
  28. <label for="color">颜色:</label>
  29. <input type="color" name="color" id="color" />
  30. </div>
  31. <div class="date">
  32. <label for="date">年、月、日:</label>
  33. <input type="date" name="date" id="date" />
  34. </div>
  35. <div class="month">
  36. <label for="month">年和月:</label>
  37. <input type="month" name="month" id="month" />
  38. </div>
  39. <div class="time">
  40. <label for="time">时间</label>
  41. <input type="time" name="time" id="time" />
  42. </div>
  43. <div class="time">
  44. <label for="datetime-local">日期和时间</label>
  45. <input
  46. type="datetime-local"
  47. name="datetime-local"
  48. id="datetime_local"
  49. />
  50. </div>
  51. <div class="email">
  52. <label for="email">邮箱:</label>
  53. <input
  54. type="email"
  55. name="email"
  56. id="email"
  57. placeholder="绑定邮箱"
  58. required
  59. />
  60. </div>
  61. <div class="file">
  62. <label for="file">上传文件</label>
  63. <input type="file" name="file" id="file" />
  64. </div>
  65. <div class="file">
  66. <label for="hidden">隐藏</label>
  67. <input type="hidden" name="hidden" id="hidden" />
  68. </div>
  69. <div class="image">
  70. <label for="image">图片</label>
  71. <input type="image" src="" alt="暂无" name="image" id="image" />
  72. </div>
  73. <div class="number">
  74. <label for="number">手机号</label>
  75. <input
  76. type="number"
  77. name="number"
  78. id="number"
  79. placeholder="填写手机号"
  80. />
  81. </div>
  82. <div class="number">
  83. <label for="number">数字</label>
  84. <input type="number" name="number" id="number" />
  85. </div>
  86. <div class="paw">
  87. <label for="password"> 密码: </label>
  88. <input
  89. type="password"
  90. name="password"
  91. placeholder="****"
  92. id="password"
  93. required
  94. />
  95. <button type="button" disabled>显示</button>
  96. </div>
  97. <div class="range">
  98. <label for="range">选取范围</label>
  99. <input type="range" name="range" id="range" />
  100. </div>
  101. <div class="reset">
  102. <label for="reset">重置</label>
  103. <input type="reset" name="reset" value="重置" id="reset" />
  104. </div>
  105. <div class="search">
  106. <label for="search">搜索</label>
  107. <input type="search" name="search" id="search" />
  108. </div>
  109. <div class="tel">
  110. <label for="tel">电话</label>
  111. <input type="tel" name="tel" id="tel" />
  112. </div>
  113. <div class="url">
  114. <label for="url">电话</label>
  115. <input type="url" name="url" placeholder="可以填写参数" id="url" />
  116. </div>
  117. <div class="week">
  118. <label for="week">年和周数组成的日期</label>
  119. <input type="week" name="week" placeholder="可以填写参数" id="week" />
  120. </div>
  121. <button type="submit">登录</button>
  122. </fieldset>
  123. </form>

案例截图

总结

不要忘记标签上的属性,可以带来很多便利之处,具体参考顶部文档链接

批改老师:PHPzPHPz

批改状态:合格

老师批语:不是作业内容可以直接在博客中发布
本博文版权归博主所有,转载请注明地址!如有侵权、违法,请联系admin@php.cn举报处理!
全部评论 文明上网理性发言,请遵守新闻评论服务协议
0条评论
作者最新博文
关于我们 免责申明 意见反馈 讲师合作 广告合作 最新更新 English
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送
PHP中文网APP
随时随地碎片化学习
PHP中文网抖音号
发现有趣的

Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号

  • 登录PHP中文网,和优秀的人一起学习!
    全站2000+教程免费学