What is HTML accept Attribute?

HTML, HTML Attributes , 0 Comments

The accept attribute Specify which type of file user can choose from the input picker. This attribute is valid for only input type=”file”


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

Note: You can use accept attribute only for <input type=”file”>.

Tip: Do not use this attribute as a validation tool. File uploads should be validated on the server for better validation.


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

Separate the values with a comma to indicate more than one value (e.g. <input accept=” image/*, video/*, audio/*,” />.

Attribute Values

Value Description
file_extension Specify the file extension(s) (e.g: .gif, .jpg, .png, .doc) the user can
pick from
audio/* The user can pick all sound files
video/* The user can pick all video files
image/* The user can pick all image files
media_type A valid media type, with no parameters. Look at
IANA Media Types for a complete list of standard media types

Browser Support

Data on support for the input-file-accept feature across the major browsers from caniuse.com

Leave a Reply

Your email address will not be published.