HTML accept Attribute

Beginner
6 min read
Updated: Oct 2026
3 examples
Live preview

Definition and Usage

The accept attribute tells an <input type="file"> which file types the user should pick. Its value is a comma-separated list of unique file type specifiers: extensions (e.g. .png), MIME types (e.g. image/jpeg), or wildcards (image/*, audio/*, video/*).

Pair it with a labeled control and, for real uploads, a form using enctype="multipart/form-data". Use multiple when more than one file is allowed.

Baseline · Widely available.

Not deprecated and not experimental. Stable across modern browsers since about July 2015. Applies to file inputs only.

Hint only — not validation.

Users can often override the picker and choose any file. Always validate type, size, and content on the server.

HTML Syntax

syntax.html
<input type="file" accept=" file_type, file_type, …">

Each file_type is an extension, a MIME type, or one of audio/*, video/*, image/*.

Attribute Values

Unique file type specifiers you can mix in one comma-separated list:

ValueDescriptionTry it
.extFilename extension starting with a period (case-insensitive), e.g. .jpg, .pdfTry it
type/subtypeA MIME type with no extension, e.g. image/png, application/pdfTry it
image/*Any image file. Many phones also offer the cameraTry it
audio/*Any audio fileTry it
video/*Any video fileTry it
Combined listMix forms, e.g. image/*,.pdf or a thorough Word listTry it

Live Preview

Change the accept value, then open the file picker. Filtering depends on your OS and browser.

A real <input type="file">. Apply a filter, then choose a file.

File input

accept=".jpg, .jpeg, .png"

HTML Examples

Short, copy-ready snippets. Use Try It Yourself for a live editor.

Example 1 — Profile Picture Extensions

Limit a single upload to common web image extensions.

HTML
<label for="profile_pic">Choose a profile picture:</label>
<input
  type="file"
  id="profile_pic"
  name="profile_pic"
  accept=".jpg, .jpeg, .png">
Try It Yourself

How It Works

  1. Use a file input. type="file" is required for accept.
  2. List extensions. Each value starts with . and is separated by commas.
  3. Connect the label. for / id keeps the control accessible.
  4. Hint, not lock. The OS filters the dialog; still validate on the server.

Example 2 — Audio, Video, and Image Wildcards

Accept any file in a media category with audio/*, video/*, or image/*.

HTML
<p>
  <label for="soundFile">Select an audio file:</label>
  <input type="file" id="soundFile" accept="audio/*">
</p>
<p>
  <label for="videoFile">Select a video file:</label>
  <input type="file" id="videoFile" accept="video/*">
</p>
<p>
  <label for="imageFile">Select some images:</label>
  <input type="file" id="imageFile" accept="image/*" multiple>
</p>
Try It Yourself

How It Works

  1. Wildcards cover a family. image/* means any image MIME type, not one extension.
  2. Separate inputs, clear jobs. Audio, video, and images each get their own filter.
  3. multiple on the image field allows more than one file (see multiple).
  4. Mobile bonus. image/* often unlocks the camera on phones.

Example 3 — Thorough Specifiers (Word + Images/PDF)

One format can have several identifiers — list extensions and MIME types together.

HTML
<label for="docpicker">Upload a Word document:</label>
<input
  type="file"
  id="docpicker"
  name="doc"
  accept=".doc,.docx,application/msword,application/vnd.openxmlformats-officedocument.wordprocessingml.document">

<label for="asset">Image or PDF:</label>
<input type="file" id="asset" name="asset" accept="image/*,.pdf">
Try It Yourself

How It Works

  1. Same file, many names. Word may match .doc, .docx, or two MIME types — list them all.
  2. Mix styles. image/*,.pdf combines a wildcard with an extension.
  3. Comma-separated list. Order does not matter; spaces after commas are fine.
  4. Still verify server-side. A renamed .exe can slip past a client filter.

Edge Cases & Pitfalls

Most surprises come from treating accept as security instead of UX.

security

Not a substitute for server checks

Users can bypass the filter. Validate MIME type, size, and content on the server every time.

scope

Only for type="file"

Other input types ignore it. Support on <form> was removed; put accept on the file control.

OS

Picker UI differs by platform

Windows may hide non-matching files; macOS may gray them out. Behavior is similar in goal, not identical in UI.

coverage

One format may need several tokens

Office and media types often need both extensions and MIME types for reliable filtering.

upload

Remember multipart forms

For real uploads, set enctype="multipart/form-data" on the form. accept alone does not upload anything.

Browser Support

accept is an HTML attribute for file inputs in the browser. It is not a Node.js, Deno, or Bun API.

✓ Baseline · Widely available

accept

Widely available since about July 2015. Desktop Chrome, Firefox, Safari, Edge, and Opera support filtering well. Some mobile browsers still report partial support.

96% Global support (approx.)
Google Chrome 26+
Full support
Mozilla Firefox 37+
Full support
Apple Safari 11.1+
Full support
Microsoft Edge 79+
Full support
Opera 15+
Full support
Samsung Internet Modern · Partial on some builds
Partial
Internet Explorer 10+
Supported
accept Widely supported

Bottom line: Safe to use as a UX filter everywhere. Treat missing or partial mobile filtering as another reason to validate uploads on the server.

Key Takeaways

  • Role: guide the file picker with extensions, MIME types, or image/* / audio/* / video/*.
  • Element: only <input type="file"> in modern HTML.
  • Combine freely: e.g. image/*,.pdf or a thorough Word list.
  • Security: always validate uploads on the server.

One line: accept filters the file dialog — it does not replace server-side checks.

Frequently Asked Questions

On an input with type=file, accept lists which file types the picker should allow. Values are comma-separated extensions (like .png), MIME types (like image/jpeg), or wildcards (image/*, audio/*, video/*).
Only input type=file in modern HTML. It was once allowed on form but that use was removed in favor of the file input.
No. It is only a hint for the file chooser. Users can often override the filter. Always check type, size, and content on the server.
.png filters by filename extension. image/* accepts any image MIME type (PNG, JPEG, WebP, and more). Many phones also offer the camera when image/* is used.
Yes. For example accept="image/*,.pdf" allows any image plus PDF files in one list.
It is Baseline widely available (since about July 2015). Desktop Chrome, Firefox, Safari, and Edge support it well. Some mobile browsers still treat filtering as partial.

Next: accept-charset

Control which character encodings a form may use on submit.

accept-charset tutorial →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

8 people found this page helpful