W3docs

HTML accept Attribute

The HTML accept attribute specifies the type of file that the server accepts. Read about the accept attribute and find out on what element it can be used.

The HTML accept attribute specifies the types of files that the server accepts via a file upload. It filters the file picker on the client side. Note that browser support for specific MIME types and file extensions varies.

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>

Practice

Practice

What is the purpose of the 'accept' attribute in HTML and where is it commonly used?