Definition and Usage
- Controls
- Refers to elements that allow users to interact with a web page.
The<input>tag, along with the<button>,<textarea>, and<select>tags, are typical control elements that allow users to enter data, make selections, or click.
Basic Example
<form action="submit_url">
<label for="user-name">Name</label>
<input type="text" id="user-name" name="user-name">
<input type="submit">
</form>
The implicit role value of <input type="submit"> is button.
Using Related Attributes
Let's learn about the attributes related to <input type="submit">.
value Attribute
The value attribute specifies the string to be used as the button's label.
If a string for the button's label is not specified using the value attribute, the browser's default label is displayed.
value attribute
<input type="submit" value="String used as the label">
value attribute
<input type="submit">
disabled Attribute
Use the disabled attribute to disable a button. It prevents user interactions with the button, such as pressing or clicking.
It is a Boolean attribute, meaning you only need to include the attribute name without specifying a value.
<form action="submit_url">
<label for="user-name">Name</label>
<input type="text" id="user-name" name="user-name">
<input type="submit" disabled>
</form>
name Attribute
The name attribute represents the name of the button.
This name can be used to submit the value of the <input type="submit"> element when the form is submitted, and in JavaScript, it can be referenced to access the element via the form.elements API.
form Attribute
formnovalidate Attribute
Indicates that the form (<form>) should not be validated when submitted with <input type="submit">. It is a Boolean attribute, meaning you only need to include the attribute name without specifying a value.
Note!
formnovalidate attribute is also available on <input type="image"> and <button type="submit">.
Styling Limitations
The <input> tag's type="submit" is perfectly valid for submitting all submittable values of the form containing the element, but HTML also offers <button type="submit">, which provides the same functionality.
The <input> tag is a void element, meaning it cannot have any content and does not have a closing tag (</input>).
The <button> tag has a closing tag (</button>), allowing it to contain child content.
Because it can hold inner content, you can include HTML elements or images within its label, giving you far more styling flexibility.
<style>
button {
color: inherit;
text-decoration: none;
padding: 0.5em 1em;
background-color: #fff;
border: 1px solid #777;
border-radius: 0.5em;
display: inline-flex;
align-items: center;
}
/* The input tag cannot use
::before or ::after. */
button::after {
content: "";
display: inline-flex;
width: 0.5em;
height: 0.5em;
border-left: 1px solid black;
border-bottom: 1px solid black;
transform: rotateZ(225deg);
margin-left: 0.2em;
}
</style>
<button type="submit">Log In</button>
Browser Compatibility
| Attribute |
Desktop Chrome
|
Desktop Edge
|
Desktop Firefox
|
Safari
|
|---|---|---|---|---|
<input type="submit"> |
1 | 12 | 1 | 1 |
Specifications
| Specification | |
|---|---|
<input type="submit">
|
HTML Standard #submit-button-state-(type=submit) |