English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

HTML Reference Manual

Complete List of HTML Tags

HTML: <form> accept Attribute

The accept attribute specifies the file types that the server accepts (files can be submitted through file upload), please avoid using this attribute as a validation tool. File uploads should be validated on the server side to prevent malicious uploads.

 HTML <form> tag

Online Example

Specify the server to accept only png and jpeg image formats when uploading files:

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>HTML <form> accept Attribute Usage-Basic Tutorial(oldtoolbag.com)</title>
</head>
<body>
<form action="action_page.php" accept="image/png, image/jpeg">
  First name: <input type="text" name="fname"><br>
  Last name: <input type="text" name="lname"><br>
  Your image: <input type="file" name="pic" id="pic"><br>
  <input type="submit" value="Submit">
</form>
</body>
</html>
Test it out ‹/›

Browser Compatibility

IEFirefoxOperaChromeSafari

Note:Almost all mainstream browsers do not support the accept attribute.

Definition and Usage

In HTML5 In,the <form> accept attribute is not supported.

The accept attribute specifies the file types accepted by the server (files can be submitted through file upload).

Tip:Avoid using this attribute as a validation tool; it should be validated on the server side when uploading files.

Syntax

<form accept="MIME_type">

Attribute Value

ValueDescription
MIME_typeAllowed to be submitted/One or more MIME types uploaded. To specify multiple MIME types, separate them with commas.

See IANA MIME Types,for a complete list of standard MIME types.

 HTML <form> tag