I’m new to CSS and have a simple login form that I’m trying to align correctly. Basically two columns with the labels and the Login button in one column and the text boxes in another column. How do I do this in CSS?
The HTML code is:
<body>
<form action="" method="post">
<label> Username </label>
<input type="text"/>
<label> Password </label>
<input type="password"/>
<input type="submit" value="submit"/>
</form>
</body>
This is one approach that works:
JS Fiddle demo.
Adjust dimensions and margins to suit your use-case and aesthetic of course.
Of course, currently, there are other means by which this can work, such as CSS Grid:
JS Fiddle demo.
References:
+) combinator.box-sizing.display.float.gap.grid-area.grid-template-areas.grid-template-columns.grid-template-rows.margin.width.Bibliography: