HTML <input> with accept Attribute

You are Here:

HTML <input> with accept Attribute

The accept attribute specifies the types of files that need to be filtered out from the file input dialog box so that the user can easily pick one.

Note: The accept attribute is only used for inputs with type="file".

Example

HTML Online Editor
<!DOCTYPE html> <html> <body> <form action="/multipart.php" method="post" enctype="multipart/form-data"> <input type="file" name="userFile" accept=".txt"> <input type="submit"> </form> </body> </html>

Attribute Value

ValueExplanation
audio/*All audio files are accepted.
video/*All video files are accepted.
image/*All image files are accepted.
file_extensionA file extension starting with the STOP character, e.g: .gif, .jpg, .png, .txt.
media_typeA valid media type, with no parameters.

Reminder

Hi Developers, we almost covered 99.5% of HTML Tutorials with examples for quick and easy learning.

We are working to cover every Single Concept in HTML.

Please do google search for:

Join Our Channel

Join our telegram channel to get an instant update on depreciation and new features on HTML, CSS, JavaScript, jQuery, Node.js, PHP and Python.

This channel is primarily useful for Full Stack Web Developer.

Share this Page

Meet the Author