Cover Image for HTML Button Type
59 views

HTML Button Type

The HTML type attribute is used to define the type of a button element. Here are some common values for the type attribute:

1 Submit Button:

HTML<span role="button" tabindex="0" data-code="<button type="submit">Submit
<button type="submit">Submit</button>

The submit type is used to create a button that submits a form when clicked. This is typically used when you have a form that you want to submit to a server.

2 Reset Button:

HTML<span role="button" tabindex="0" data-code="<button type="reset">Reset
<button type="reset">Reset</button>

The reset type is used to create a button that resets the form fields to their initial values when clicked. It clears any user input and sets the form back to its default state.

3 Button Button:

HTML<span role="button" tabindex="0" data-code="<button type="button">Click Me
<button type="button">Click Me</button>

The button type is used to create a regular button that performs a custom action when clicked. It doesn’t have any predefined behavior like submitting or resetting a form.

4 Image Button:

HTML<span role="button" tabindex="0" data-code="
<input type="image" src="button-image.png" alt="Submit">

The image type is used to create a button with an image instead of text. It behaves like a submit button and submits the form when clicked. The src attribute specifies the image URL, and the alt attribute provides alternative text for accessibility.

These are the most commonly used button types in HTML. By specifying the appropriate type attribute, you can create buttons with different behaviors and functionalities.

YOU MAY ALSO LIKE...

The Tech Thunder

The Tech Thunder

The Tech Thunder


COMMENTS