Computer >> Computer tutorials >  >> Programming >> HTML

How do we set the type of element in HTML?


Use the type attribute to in HTML to set the type of element.

Let us learn about the <input> tag, which helps you to take user input using the type attribute. The attribute is used with the form elements such as text input, checkbox, radio, etc.

Example

You can try to run the following code to implement type attribute −

<!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>