I’m currently building a form for a project but the form elements are all in a new line each (to clarify: the label is in one line and the input of it is in the next line, instead of next to it).
Here’s the image of the problem:
I have the following HTML code:
**<!-- Name -->**
<div class="rowTab">
<div class="labels">
<label id="label-name">
* Name
</label>
</div>
<div class="rightTab">
<input type="text" required placeholder="Enter your name" id="name" class="input-
field" name="Name" autofocus>
</div>
</div>
**<!-- Age -->**
<div class="rowTab">
<div class="labels">
<label id="label-age">* Age: </label>
</div>
<div class="rightTab">
<input type="number" type="number" required name="Age"
placeholder="Age" id="number" min="1" max="125"class="input-field">
</div>
</div>
**<!-- Email -->**
<div class="rowTab">
<div class="labels">
<label id="label-email">* Email: </label>
</div>
<div class="rightTab">
<input type="email"
pattern="[a-z0-9._%+-]+@[a-z0-9.-]+\.[a-z]{2,63}$"
required placeholder="Enter your email" name="name" id="email" class="input-
field">
</div>
</div>
</form>
</div>
And the corresponding CSS is:
body {
background-color: #a9d7d1;
color: black;
font-family: 'Montserrat', sans-serif;
font-weight: normal;
display: block;
margin: 8px;
text-align: center;
}
.outer-form {
background-color: #FFFFFF;
padding: 20px;
margin: 0 auto;
box-shadow: 2px 2px 15px #78ADA6;
max-width: 900px;
border-radius: 4px;
}
.input-field {
font-family: 'Montserrat', sans-serif;
padding: 4px;
margin: 0px 20px 0px 20px;
line-height: 15px;
}
labels {
display: inline-block;
width: 240px;
}
.rightTab {
display: inline-block;
width: 240px;
}
.rowTab {
text-align: center;
display: block;
width: 40px;
}
form {
display: inline-block;
margin-top: 0em;
width: 25%;
}
What am I doing wrong??