Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why does input type=search cause extra padding on Webkit(Safari)

Tags:

css

safari

webkit

When using an input with type="search" why does Safari add a few extra pixels of padding to the left side of the value/placeholder of the field?

<input type="search" placeholder="Search" />

(remember to view in Safari)

.input {
  padding: 8px 20px;
  -webkit-appearance: textfield;
}
<div><input type="text" placeholder="Search" class="input" /></div>
<div><input type="search" placeholder="Search" class="input" /></div>
like image 285
tekstrand Avatar asked Mar 05 '26 20:03

tekstrand


1 Answers

You need to remove the styling for the -webkit-search-decoration pseudo element.

.input {
  padding: 8px 20px;
  -webkit-appearance: textfield;
}
.input::-webkit-search-decoration {
  -webkit-appearance: none;
}
<div><input type="text" placeholder="Search" class="input" /></div>
<div><input type="search" placeholder="Search" class="input" /></div>
like image 68
tekstrand Avatar answered Mar 07 '26 09:03

tekstrand