我们如何在HTML中设置元素的类型?

在HTML中使用 type属性来设置元素的类型。

让我们了解<input>标记,它可以帮助您使用 type属性进行用户输入。该属性与表单元素一起使用,例如文本输入,复选框,单选等。

示例

您可以尝试运行以下代码以实现 type属性-

<!DOCTYPE html>
<html>
   <head>
      <title>HTML Forms</title>
   </head>
   <body>
      <p>Add your details:</p>
      <form>
         Student Name:<br> <input type = "text" name = "name">
         <br>
         Student Subject:<br> <input type = "text" name = "subject">
         <br>
         Rank:<br> <input type = "text" name = "rank">
      </form>
   </body>
</html>