HTML<input>标签

定义和用法

<input> 标签用于搜集用户信息。
根据不同的 type 属性值,输入字段拥有很多种形式。输入字段可以是文本字段、复选框、掩码后的文本控件、单选按钮、按钮等等。

文本字段:
(用input标签定义type的属性为text,可在框中输入文字)

<html>
<body>
<form>
名:
<input type="text" name="firstname">
<br />
姓:
<input type="text" name="lastname">
</form>
</body>
</html>

复选框:
(用input标签定义type为checkbox,这样就可以选取多个选项)
<html>
<body>
<form>
我喜欢自行车:
<input type="checkbox" name="Bike">
<br />
我喜欢汽车:
<input type="checkbox" name="Car">
</form>
</body>
</html>

单选项:
(用input标签定义type为radio,checked为单选按钮)

<html>
<body>
<form>
男性:
<input type="radio" checked="checked" name="Sex" value="male" />
<br />
女性:
<input type="radio" name="Sex" value="female" />
</form>
</body>
</html>

创建按钮:
(用input标签定义type为button,值为Hello world!)

<html>
<body>
<form>
<input type="button" value="Hello world!">
</form>
</body>
</html>

猜你喜欢

转载自729372415.iteye.com/blog/2260086