HTML <input> acceptAttribute

HTML input 标签参考手册HTML <input> Tag

Example

Specifies that the server only accepts image files in file upload:

<form action="demo_form.html">
  <input type="file" name="pic" accept="image/*">
  <input type="submit">
</form>

Try it Yourself »

Browser Support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

Internet Explorer 10, Firefox, Opera, Chrome, and Safari 6 support the accept attribute.

Note:Internet Explorer 9 and earlier versions do not support the accept attribute of the <input> tag.


Definition and Usage

The accept attribute specifies the types of files that the server accepts and that can be submitted through file upload.

Note:The accept attribute only applies to <input type="file">.

Tip:Do not use this attribute as your validation tool. File uploads should be validated on the server.


Differences Between HTML 4.01 and HTML5

None.


Syntax

<input accept="audio/*|video/*|image/*|MIME_type">

Tip:To specify multiple values, separate them with commas (for example, <input accept="audio/*,video/*,image/*" />).

Attribute Values

Value Description
audio/* Accepts all sound files.
video/* Accepts all video files.
image/* Accepts all image files.
MIME_type A valid MIME type, without parameters. SeeIANA MIME Types, for a complete list of standard MIME types.


HTML input 标签参考手册HTML <input> Tag Other Extensions