一、标签定义
1、<input> 标签规定了用户可以在其中输入数据的输入字段。
2、输入类型是由 type 属性定义。
二、input的参数
<input type="类型" name="输入框名称" size="框的大小" maxlength="字符的最大数" value="框的默认值"/>
三、属性
文本域:type = text 用来输入单行文本
-
姓:
<
input
type
=
"text" name
=
"yourname"
>
<br
>
-
名:
<
input
type
=
"text" name
=
"myname"
>
密码字段:type=password 用户的输入会被遮挡
-
你也可以加maxlength
=
"8",意思是输入的密码长度只能
8个
-
密码:
<
input
type
=
"password"
>
单选按钮:type=radio 表示一组选择之中,只能选中一项
-
<
input
type
=
"radio"
value
=
"A" name
=
"nn"
>A
<br
>
-
<
input
type
=
"radio"
value
=
"B" name
=
"nn"
>B
<br
>
-
<
input
type
=
"radio"
value
=
"C" name
=
"nn"
>C
<br
>
-
<
input
type
=
"radio"
value
=
"D" name
=
"nn"
>D
<br
>
复选框:type=checkbox 允许选择或取消选择该选项
-
<
input
type
=
"checkbox"
value
=
"A" name
=
"nn"
>A
-
<
input
type
=
"checkbox"
value
=
"B" name
=
"nn"
>B
-
<
input
type
=
"checkbox"
value
=
"C" name
=
"nn"
>C
-
<
input
type
=
"checkbox"
value
=
"D" name
=
"nn"
>D
提交按钮:type=submit 用户点击这个按钮,就会把表单提交给服务器
-
<form
>
-
Username:
<
input
type
=
"text" name
=
"user"
>
-
<
input
type
=
"submit"
value
=
"Submit"
>
-
<
/form
>
重置按钮:type=reset 作用在于清空输入的信息。
-
<form
>
-
姓名:
<
input
type
=
"text"
>
-
<
input
type
=
"reset"
>
-
<
/form
>
日期的输入框:type=date 用户可以输入年月日
时间的输入框:type=time 可以输入时分秒
滑块:type=range 用户拖动滑块,选择给定范围之中的一个数值
输入年份和月份的输入框:type=month
选择颜色的控件:type=color 它的值一律都是#rrggbb格式