1

The size of an input field can be controlled

<input type="text" size="2" maxlength="2">

The actual box is, however, wider than the selected width:

enter image description here

How to make it the size selected in size="..."?

I checked the calculated size in Chrome DevTools and the size is forced by the actual content (12 in the example above), not some padding or other CSS-dependent modifications of size.

WoJ
  • 23,237
  • 42
  • 145
  • 273

1 Answers1

1

Size tells you how many characters can be entered. The width of the input box itself can be set through CSS.

input {
width: 16px;
}
<input type="text" size="2" maxlength="2">
Gerard
  • 14,447
  • 5
  • 28
  • 48