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>

Practice Your Knowledge

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

Quiz Time: Test Your Skills!

Ready to challenge what you've learned? Dive into our interactive quizzes for a deeper understanding and a fun way to reinforce your knowledge.

Do you find this helpful?