enter image description here
As in, in this image, the labels are slightly above to the input text fields. I want them to justify.
<meta name="viewport" content="width=device-width,initial-scale=1.0">
<title>REGISTRATION FORM</title>
<link rel="icon" type="image/x-icon" href="C:UsersquadiOneDriveDocumentsDesktopiwpclass3rdsemassignmentm-favicon3.png">
input {
border: 1px solid black;
border-top: 3px solid grey;
border-left: 3px solid grey;
margin: 5px 4px;
float:left;
}
label {
width: 200px;
float: left;
text-align: right;
}
<b>Registration Form</b>
<label for="uname">Username</label>
<input type="text" id="uname" name="uname"><br>
<label for="pwd">Password</label>
<input type="password" id="pwd" name="pwd"><br>
<label for="cpwd">Confirm Password</label>
<input type="password" id="cpwd" name="cpwd">
3
Answers
remove the
float: left;
style from both elements as it’s not necessary when usinginline-block
. always Enclosing eachlabel
andinput
pair in adiv
helps to ensure that each pair is treated as a block and its a good practiceJust wrap every label & input in a separate span tag or div tag and then in css give this span tag
display:flex
andalign-items:center;
to vertically center themYou should use inline-block property for label, like this: