html表单

本文介绍了HTML中的表单元素,包括输入框、下拉框、文本域和按钮等,并详细讲解了表单属性如placeholder、maxlength和required等,以及form标签的action、method属性,探讨了表单数据的传输方式和自动填充功能。
摘要由CSDN通过智能技术生成
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <form action="">
        账号:<input type="text" name="name"><br><br>
        密码:<input type="password" name="password"><br><br>
        性别:<input type="radio" name="sex" checked id="man">
        <label for="man">男</label>
             <input type="radio" name="sex">女<br><br>
        爱好:<input type="checkbox">跑步
            <input type="checkbox">听音乐
            <input type="checkbox" checked>打游戏
            <input type="checkbox">健身<br><br>
        邮箱:<input type="email"><br><br>
        手机:<input type="tel"><br><br>
        日期:<input type="date"><br><br>
        文件:<input type="file"><br><br>
        普通按钮:<input type="button" value="普通按钮"><br><br>
        提交按钮:<input type="submit" value="提交按钮"><br><br>
        重置按钮:<input type="reset" value="重置按钮"><br><br>
        选择水果:<select>
            <option value="">苹果</option>
            <option value="" selected>香蕉</option>
            <option value="">橘子</option>
        </select><br><br>
        你的留言:<textarea cols="30" rows="10"></textarea><br><br>
        <button type="button"><a href="http://www.baidu.com">点击去百度</a></button>
        <button type="submit"><img src="../第一节:初始HTML/作业01/初识html.png" width="100px"></button>
        <button type="reset">重置</button>

    </form>
</body>
</html>

 一.表单常用使用场景

1.网页顶部的搜索框

2.网页注册和登录

二.表单标签

1.输入框:input

<input type="text" name="name">

2.下拉框:select

<select>

            <option value="">苹果</option>

            <option value="" selected>香蕉</option>

            <option value="">橘子</option>

</select>

3.文本域:textarea

<textarea cols="30" rows="10"></textarea>

4.按钮:button

<button type="reset">重置</button>

5.input标记标签:label

<input type="radio" name="sex" checked id="man">

<label for="man">男</label>

三.表单属性

       1.placeholder:设置提示语

        2.maxlength/minlength:设置输入内容最大/最小长度

        3.required:设置必填项

        4.autofocus:设置自动获取焦点

        5.checked:设置单选或多选框的默认选中

        6.selected:设置下拉选项的默认选中

        7.multiple:设置同时可以上传多个文件

        8.disabled:设置标签禁用,标签不能被选中,内容不能被修改

        9.readonly:设置标签只读,标签可以被选中,但是内容不能修改

四.form标签及属性

form:设置表单范围

        属性:

        1.action:设置表单提交过后跳转的页面

        2.method:设置表单数据传输方式

             可选值:

             get:将表单数据伴随action的地址显示在地址栏上面,不安全,不能传输敏感数据,

                    文本或密码有name的时候,数据内容在地址栏显示  

              post:将表单数据封装在表单内部传输,相对安全  

        3.autocomplete:设置是否开启自动填充

                可选值:

                   on:默认值,开启自动填充,text必须有name值

                   off: 关闭自动填充

   

目录

 一.表单常用使用场景

1.网页顶部的搜索框

2.网页注册和登录

二.表单标签

1.输入框:input

2.下拉框:select

3.文本域:textarea

4.按钮:button

5.input标记标签:label

三.表单属性

       1.placeholder:设置提示语

        2.maxlength/minlength:设置输入内容最大/最小长度

        3.required:设置必填项

        4.autofocus:设置自动获取焦点

        5.checked:设置单选或多选框的默认选中

        6.selected:设置下拉选项的默认选中

        7.multiple:设置同时可以上传多个文件

        8.disabled:设置标签禁用,标签不能被选中,内容不能被修改

        9.readonly:设置标签只读,标签可以被选中,但是内容不能修改

四.form标签及属性

        1.action:设置表单提交过后跳转的页面

        2.method:设置表单数据传输方式

        3.autocomplete:设置是否开启自动填充

        4. novalidate:取消数据验证


 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值