How to reset the Webkit HTML5 search field style with CSS

by Glyn Mooney

I’ll keep this one short and snappy! I just ran into an issue where the new HTML5 search field would take the browser default styles over what I had defined. With a little Googling around and some tweaks, I came up with the following:

input[type=search]::-webkit-search-decoration,
input[type=search]::-webkit-search-cancel-button,
input[type=search]::-webkit-search-results-button,
input[type=search]::-webkit-search-results-decoration {
  display: none;
}

input[type=search] {
  /* the webkit overrides need to stay at the top */
  -webkit-appearance: textfield;
  -webkit-box-sizing: content-box;
  /* your styles here */
}

Hope this helps someone! Leave a comment, if you know a better way and I’ll update the article!