html tutorial - accept Attribute in HTML - html5 - html code - html form

Accept attribute in html

Learn html - html tutorial - accept attribute in html - html examples - html programs

  • The accept attribute used to specifies a comma-separated list of content types that the server accepts.
  • The accept attribute can only use with <input> file tag.

Syntax for accept attribute in HTML:

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

Applies To:

Element Attribute
<input> accept

accept Attribute Values:

Value Description
file_extension A file extension, e.g.: .gif, .jpg, .png, .doc
audio/* All audio files are supported
video/* All video files are supported
image/* All image files are supported
media_type A valid media type, is used with no parameters.

Sample Coding for accept Attribute in HTML:

Tryit<!DOCTYPE html>
        <title>Wikitechy accept attribute</title>
            <input type=”file” name=”image” accept=”image/*”>
            <input type=”submit”>

Code Explanation for accept Attribute in HTML:

accept Attribute Code Explanation

  1. <input> tag used to get the inputs from the user.
  2. type=”file” used to specifies the file input.
  3. accept is used to specifies that the server accepted file types.
  4. “image/*” is define the input file must be image format.

Output for accept Attribute in HTML:

accept Attribute Tag Output

  1. If we click the “Choose file” button open dialog box is displayed.
  2. Open dialog box shows the default file type as image. We can choose only images from the folders.
  3. accept Attribute Tag Output
  4. After choosing the image it shows that the image is chosen with its name as “images.jpg”.

Browser Support for accept Attribute in HTML:

8.0 10.0 4.0 6.0 15.0

Tips and Notes

  • Do not use accept attribute as a validation tool. File uploads should be validated on the server.

Related Searches to accept Attribute in html

Adblocker detected! Please consider reading this notice.

We've detected that you are using AdBlock Plus or some other adblocking software which is preventing the page from fully loading.

We don't have any banner, Flash, animation, obnoxious sound, or popup ad. We do not implement these annoying types of ads!

We need money to operate the site, and almost all of it comes from our online advertising.

Please add to your ad blocking whitelist or disable your adblocking software.