HTML accept Attribute

The HTML "accept " attribute specifies the type of file that the server accepts. The submission is possible through a file upload.

You can only use this attribute on the <input> element. It is only used with <input type="file">.

The "accept " attribute must not be used as a validation tool. File uploads must be validated on the server.

SyntaxΒΆ

<input accept="file_extension | audio/* | video/* | image/* | media_type">

Example of the HTML "accept " attribute:

<!DOCTYPE html>
<html>
  <head>
    <title>Title of the document</title>
  </head>
  <body>
    <form action="/form/submit" method="post">
      <input type="file" name="Image" accept="image/*">
      <input type="submit">
    </form>
  </body>
</html>



Do you find this helpful?

Related articles