您的位置:首页 > Web前端 > HTML

HTML中的<label>标签的使用方法,文字与输入框相关联。

2017-03-09 21:02 507 查看
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>表单中文字与输入框相关联</title>
<base target="_self">
</head>
<body>
<form>
<!--无关联-->
账号:<input type="text">
<br>
密码:<input type="password">
<br>
<br>
<!--一一对应关联-->
<label for="xxx">账号:</label><input type="text" id="xxx">
<br>
<label for="xxxx">密码:</label><input type="password" id="xxxx">
<br>
<br>
<!--交叉对应关联-->
<label for="xxxxx">账号:</label><input type="text" id="xxxxxx">
<br>
<label for="xxxxxx">密码:</label><input type="password" id="xxxxx">
</form>
</body>
</html>

<!--
<label for="....">.....</label><input type="...." id=".....">
for与id要对应起来,for与那个id相对应,就与那个相关联。

1.<label for="x">账号:</label><input type="text" id="xx">

2.<label for="xx">账号:</label><input type="text" id="xxx">

3.<label for="xxx">账号:</label><input type="text" id="x">

4.<label for="xxxx">账号:</label><input type="text" id="xxxx">

1的文字与3的输入框相关联。
2的文字与1的输入框相关联。
3的文字与2的输入框相关联。
4的文字与4的输入框相关联。-->





                                            
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: