表单元素格式
| 属性 | 说明 |
|---|---|
| type | 制定元素的类型:text、password、checkbox、radio、submit、reset、file、hidden、image、button,默认为text |
| name | 指定表单元素的名称 |
| value | 元素的初始值。type为radio时必须指定一个值 |
| size | 制定表单元素的初始宽度。当type为text或password时,表单元素的大小以字符为单位。对于其他类型,宽度以像素为单位 |
| maxlength | type为text或password时,输入的最大字符数 |
| checked | type为radio或checkbox时,指定按钮是否被选中 |
name属性是必填的,如果要提交表单,表示这个元素表单空间叫什么名字,提交的时候就会附带name属性,Java程序读取的时候就是读取这个name属性。
示例
DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>登录注册title>
head>
<body>
<h1>注册h1>
<form action="4.链接标签学习.html" method="get">
<p>用户名:<input type="text" name="username" value="提高效率" maxlength="8" size="30">p>
<p>密码:<input type="password" name="pwd">p>
<p>性别:
<input type="radio" value="man" name="sex">男
<input type="radio" value="woman" name="sex">女
p>
<p>
<input type="submit">
<input type="reset">
p>
form>
body>
html>