I’m learning HTML and CSS.
I’m making a form to imitate below the example.
//Example
But I don’t know how to align to label and input the same position.
Does somebody help me ??
// This is my HTML code and screen
My Screen
<form action="#" method="#">
<div class="form-group">
<label for="fname">First Name: </label>
<input type="text" name="firstName" id="fname">
<label for="mi">MI: </label>
<input type="number" name="mi" id="mi" min="0" max="50">
<label for="lname">Last Name: </label>
<input type="text" name="lastName" id="lname">
<br>
<label for="city">City: </label>
<input type="text" name="city" id="city">
<label for="state">State: </label>
<input type="text" name="state" id="state">
<label for="zcode">Zip Code: </label>
<input type="text" name="zipcode" id="zcode">
</div>
</form>
I guess I will be able to solve this problem using CSS.
2
Answers
I guess the below code is what you want to display. This code is not the best solution, but it’s the simplest one I can think of.
The mistake you are making here is that you haven’t wrapped the label and the input field within a single div or parent tag. Your code should be like this: