checkbox复选,radio单选
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
</head>
<body>
<!-- 复选框跟文字联动,需要label标签包裹,并且label里的for是input的id -->
<label for="apple"><input type="checkbox" id="apple">苹果</label>
<label for="banana"><input type="checkbox" id="banana">香蕉</label>
<label for="peach"><input type="checkbox" id="peach">桃子</label>
<br><br>
<!-- 单选框只让选一个,name里面用同一个名字就可以 -->
<label for="watermelon"><input type="radio" name="fruit" id="watermelon">西瓜</label>
<label for="pear"><input type="radio" name="fruit" id="pear">梨子</label>
<label for="orange"><input type="radio" name="fruit" id="orange">桔子</label>
</body>
</html>