HTML Attributes

HTML <input> accept Attribute

The accept attribute hints which file types a file-upload input should allow the user to pick.


The <input> accept Attribute

The accept attribute is used with <input type="file"> to tell the browser which kinds of files the user is expected to upload. Browsers use it to filter the file picker, so users mostly see matching files. It is only a hint, not a security guarantee.

Syntax

ℹ️

Syntax: <input type="file" accept="value">, where value is a comma-separated list of file-type specifiers: file extensions (.pdf), MIME types (image/png) or wildcard MIME types (image/*).

Accept PDFs and Word documents for a resume upload
<label for="resume">Upload your resume</label>
<input type="file" id="resume" name="resume"
       accept=".pdf,.doc,.docx,application/pdf">
ValueDescription
.extA filename extension beginning with a dot, e.g. .pdf or .jpg
image/*Any image file (wildcard MIME type)
audio/*Any audio file
video/*Any video file
image/pngA specific MIME type such as PNG images
.jpg,.pngA comma-separated list combining multiple specifiers
⚠️

accept only filters the picker for convenience. Users can still bypass it, so always validate uploaded file types and sizes on the server.

Ready to use your HTML skills?

Find web development internships and fresher jobs across India.

Browse Web Dev Internships