📅  最后修改于: 2023-12-03 15:01:18.187000             🧑  作者: Mango
HTML <input type="image">
is a self-closing tag that displays an image as a submit button. When the image is clicked, the form will be submitted to the server.
<input type="image" src="image_source" alt="alternative_text" />
type="image"
specifies the type of input element as an image submit button.src
specifies the source URL of the image.alt
specifies the alternative text of the image for accessibility purposes.<form action="submit.php" method="post">
<input type="text" name="username" placeholder="Username">
<br>
<input type="password" name="password" placeholder="Password">
<br>
<input type="image" src="submit_button.png" alt="Submit">
</form>
In the above example, an image submit button is displayed along with a text input and a password input. When the image is clicked, the form data will be submitted to submit.php
.
<input type="submit">
, <input type="image">
does not display a default value or text. The image itself is the submit button.alt
attribute is important for accessibility purposes, as it provides a text alternative for the image in case the image cannot be displayed or identified by screen readers.