HTML <input> accept Attribute

The accept attribute on an input tag specifies the acceptable file types that can be uploaded.

This only applies to input controls of type file.



An accept attribute on an <input> element of type file.
This file selector let the user select only image files.

<form action="/tutorial/fileupload.html" enctype="multipart/form-data">
  <label for="image">Select image to upload</label><br />
  <input type="file" id="image" name="image" accept="image/*"><br /><br />

  <input type="submit">

Using accept

The accept attribute specifies which file format or media type the input element accepts.

This attribute is only valid with the file input type.

The accept attribute only filters the file selection. It does not validate the format during form submission.


<input type="file" accept="file-extension | audio/* | video/* | image/* | media-type">



Value Description
file-extension File extension(s), such as, .gif, .jpg, .png, .doc, and others.
audio/* Accepts all sound files.
video/* Accepts all video files.
image/* Accepts all image files.
media-type A valid media type, without parameters.

Browser support

Here is when accept support started for each browser:

26.0 Mar 2013
37.0 Mar 2015
10.0 Sep 2012
15.0 May 2013
11.1 Mar 2018

You may also like

 Back to <input>

Last updated on Sep 30, 2023