HTML accept attribute
accept
The purpose of the HTML accept attribute is to specify the supported MIME types (content type) of a form or input element.
Supported elements
HTML accept attribute supports form and input
Syntax
<form accept="value1,value2..." >.....</form>
<input accept="value1,value2...">
Type of value
Type of value of HTML accept attribute is a valid Content Type(for example image/gif).
Value
A content type or a comma-separated list of content types.
Default value
There is no default value of HTML accept attribute.
Supported doctypes
HTML 4.01 strict, HTML 4.01 transitional, HTML 4.01 frameset.
Example of HTML accept attribute with form
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Example of HTML accept attribute with form </title>
</head>
<body>
<form action="action.php" accept="image/png,image/jpeg,image/gif,">
Email id : <input type="text" name="email" /><br/>
Password : <input type="text" name="passw" /><br/>
Upload your photograph: <input type="file" name="uimg" id="uimg" /><br/>
<input type="submit" value="Submit" />
</form>
</body>
</html>
Result
View this example in a separate browser window
Example of HTML accept attribute with form.
Example of HTML accept attribute with input
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Example of HTML accept attribute with input</title>
</head>
<body>
<form action="action.php">
Email id : <input type="text" name="email" /><br/>
Password : <input type="text" name="passw" /><br/>
Upload your photograph: <input type="file" name="uimg" id="uimg" accept="image/png,image/jpeg,image/gif,"/><br/>
<input type="submit" value="Submit" />
</form>
</body>
</html>
Result
View this example in a separate browser window
Example of HTML accept attribute with input.
Previous: HTML accept-charset attribute
Next: HTML accesskey attribute
Test your Programming skills with w3resource's quiz.
It will be nice if you may share this link in any developer community or anywhere else, from where other developers may find this content. Thanks.
https://www.w3resource.com/html/attributes/html-accept-attribute.php
- Weekly Trends and Language Statistics
- Weekly Trends and Language Statistics