Super-simple HTML 5 solution:
<input type="search" placeholder="Search..." />
Source: HTML 5 Tutorial - Input Type: Search
This works at least in Chrome 8, Edge 14, IE 10, and Safari 5 and does not require Bootstrap or any other library. (Unfortunately, it looks like Firefox does not yet support the clear search button.)
After entering in the search box appears "x", which you can click to clear the text. This will still work as a normal edit box (without the x button) in other browsers such as Firefox, so Firefox users can instead select text and click Delete, or ...
If you really need this convenient feature supported in Firefox, then you can implement one of the other solutions published here as a polyfill for input [type = search] elements. Polyfill is a code that automatically adds a standard browser function when a user browser does not support this function. Over time, the hope is that you can remove polyfills, as browsers implement the corresponding functions. And in any case, the implementation of polyfill can help keep HTML code clean.
By the way, other HTML 5 input types (such as date, number, email, etc.) will also be gracefully reduced to a simple editing field. Some browsers may provide you with an unusual date picker, a rotation control with up / down buttons, or (on mobile phones) a special keyboard with a “@” symbol and a “.com” button, but as far as I know, all browsers will at least show text box for any unrecognized input type.
Bootstrap 3 & HTML 5 Solution
Bootstrap 3 resets a lot of CSS and breaks the HTML 5 cancel button. After loading Bootstrap 3 CSS, you can restore the cancel button with the CSS used in the following example:
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/> <style> input[type="search"]::-webkit-search-cancel-button { -webkit-appearance: searchfield-cancel-button; } </style> <div class="form-inline"> <input type="search" placeholder="Search..." class="form-control" /> </div>
Source: HTML 5 Search input does not work with bootstrap
I have verified that this solution works in the latest versions of Chrome, Edge, and Internet Explorer. I can not check in Safari. Unfortunately, the “x” button to clear the search does not appear in Firefox, but, as mentioned above, for browsers that do not initially support this function (for example, Firefox), polyfill can be implemented.