* 表单项标签:
* input:可以通过type属性值,改变元素展示的样式。
* type属性:
* text:文本输入框,默认值
* placeholder:指定输入框的提示信息,当输入框的内容发生变化,会自动清空提示信息
* password:密码输入框
* radio:单选框
* 注意:
1. 要想让多个单选框实现单选的效果,则多个单选框的name属性值必须一样。
2. 一般会给每一个单选框提供value属性,指定其被选中后提交的值
3. checked属性,可以指定默认值
* checkbox:复选框
* 注意:
1. 一般会给每一个单选框提供value属性,指定其被选中后提交的值
2. checked属性,可以指定默认值
* file: 文件选择框
* hidden:隐藏域,用于提交一些信息。
* 按钮:
* submit:提交按钮。可以提交表单
* button:普通按钮
* image:图片提交按钮
* src属性指定图片的路径
* label:指定输入项的文字描述信息
* 注意:
* label的for属性一般会和input的id属性值对应。如果对应了,则点击label区域,会让input输入框获取焦点。
* select:下拉列表
* textarea:文本域
<!DOCTYPE html>
<html>
<head>
<title>表单标签</title>
</head>
<body>
<form action="#" method="get">
<label for="username">用户名:</label><input type="text" name="username" placeholder="请输入用户名" id="username"><br>
密码:<input type="password" name="password" placeholder="请输入密码"><br>
性别:<input type="radio" name="gender" value="male" checked="checked"> 男
<input type="radio" name="gender" value="female"> 女
<br>
爱好:<input type="checkbox" name="hobby" value="shopping"> 逛街
<input type="checkbox" name="hobby" value="java" checked="checked"> JAVA
<input type="checkbox" name="hobby" value="game"> 游戏
<br>
图片:<input type="file" name="file"><br>
隐藏域:<input type="hidden" name="id" value="aaa"><br>
取色器:<input type="color" name="color"><br>
生日:<input type="date" name="birthday"><br>
生日:<input type="datetime-local" name="birthday"><br>
邮箱:<input type="email" name="email"><br>
年龄:<input type="number" name="age"><br>
<br>
<input type="submit" value="登录"><br>
<input type="button" value="一个按钮"><br>
<input type="image" src="image/reg_button.jpg">
</form>
</body>
</html>
表单项标签
最新推荐文章于 2022-05-03 17:57:26 发布