html-form表单笔记


HTML5引入了很多更具描述性的HTML元素,例如:header、footer、nav、video、article、section等。

这些元素让HTML更易读,同时有助于搜索引擎优化和无障碍访问。

main元素让搜索引擎和开发者瞬间就能找到网页的主要内容。

表单form

input

  • placeholder占位符是用户在input输入框中输入任何东西前的预定义文本。
  • 把文本输入字段设置为必填项,添加属性required
<input type="text" placeholder="猫咪图片地址" required>

button

提交按钮:

<button type="submit">this button submits the form</button>

radio 单选

  • 每一个单选按钮都应该嵌套在它自己的label(标签)元素中。
  • 所有关联的单选按钮应该拥有相同的name属性。
  • for属性和单选按钮id属性值相等,这样label元素和它的子元素单选按钮之间创建了一种链接关系。
  • 添加checked属性,默认选中项
<label for="indoor">   
    <input id="indoor" type="radio" name="indoor-outdoor" checked>Indoor 
</label>

checkbox 复选

同radio

<label for="loving">
    <input id="loving" type="checkbox" name="personality" checked> Loving
</label>
<form action="/submit-cat-photo">
    <label for="indoor"><input id="indoor" type="radio" name="indoor-outdoor">室内</label>
    <label for="outdoor"><input  id="outdoor" type="radio" name="indoor-outdoor">室外</label><br>
    <label for="loving"><input  id="loving" type="checkbox" name="personality">忠诚</label>
    <label for="loving"><input  id="loving"t type="checkbox" name="personality">懒惰</label>
    <label for="loving"><input  id="loving" type="checkbox" name="personality">积极</label><br>
    <input type="text" placeholder="猫咪图片地址" required>
    <button type="submit">提交</button>
</form>

在这里插入图片描述

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值