If you want to display inputs row by row, follow this structure:
Enclose each label and its corresponding input within a div. Place two of these div wrappers inside another div with the class "row".
<div class="row">
<div>
<label for="firstName"> First Name </label>
<input type="firstName" id="firstName" name="first Name" />
</div>
<div>
<label for="lastName"> Last Name </label>
<input type="lastName" id="lastName" name="last Name">
</div>
</div>
To learn more about flexbox and how to use it, visit this link.
Add the following CSS for the "row" class:
.row {
display: flex;
/* ensures children elements are in one row */
flex-wrap: wrap;
/* allows children to move to the next line if space is insufficient */
gap: 10px;
/* creates spacing between children */
padding-top: 10px;
/* adds space above the row */
}
h2 {
margin-bottom: 0px
}
label {
display: block;
}
<div class="form">
<h2>Let's do this!</h2>
<form action="#" method="get">
<div class="row">
<div>
<label for="firstName"> First Name </label>
<input type="text" id="firstName" name="first Name" />
</div>
<div>
<label for="lastName"> Last Name </label>
<input type="text" id="lastName" name="last Name">
</div>
</div>
<div class="row">
<div>
<label for="email"> Email </label>
<input type="email" id="email" name="Email">
</div>
<div>
<label for="phoneNumber"> Phone Number </label>
<input type="tel" id="phoneNumber" name="phone Number">>;
</div>
</div>
<div class="row">
<div>
<label for="password"> Password </label>
<input type="password" id="password" name="Password">>;
</div>
<div>
<label for="confirmPassword"> Confirm Password </label>
<input type="password" id="confirmPassword" name="Confirm Password">>;
</div>
</div>
</form>