input type=“text” vs input type=“search” in HTML5

前端 未结 10 1811
無奈伤痛
無奈伤痛 2021-01-30 12:05

I\'m new to HTML5 as begun to work with HTML5\'s new form input fields. When I\'m working with form input fields, especially and

10条回答
  •  Happy的楠姐
    2021-01-30 12:31

    It does absolutely nothing in most browsers. It just behaves like a text input. This isn't a problem. The spec doesn't require it to do anything special. WebKit browsers do treat it a bit differently though, primarily with styling.

    A search input in WebKit by default has an inset border, rounded corners, and strict typographic control.

    Also,

    This isn't documented anywhere that I know of nor is it in the spec, but you if you add a results parameter on the input, WebKit will apply a little magnifying glass with a dropdown arrow showing previous results.

    
    

    Reference

    Above all, it provides a semantic meaning to the input type.

    Update:

    Chrome 51 removed support for the results attribute:

提交回复
热议问题