--- title: slug: Web/HTML/Element/Input/image translation_of: Web/HTML/Element/input/image ---
<input type="image"> 标签是一个图片提交按钮
。 你必须使用 src 属性来定义图片的源,并且使用alt来定义当图片无法显示的时候的替代文字。 height 和width属性是用来定义图片的高和宽的。
Permitted content | None, it is an {{Glossary("empty element")}}. |
---|---|
Tag omission | Must have a start tag and must not have an end tag. |
Permitted parent elements | Any element that accepts phrasing content. |
DOM interface | {{domxref("HTMLInputElement")}} |
This element includes the global attributes.
{{htmlattrdef("type")}}
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 {{HTMLElement("input")}} element with the {{htmlattrxref("type","input")}} attribute set to file
.text/plain
If this attribute is specified, it overrides the {{htmlattrxref("enctype","form")}} attribute of the element's form owner.
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 {{htmlattrxref("method","form")}} attribute of the element's form owner.
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
.image
type (submit
, reset
, or button
). The {{cssxref(":optional")}} and {{cssxref(":required")}} CSS pseudo-classes will be applied to the field as appropriate.<input type="image" name="image" src="/files/2917/fxlogo.png" width="50">
{{ EmbedLiveSample('simple_input_image_example') }}
Specification | Status |
---|---|
{{SpecName('HTML WHATWG', 'https://html.spec.whatwg.org/multipage/forms.html#image-button-state-%28type=image%29', '<input type="image">')}} | {{Spec2('HTML WHATWG')}} |
{{SpecName('HTML5 W3C', 'http://www.w3.org/TR/html5/forms.html#image-button-state-%28type=image%29', '<input type="image">')}} | {{Spec2('HTML5 W3C')}} |
{{SpecName('HTML4.01', 'interact/forms.html#h-17.4', '<form>')}} | {{Spec2('HTML4.01')}} |
{{Compat("html.elements.input.input-image")}}