HTML accept Attribute

❮ HTML Attributes


<form action="action.php">
  <label for="img">Select image:</label>
  <input type="file" id="img" name="img" accept="image/*">
  <input type="submit">


The accept attribute defines expected file type in file upload controls.

The accept attribute is used to list the MIME types accepted for file uploads when using a file upload control <input type="file">.

To specify more than one value, separate the values with a comma (e.g. <input accept="audio/*,video/*,image/*" />.

Standard Syntax

HTML:<input accept="fileExtension|audio/*|video/*|image/*|mediaType">,
XHTML:<input accept="fileExtension|audio/*|video/*|image/*|mediaType"/>

Browser Support

Not supported means any file can be picked as if the accept attribute was not set, unless otherwise noted.

On Windows, files that do not apply are hidden. On OSX they are grayed out and disabled.

  1. Supports the type format (e.g. image/*) but not the extension format (e.g. .png)
  2. Offers appropriate file locations/input based on format type, but does not prevent other files from being selected.
  3. Does not allow any files to be picked at all


Applies to:

The accept attribute can be used on the following element:

Element Attribute
<input> accept

Attribute Values

Value Description
fileExtension The file extension(s) (e.g: .mp4, .jpg, .png, .doc)
audio/* All audio files
video/* All video files
image/* All image files
mediaType A media type, with no parameters.
See the list
❮ HTML Attributes