File Input accept Attribute
The HTML5 revolution provided us several simple but important attributes like download, autofocus, required, novalidate, and placeholder.  There's another one you may want to know about:  accept.  The accept attribute is useful for input[type=file] elements.  Let's have a look at it!
The HTML
I'll use Twitter's upload button to illustrate a good usage of the accept attribute:
<input type="file" name="media_empty" accept="image/gif,image/jpeg,image/jpg,image/png,">
The accept attribute gets a comma-separated list of mime types for files desired file types.  In this case, Twitter is allowing the user to upload common image formats.
![5 Ways that CSS and JavaScript Interact That You May Not Know About]()
CSS and JavaScript:  the lines seemingly get blurred by each browser release.  They have always done a very different job but in the end they are both front-end technologies so they need do need to work closely.  We have our .js files and our .css, but...
![Camera and Video Control with HTML5]()
Client-side APIs on mobile and desktop devices are quickly providing the same APIs.  Of course our mobile devices got access to some of these APIs first, but those APIs are slowly making their way to the desktop.  One of those APIs is the getUserMedia API...
![MooTools 1.3 Browser Object]()
MooTools 1.3 was just released and one of the big additions is the Browser object.  The Browser object is very helpful in that not only do you get information about browser type and browser versions, you can gain information about the user's OS, browser plugins, and...
![Image Data URIs with PHP]()
If you troll page markup like me, you've no doubt seen the use of data URI's within image src attributes.  Instead of providing a traditional address to the image, the image file data is base64-encoded and stuffed within the src attribute.  Doing so saves...
The biggest problem about using this code is that the user can change it easily with firebug or others debugs.
It’s not for validation, it’s for assisting the user to select the right file type (since the file selection will only show files of that type).
You should never use this for validation since some browsers do not support it.
Validation should be done on your backend. This kind of selection only helps users what we really need from them.
Be careful with this.
The main issue is that some mobile browsers started to prevent the user from selecting any (!) file at all if the accept property was declared (which is just plain terrible user agent behaviour).
Thus if you want to support these browsers, you have to detect them and remove the accept property.
For details see http://caniuse.com/#feat=input-file-accept