HTML accept attribute

HTML accept attribute: In this attribute describes the types of files that the server accepts. And these files can be submitted through file uploading. While it can be used with <input type=”file”>. And this attribute is not used for a validation tool because the uploads should be validated on the server.

HTML accept attribute

We should not use these attributes as a validation tool. File uploads should be done on the server. And the accept attribute uses the input element. If you want to specify more than one value, use the separate commas.

Syntax: <input accept = “file_extension”> 

Supported Browsers

Thia attribute can be supported by different browsers. They are as follows:

  • Chrome – 8.0
  • Firefox – 4.0
  • Internet Explorer – 10.0
  • Safari – 6.0
  • Opera – 15.0

Example:

<!DOCTYPE html> 
<html> 
    <head> 
        <title>accept attribute</title> 
        <style> 
            body { 
                text-align:center; 
            } 
            h1 { 
                color:green; 
            } 
        </style> 
    </head> 
    <body> 
        <h1>Freshersnow</h1> 
        <h2>accept attribute</h2> 
        <form action=" "> 
            <input type="file" name="picture" accept="image/*"> 
            <input type="submit"> 
        </form> 
    </body> 
</html>

Output:

HTML accept attribute