My JavaScript-generated fill-in-the-blank text is causing me trouble when it comes to adjusting the size of the input boxes.
Unlike others, I know exactly what the user will or should be entering.
If there is a blank space like this _______________, I want the input to be precisely 4 characters wide. However, due to the use of a proportional font (which won't change), the width always ends up being too large, even for wide characters like capital Ds.
So, any suggestions? I've tried setting the width using size, CSS width in em (resulting in it being too big) and ex (making it too narrow even for smaller characters).
I could calculate the width of the actual word that needs to be filled in using a hidden span element, but that doesn't seem very elegant.
Is there a way to make the browser come up with a more accurate estimate for the width of the input when using a proportional font?