htmlcssformsinput

<input type="search"> not styling


I am trying to create a simple search bar with a search icon next to it. But I have noticed I can't style a input with the type search. I tried it on safari (Version 9.0.3 (11601.4.4)) and then on chrome (version 49.0.2623.110). At first I thought it was because the input was not valid but found out it was fine to have the type search.

The only thing I was able to style was background-color and it only worked in chrome.

I also tried deleting all my css styles and only styling the input. It did not help.

I tried googling it with no success.

So is their a way around it or will I have to put my input type on text so I can style it?

Thanks in advance!

CODE:

input {
  padding: 10px;
  /* Does not work */
}
<input type="search" placeholder="Search">

this code does not work in Safari and Chrome on OS X

EDIT: I am using OS X so could it be a problem with webkit?


Solution

  • Use appearance property to avoid propietary stylizing and then you are able to style it:

    input[type=search]{
       -moz-appearance: none; /* older firefox */
       -webkit-appearance: none; /* safari, chrome, edge and ie mobile */
       appearance: none; /* rest */
    }
    

    More info: