HTML5-form表单总结

1. form表单的属性 

  • form标签的属性
form标签的属性
action跳转的路径

  • 绝对路径-------从盘符开始,找到你所需要的文件的路径 路径+文件的名称(如:D:\云计算上课代码\lianxi\lianxi01.html)
  • 相对路径-------当前源文件和目标文件的相对位置 (如:..\lianxi\lianxi01.html)相对位置前需手动输入 ..\
method明确表单提交的方式(get/post)默认值为get

  • get-------会把用户信息暴露在地址栏上
  • post-------相对于get较安全

 2. form表单元素

  • 表单元素(文本框,密码框,下拉列表框等等),一般由 inputtextareaselect 标签构成,需要放到form 标签内使用

2.1 input标签

<input type="元素的类型" name="元素的名称" value="元素的值">
  • type标签的取值 
type标签的取值
text文本框
password密码框
radio单选按钮
checkbox多选按钮
submit提交按钮
reset复位按钮
button普通按钮
image图像按钮
file文本域(上传文件的按钮)
hidden隐藏域
email邮箱
color颜色域
date日期
time时间
datetime-local日期+时间
range进度条

  • input标签的属性
input标签的属性
checked默认选择
readonly只读(字段只可以读不能修改)
disabled禁用(不可以点击)
autofocus默认光标的位置
required不能为空白提交

  • 代码表示:
<!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>表单</title>
</head>
<body>
    <form action="demo.html" merhod="post" name="regester">
        用户名: <input type="text" mame="uesername" value="zhangsan" readonly><br>
        用户名: <input type="text" mame="uesername" value="lisi" disabled><br>
        密码:<input type="password" name="password" autofocus required><br>
        <input type="submit">
        请选择您的性别:<br><input type="radio" value="男" name="gender" checked>男
        <input type="radio" value="女" name="gender">女
        <p>
            选择您的爱好:<br>
            <input type="checkbox" mame="aihao">唱歌
            <input type="checkbox" mame="aihao">跳舞
            <input type="checkbox" mame="aihao">篮球
            <input type="checkbox" mame="aihao">足球
        </p>
        <input type="submit">
        <input type="reset">
        <input type="button" value="普通">
        <input type="image">
        <input type="file">
        <input type="hidden" value="123456"><br>
        请填写自己的邮箱:<br><input type="email" name="email" calue="请填写邮箱"><br>
        <input type="color">
        <input type="date">
        <input type="time">
        <input type="datetime-local">
        <input type="range">
    </form>
</body>
</html>
  • 运行结果:

 2.2 select标签

  • 下拉列表框(一般与option标签连用)
  • select标签的属性 
select标签的属性
multiple以列表形式显示

  • option标签的属性 
option标签的属性
selected默认被选中的选项

  • 代码表示:
<!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>表单</title>
</head>
<body>
    <form action="">
        <select name="" id="" multiple="multiple">
            <option value="">北京</option>
            <option value="" selected>上海</option>
            <option value="">重庆</option>
            <option value="">西安</option>
        </select>
    </form>
</body>
</html>
  • 运行结果:

 2.3 textarea标签

  • 用来实现文本域
  • textarea标签的属性 
textarea标签的属性
cols="30"多少列,表示文本域的宽度
rows="10"多少行,表示文本域的高度

  • 代码表示:
<!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>表单</title>
</head>
<body>
    <form action="">
        <textarea name="" id="" cols="30" rows="10">这个家伙什么都没留下</textarea>
    </form>
</body>
</html>
  • 运行结果:

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值