Last Updated : 11 Jul, 2025
HTML accept Attribute specifies the type of file that the server accepts. This attribute can be used with <input> element only. This attribute is not used for validation tools because file uploads should be validated on the Server.
Syntax:
<input accept = "file_extension">
Note: This attribute is not supported in HTML5.
Attribute Values:
Type Description file_extension It Specify the file extension(s) like .gif, .jpg, .png, .doc) the user can pick from. audio/* The user can pick all sound files. video/* The user can pick all video files. image/* A valid media type, with no parameters. Look at IANA Media Types for a complete list of standard media types. media_type A valid media type without parametersAttribute: The accept attribute is associated with <input> elements only.
HTML accept Attribute ExamplesExample: Here is the implementation of HTML accept Attribute.
HTML
<!DOCTYPE html>
<html>
<head>
<title>accept attribute</title>
<style>
body {
text-align: center;
}
</style>
</head>
<body>
<form action=" ">
<input type="file" name="picture"
accept="image/*">
<input type="submit">
</form>
</body>
</html>
Output:
Explanation:
In HTML5, the accept attribute is used within the input element of type file to specify the types of files that the server can accept for upload.
2. How to create input field that accept CSV file in HTML ?To create an input field that accepts CSV files in HTML, use the input element with type="file" and set the accept attribute to ".csv" or "text/csv".
Supported BrowsersThe browser supported by accept attribute are listed below:
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4