Simple HTML5 to create a search box

Source: Internet
Author: User

With the popularity of HTML5, more and more new features are used by more Coder. HTML5 has added a lot of humanized tags and attributes, and the new form attributes will be introduced immediately.

Instance image:

The Code is as follows:

<Input type = "text" placeholder = "Enter and press enter to search" autofocus x-webkit-speech>

Awesome? Yes!

A few short codes can achieve the perfect Interaction Effect of the original multi-line JavaScript code. This is a little like HTML5!

PlaceholderIt is to set the initial value, and the color of the initial value is gray. When the input content changes, this value disappears. Its responsibility is to give an affinity indication, which is very loving.

AutofocusAs the name implies: automatic focus. when entering the current page, this input will automatically obtain the focus, and you can directly enter something to search after opening the page. When autofocus appears more than twice, the browser selects the last input focus with the autofocus attribute.

X-webkit-speechThis probably doesn't have to be explained. It's no good to install the voice recognition tool unique to webkit browsers (such as Chrome) on the input, google also installed the tool in its search box.

Well, don't worry. There is actually more things we need to study in a simple box.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.