HTML <input> src 属性

定义和用法

src 属性规定用作提交按钮的图像的 URL。

注意:src 属性只能与 <input type="image"> 一起使用(并且是必需的)。

实例

HTML 表单包含表示提交按钮的图像:

<form action="/action_page.php">
  <label for="fname">Name:</label>
  <input type="text" id="fname" name="fname"><br><br>
  <input type="image" src="submit.gif" alt="submit" width="48" height="48">
</form>

Try it yourself

Syntax

<input src="URL">

Attribute value

Value Description
URL

Specifies the URL of the image used as the submit button.

Possible values:

  • Absolute URL - points to another website (e.g., src="http://www.example.com/submit.gif")
  • Relative URL - points to a file within the website (e.g., src="submit.gif")

Browser support

Chrome Edge Firefox Safari Opera
Chrome Edge Firefox Safari Opera
Support Support Support Support Support