Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

No clear button in Firefox for input type search?

Tags:

html

css

firefox

<input type="search" />
input[type="search"]
{
   -webkit-appearance: searchfield
}

makes the clear(x) button appear when you type something in the input, but how do you make the same thing happen in Firefox?

Thanks!

like image 216
Ke. Avatar asked Jan 23 '15 16:01

Ke.


People also ask

How do I add a Clear button to my search bar?

The easiest way to add an input box with a clear button is to add an input element with the type attribute set to search . Then when we type into the input box, we see the clear button displayed. And we can click on it to clear its value.

How do I put search icon in input?

To add icon inside the input element the <i> tag and <span> tag are used widely to add icons on the webpages. To add any icons on the webpages or in some specific area, it needs the fontawesome link inside the head tag. The fontawesome icon can be placed by using the fa prefix before the icon's name.

What is input type search?

Definition and Usage. The <input type="search"> defines a text field for entering a search string. Note: Remember to set a name for the search field, otherwise nothing will be submitted. The most common name for search inputs is q.


1 Answers

Firefox has been dragging their feet on this for years and years. Contrary to the other answer, there is still (as of late 2017) no native way of including a clear button on an input. You can of course insert your own and style it manually, in which case you'd do well to use

input[type="search"]::-webkit-search-cancel-button { display: none }

to avoid having the native clear button show up on browsers that support it.

like image 142
Coderer Avatar answered Sep 17 '22 15:09

Coderer