Dofactory.com
Dofactory.com
Earn income with your HTML skills
Sign up and we'll send you the best freelance opportunities straight to your inbox.
We're building the largest freelancing marketplace for people like you.
By adding your name & email you agree to our terms, privacy and cookie policies.

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.

Example

#

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">
</form>

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.


Syntax

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

Values

#

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:

Chrome
26.0 Mar 2013
Firefox
37.0 Mar 2015
IE/Edge
10.0 Sep 2012
Opera
15.0 May 2013
Safari
11.1 Mar 2018

You may also like

 Back to <input>

Last updated on Sep 30, 2023

Earn income with your HTML skills
Sign up and we'll send you the best freelance opportunities straight to your inbox.
We're building the largest freelancing marketplace for people like you.
By adding your name & email you agree to our terms, privacy and cookie policies.

Guides