<input type="image"> - HTML(超文本标记语言) 编辑

<input type="image"> 标签是一个图片提交按钮。 你必须使用 src 属性来定义图片的源,并且使用alt来定义当图片无法显示的时候的替代文字。 height 和width属性是用来定义图片的高和宽的。

Permitted contentNone, it is an empty element.
Tag omissionMust have a start tag and must not have an end tag.
Permitted parent elementsAny element that accepts phrasing content.
DOM interfaceHTMLInputElement

Attributes

This element includes the global attributes.

type

formaction HTML5
The URI of a program that processes the information submitted by the input element, here image if specified, it overrides the action attribute of the element's form owner.
formenctype HTML5
If the input element is an image, this attribute specifies the type of content that is used to submit the form to the server. Possible values are:
  • application/x-www-form-urlencoded: The default value if the attribute is not specified.
  • multipart/form-data: Use this value if you are using an <input> element with the type attribute set to file.
  • text/plain

If this attribute is specified, it overrides the enctype attribute of the element's form owner.

formmethod HTML5
In image input element, this attribute specifies the HTTP method that the browser uses to submit the form. Possible values are:
  • post: The data from the form is included in the body of the form and is sent to the server.
  • get: The data from the form is appended to the form attribute URI, with a '?' as a separator, and the resulting URI is sent to the server. Use this method when the form has no side-effects and contains only ASCII characters.

If specified, this attribute overrides the method attribute of the element's form owner.

formnovalidate HTML5
This Boolean attribute specifies that the form is not to be validated when it is submitted. If this attribute is specified, it overrides the novalidate attribute of the element's form owner.
formtarget HTML5
This attribute is a name or keyword indicating where to display the response that is received after submitting the form. This is a name of, or keyword for, a browsing context (for example, tab, window, or inline frame). If this attribute is specified, it overrides the target attribute of the element's form owner. The following keywords have special meanings:
  • _self: Load the response into the same browsing context as the current one. This value is the default if the attribute is not specified.
  • _blank: Load the response into a new unnamed browsing context.
  • _parent: Load the response into the parent browsing context of the current one. If there is no parent, this option behaves the same way as _self.
  • _top: Load the response into the top-level browsing context (that is, the browsing context that is an ancestor of the current one, and has no parent). If there is no parent, this option behaves the same way as _self.
height HTML5
This attribute defines the height of the image displayed for the button.
required HTML5
This attribute specifies that the user must fill in a value before submitting a form but it cannot be used when the type attribute is image type (submit, reset, or button). The :optional and :required CSS pseudo-classes will be applied to the field as appropriate.
src
This attribute specifies a URI for the location of an image to display on the graphical submit button; otherwise it is ignored.
usemap HTML 4 only, 已废弃 HTML5
The name of a <map> element as an image map.
width HTML5
This attribute defines the width of the image displayed for the button.

Examples

Firefox logo input image example

<input type="image" name="image" src="/files/2917/fxlogo.png" width="50">

Result

Specifications

SpecificationStatus
HTML Living Standard
<input type="image">
Living Standard
HTML5
<input type="image">
Recommendation
HTML 4.01 Specification
<form>
Recommendation

Browser compatibility

BCD tables only load in the browser

The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据

词条统计

浏览:133 次

字数:9155

最后编辑:6年前

编辑次数:0 次

    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文