W3docs

Atributo accept de HTML

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.

El atributo accept de HTML especifica los tipos de archivos que el servidor acepta mediante una carga de archivos. Filtra el selector de archivos en el lado del cliente. Ten en cuenta que el soporte del navegador para tipos MIME y extensiones de archivo específicas varía.

Solo puedes usar este atributo en el elemento <input>. Solo se utiliza con <input type="file">.

El atributo accept no debe utilizarse como herramienta de validación. Las cargas de archivos deben validarse en el servidor.

Sintaxis

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

Ejemplo del atributo accept de HTML

<!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>

Práctica

Práctica

¿Cuál es el propósito del atributo 'accept' en HTML y dónde se utiliza comúnmente?