English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

HTML Reference Manual

Complete List of HTML Tags

HTML: <input> accept attribute

The accept attribute specifies the filter for the file types that users can select from the file input dialog (only for type ="file"), note: the accept attribute can only be used with <input type ="file">

 HTML <input> tag

Online Example

Specify the file types that users can select from the file input dialog:

<!DOCTYPE html>
<html>
<head>
<title>HTML: <input> accept attribute - Basic Tutorial Website(oldtoolbag.com)</title>
<body>
<form action="action_page.php">
  <input type="file" name="pic" accept="image/*">
  <input type="submit">
</form>
</body>
</html>
Test to see ‹/›

Browser compatibility

IEFirefoxOperaChromeSafari

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

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

Define and Usage

The accept attribute specifies a filter for the file types that the user can select from the file input dialog (used only for type ="file").
Note: The accept attribute can only be used with <input type ="file">.

Tip: Do not use this attribute as a validation tool. File upload should be validated on the server to ensure the security of the upload.

HTML 4.01 with HTML5differences

None.

Syntax

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

Tip:If multiple values are to be specified, separate these values with commas (for example <input accept="audio/*,video/*,image/*" />).

Attribute Value

ValueDescription
audio/*Accepts all audio files.
video/*Accepts all video files.
image/*Accepts all image files.
MIME_typeA valid MIME type without parameters. See IANA MIME Type,to obtain a complete list of standard MIME types.
 HTML <input> tag