I tried to use the maxlength attribute of an input element as a CSS width, but it does not seem to work:
input[maxlength] {
  width: attr(maxlength em);
}
According to Mozilla I thought this might be the intended use case. Yes I saw the note. Is there any other way to get it working?
This works, but scales too much.
input[maxlength="2"] {
  width: 2em;
}
input[maxlength="3"] {
  width: 3em;
}