CKTIS / HTML
capture attribute — media capture
The capture attribute requests media capture through a file input and hints at the preferred camera direction.
Version: W3C HTML Media Capture; index snapshot date recorded separately
Syntax
<input type="file" accept="image/*" capture="user|environment">capture applies to input with type="file" and a specified accept. It is enumerated, not Boolean: user prefers a user-facing camera, while environment prefers an outward-facing camera. In the syntax, user|environment denotes alternatives, not a literal value.
Empty capture, invalid values, and omission leave direction implementation-specific; however, attribute presence recommends a capture picker. The preferred direction is not guaranteed. If the MIME type in accept has no associated capture mechanism, the browser must ignore capture. The attribute does not provide a live stream.
Examples
<!doctype html>
<html lang="en">
<meta charset="utf-8">
<title>Capture example</title>
<label for="photo">Take a photo</label>
<input id="photo" type="file" accept="image/*" capture="environment">
</html>Result
Take a photo
The displayed code and declared result were verified in an isolated environment using the method recorded in the verification evidence for this exact version.