html方框打钩代码

洛仁耀 2周前 13浏览 0评论

HTML方框打钩是在通常的表单中添加选项时经常使用的一种方法。以下是一个简单的HTML源代码示例,用于创建带有选择项的方框并在选择时显示打勾:

<!DOCTYPE html>
<html>
  <head>
    <title>HTML方框打钩示例</title>
  </head>
  <body>
    <form>
      <p><label for="option1"><input type="checkbox" id="option1" name="option1" value="option1">选择项1</label></p>
      <p><label for="option2"><input type="checkbox" id="option2" name="option2" value="option2">选择项2</label></p>
      <p><label for="option3"><input type="checkbox" id="option3" name="option3" value="option3">选择项3</label></p>
    </form>
  </body>
</html>

上面的代码包含三个选择项,每个选择项都包含一个元素和相应文本的

值得注意的是,所有选择框都应该具有唯一的id属性,并且name属性应该相同以便于在提交表单时进行处理。

这就是HTML方框打钩的基本代码,您可以在自己的网站上使用它来创建自己的表单和选项。