HTML accept Attribute

HTML accept Attribute defines the type of the file that user can select to upload or the file that server accepts. HTML accept Attribute is used for input tag.

Syntax of HTML accept Attribute

The Syntax of HTML accept Attribute is shown below.

<input type="file" accept="image/*" name="image" >

Usage of HTML accept Attribute

HTML accept Attribute is used to specify the type of file that server can accept. HTML accept Attribute is used with the input tag. HTML accept Attribute makes sure that user only upload the files which are allowed.

Used For

HTML accept Attribute is used for following tags.

Tag Name
HTML input Tag

Example of HTML accept Attribute

Simple example of HTML accept Attribute is given below.

<label for="video">Video:</label>
<input type="file" id="video" accept="video/*">

In above example we have used HTML accept Attribute to only allow video files.

Values of HTML accept Attribute

Following values can be used with HTML accept Attribute.

ValueDescription
image/*All images are allowed.
video/*All videos are allowed.
audio/*All audio files are allowed.
media_typeValid media type without parameters.
file_extensionSpecify the allowed file extensions.

At a time, more than one value can be used for HTML accept Attribute, separate the values with a comma.

<label for="video">Audio/Video:</label>
<input type="file" id="video" accept="audio/*,video/*">

Browser Support for HTML accept Attribute

HTML accept Attribute is supported by following major browsers.

Browser NameVersion
Chrome8.0 and above
Firefox4.0 and above
Opera15.0 and above
IE / Edge10.0 and above
Safari6.0 and above