Home > Web Front-end > HTML Tutorial > How do we set the type of an element in HTML?

How do we set the type of an element in HTML?

WBOY
Release: 2023-08-26 14:45:12
forward
1424 people have browsed it

How do we set the type of an element in HTML?

In this article, we will learn how to set the type of an element in HTML, just like we are familiar with the type in HTML. For the

The type attribute can be used on the following elements

element Attributes
type
type
type
type
type
type
type

Let’s go through the following example to understand how to set the type of an element in HTML.

HTML

Clickable buttons in HTML are defined by the

Example

In the example below, we use two

<!DOCTYPE html>
<html>
<body>
   <form action="#" method="get">
      <label for="firstname">Username:</label>
      <input type="text" id="firstname" name="firstname"><br><br>
      <label for="lastname">Surname:</label>
      <input type="text" id="lastname" name="lastname"><br><br>
      <button type="submit" value="Submit">Submit</button>
      <button type="reset" value="Reset">Reset</button>
   </form>
</body>
</html>
Copy after login

When the script executes, it will generate an output with input fields for the username and lastname (set by type="text"), as well as a submit button and a reset button.

HTML Tags

Tags specify fields into which users can enter data. The most important form element is the element. Depending on the type attribute, the element can be rendered in a number of different ways.

Example

Consider the following example where we use an HTML form with two different input types, one for text and another for submission.

<!DOCTYPE html>
<html>
<body>
   <form action="#">
      <label for="Username">Enter name: </label>
      <input type="text" id="Username" name="Username"><br>
      <input type="submit" value="Submit">
   </form>
</body>
</html>
Copy after login

When you run the above script, it will produce an output that includes an input field with a name of type="text" and an input button with a type="submit" attribute.

Use script

Look at the following example, we are running a script with the type attribute specified

Example

In the example below, we use two

Related labels:
source:tutorialspoint.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template