Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Left align form labels, inputs also left aligned

Tags:

css

So I'm trying to create a pretty form with labels. The aim is for all the labels to be inline with the inputs, while being left aligned. Because I also want to inputs to be left aligned, the space between each label and input is different.

What I'm working with

Any help would be appreciated. Thanks as always, much obliged.

like image 531
Kevin Lewis Avatar asked Feb 12 '26 01:02

Kevin Lewis


1 Answers

Set the width of your labels to be the same and all your inputs will be aligned

label {
    display: inline-block; //So that we can set the width
    width: 40px; //Whatever the widest label will be.
}

This can cause some issues if you add longer labels, you may need to adjust the width so that it doesn't overflow.

like image 128
Schleis Avatar answered Feb 16 '26 21:02

Schleis



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!