I thought it would look good if I change the font that is typed into the text box but the letters are not aligned in the middle.
enter image description here
The letters are instead sticking at the top right corner. How do I fix this? (I don’t want to center the letters)
Css:
#textInput {
border-radius: 5px;
border-style: solid;
border-color: grey;
height: 20px;
width: 210px;
position: absolute;
font-family: MathGG;
font-size: 20px;
}
Html:
<input id="textInput" type="text">
I tried using
text-align: middle;
but that didn’t work.
3
Answers
It should be
text-align: center
See MDN
Without seeing it with the actual font you are using we can’t provide an exact solution, but you should be able to do this with padding. For example, if the text is too high in the input simply add some top padding.
Adjusting the
line-height
might help as well.The text in the input field is vertically centered by default. You have to consider all letters/characters, not only the ones that don’t descend below the baseline. See the example below: