The primary reason for the misalignment is due to the white space between the two input fields, particularly the white space between the first input and the br
tag. Removing this white space will resolve the issue:
<div style="text-align:center;">
<input type="text"><br>
<input type="text>
</div>
Here is another example to illustrate the whitespace problem more clearly:
<div style="text-align:center;">
<input type="text>
<br>
<input type="text>
<br>
</div>
In this case, an extra br
tag is added at the end, creating white space after both the first and second input fields, unlike before where the white space was only after the first input.
Adding borders will highlight these white spaces:
<div style="text-align:center;display:inline-block;border:1px solid;">
<input type="text>
<br>
<input type="text>
<br>
</div>
<div style="text-align:center;display:inline-block;border:1px solid;">
<input type="text>
<br>
<input type="text>
</div>