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

前端 未结 10 1661
無奈伤痛
無奈伤痛 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条回答
  • 2021-01-30 12:45

    On some browsers, it also supports the "results" and "autosave" attributes which provides automatic "recent searches" functionality with the magnifier icon.

    More info

    0 讨论(0)
  • 2021-01-30 12:47

    There's browser difference in action, when you type some words then keyed ESC in input type="search" in chrome/safari the input box will get cleared. but in type="text" scenario, the words will not get cleared. So be careful choosing the type especially when u use it for autocomplete or search related feature

    0 讨论(0)
  • 2021-01-30 12:48

    Visually/functionally, 2 differences if the input type is 'search':-

    1. You get a 'X' symbol at the end of the input/search box to clear texts in the box
    2. Pressing 'Esc' key on keyboard also clears texts
    0 讨论(0)
  • 2021-01-30 12:48

    But it has a bad affect on yout input element, if you set

    <input type="search">
    

    And in your css you set

    input {background: url("images/search_bg.gif");}
    

    It wont showup at all.

    0 讨论(0)
提交回复
热议问题