How to use the submit button in HTML forms?

Submit button automatically submits a form on click. Using HTML forms, you can easily take user input. The <form> tag is used to get user input, by adding the form elements. Different types of form elements include text input, radio button input, submit button, etc.

Let's learn about how to use the submit button in HTML forms. It is created using HTML <input> tag with the type attribute set to "submit".

HTML Form with Submit Button Student Name Student Subject Submit Reset Submits form data

Basic Syntax

The submit button is created using the <input> tag with type="submit":

<input type="submit" value="Submit">

Complete Form Example

You can try to run the following code to use submit button to submit and reset a form. Under the action attribute, add the file where you want to reach after clicking the Submit button. Using get and post methods, you can send the values to the server-side file.

<!DOCTYPE html>
<html>
<body>
    <form action="/new.php" method="post">
        Student Name:<br>
        <input type="text" name="sname" required>
        <br><br>
        Student Subject:<br>
        <input type="text" name="ssubject" required>
        <br><br>
        <input type="submit" value="Submit">
        <input type="reset" value="Reset">
    </form>
</body>
</html>

Submit Button Attributes

Attribute Description Example
value Button text value="Submit Form"
name Button identifier name="submit_btn"
disabled Disables the button disabled

Alternative: Button Element

You can also create submit buttons using the <button> element:

<!DOCTYPE html>
<html>
<body>
    <form action="/process.php" method="post">
        <input type="text" name="username" placeholder="Enter username">
        <br><br>
        <button type="submit">Submit Data</button>
        <button type="reset">Clear Form</button>
    </form>
</body>
</html>

Key Points

  • Submit buttons automatically submit form data when clicked
  • Use action attribute to specify where form data should be sent
  • Use method attribute to specify GET or POST request
  • Reset buttons clear all form fields to their default values
  • Add required attribute to input fields for basic validation

Conclusion

Submit buttons are essential for HTML forms, automatically sending form data to the server when clicked. Use them with proper form attributes for effective data collection and processing.

Updated on: 2026-03-15T23:18:59+05:30

5K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements