The device you are looking for ch: this block represents the width of the character "0" in the current font. In a monospace font, it is 1chequivalent to the entire width of the characters.
input {
border: 0;
outline: 0;
background: transparent;
border-bottom: 2px solid black;
font-family: monospace;
width: 9ch;
}
<input type="text" placeholder="your name" maxlength="10" required />
Run codeHide result, monopsace , . 1ch ≈ 0.5em 5em ≈ 10ch.