X
    Categories: HTML 5

Cool HTML5 features

The accept attribute

You can use the HTML5 accept attribute to pinpoint what kind of files you accept from an input of type file. You can allow only images, videos, audios or a specific file extension. You use it in the following way:

You can be more specific, for example, by stipulating image/png instead of the wildcard image/* which accepts all kinds of images. When you add the accept attribute and the user is shown the file dialog, he would be able to select only files from that particular type with some browser magic.

The autofocus attribute

You can use the autofocus attribute to have a form input immediately focused when a page loads. You use it like this:  .

The placeholder attribute

The placeholder attribute, as shown above, allows you to have a text shown directly in the input that disappears when the user focuses and starts typing in the box.

Ivan Dimov: Ivan is a student of IT, a freelance web designer/developer and a tech writer. He deals with both front-end and back-end stuff. Whenever he is not in front of an Internet-enabled device he is probably reading a book or traveling. You can find more about him at: http://www.dimoff.biz. facebook, twitter