You should give same css properties to both the input element and the span element.
input,span{
float: left; /* helpful to remove the gap */
line-height: 15px; /* centering by giving the value of height */
height: 15px; /* same height to both the elements */
}
span{
border: 1px solid transparent;
border-left-width: 0px; /* removing left border to decrease the gap */
}
In the above stylings, I am giving border to the span element because the input has border by default.
Working Fiddle
or else
You can also use display: table-cell
and do something like this:
input, span {
display: table-cell;
vertical-align: middle;
}
input {
outline: none;
padding: 0px;
margin: 0px;
}
body { /* or parent element */
display: table;
}
Working Fiddle