HTML accept attribute

HTML accept attribute gives hint to the browser that which type of file will be accepted by the browser.

HTML File: <input type="file" accept=".html">
JavaScript File: <input type="file" accept=".js">
CSS File: <input type="file" accept=".css">
HTML File:
JavaScript File:
CSS File:

Attribute values

All possible values of accept attribute


video value hints the browser that only video files should be accepted.

<p>Upload Video: <input type="file" accept="video/*"><p>
<p>Upload Video: <input type="file" accept="video/*"><p>


audio value hints the browser that only audios are to upload.

<p>Upload audio: <input type="file" accept="audio/*"><p>


image value hints the browser that only images should be accepted.

<p>Upload image: <input type="file" accept="image/*"><p>


The value which starts with a dot(.) hints the browser that a file of specific extension is to upload.

  • If files of different extensions are allowed, then extensions should be separated by a comma.

  • The same type of extensions (dublicate extensions) should not be used.

<p>Upload files: <input type="file" accept=".doc,.docx"><p>

Related Tags

The tags that support accept attribute

<input> tag

input tag allows the user to enter data in the form. It supports accept attribute.

<p>Upload Video: <input type="file" accept="video/*"><p>

Was this article helpful?