我们如何在HTML表单中对数据进行分组?

PHPz
PHPz 转载
2023-09-09 19:29:01 884浏览

我们如何在HTML表单中对数据进行分组?

我们使用<fieldset>标签,对HTML表单中的相关数据进行分组。该标签在网页上的相关元素周围创建一个框。 <legend> 标签在 <fieldset> 标签内使用,为组提供标题或为组提供名称。

语法

<fieldse>…..</fieldset>

示例 1

以下是使用<legend>标签在<fieldset>标签内对HTML表单中的数据进行分组的示例 -

<!DOCTYPE html>
<html>
<head>
   <meta charset="UTF-8">
   <meta name="description" content="meta tag in the web document">
   <meta name="keywords" content="HTML,CSS">
   <meta name="author" content="lokesh">
   <meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>
<body>
   <form>
      <fieldset>
         <legend>Employee Details</legend>
         Employee Name<br>
         <input type="text" name="Ename">
         <br>
         Employee ID<br>
         <input type="text" name="Eid">
         <br>
         Employee Address<br>
         <input type="text" name="Eid">
         <br>
      </fieldset>
   </form>
</body>
</html>

示例2

您可以尝试运行以下代码来对HTML表单中的数据进行分组 -

<!DOCTYPE html>
<html>
<body>
   <form>
      <fieldset>
         <legend>Student Information:</legend>
         Student Name:<br>
         <input type="text" name="sname">
         <br>
         Student Subject:<br>
         <input type="text" name="ssubject">
         <br>
      </fieldset>
   </form>
</body>
</html>

以上就是我们如何在HTML表单中对数据进行分组?的详细内容,更多请关注php中文网其它相关文章!

声明:本文转载于:tutorialspoint,如有侵犯,请联系admin@php.cn删除