HTML capture Attribute
Description
The capture attribute is used with the <input type="file"> element to control how users interact with the file selection dialog. It allows you to prompt the user to capture a new media file using their device's camera or microphone, rather than simply selecting a file from their storage.
Here's what it does:
- When present, the
captureattribute indicates the browser should prioritize capturing new media over selecting existing files. - The attribute takes a string value specifying the preferred camera to use for capturing media:
"user": This value prompts the user to use the front-facing camera, typically for capturing selfies or videos of themselves."environment": This value prompts the user to use the environment-facing camera, usually the back camera on mobile devices, for capturing pictures or videos of their surroundings.
Important considerations:
- Browser support for specific
captureattribute values might vary depending on the device and browser version. - It's recommended to use the
captureattribute in conjunction with theacceptattribute, which specifies the allowed media types (e.g.,image/*for images,video/*for videos). This ensures the user can only capture media formats supported by the application. - To provide a better user experience, consider offering an option to choose between capturing a new file or selecting an existing one from storage. This gives users more control over the file selection process.
Syntax
<input type="file" capture="value">
Values
- valuedefines which camera to use for capturing media (image or video) and can be one of the following:
"user": This indicates the user-facing camera (typically the front camera on mobile devices)."environment": This indicates the environment-facing camera (typically the back camera on mobile devices).
Applies To
Example
Browser Support
The following information will show you the current browser support for the HTML capture attribute. Hover over a browser icon to see the version that first introduced support for this HTML attribute.
This attribute is supported in some modern browsers, but not all.
Desktop
Tablets & Mobile
-
Last updated by CSSPortal on: 25th March 2024
Sponsors
Copy Paste List
Copy and paste or download lists in your preferred format, including plain text, PDF, or HTML.
Unicode Characters & Emojis
Search all Unicode characters and emojis plus other tools.
Check Shortened URLs
Expand shortened URLs to view the destination link.
Advertise Here
Advertise your company and products here!
