<...">

How to get the alignment of a form like a table using a div?

Here is my code:

<div>
    <label>Name</label><input type="text" id='name'/><br />
    <label>Email</label><input type="text" id='email'/><br />
    <label>Place</label><input type="text" id='place'/><br />
</div>

I'm new to CSS, I don't want the table aligned, but the perfection should be the same, and there is no need to apply style to individual elements. Any help is appreciated.

+5
source share
1 answer

I assume that you want to align the labels and inputs next to each other, in which case you will need floats. Here's the quick css code:

form {
 width: 500px;
 overflow:hidden;}

label {
 clear: both;
 float: left;
 width: 40%;}

input {
 float: left;
 width: 55%;}

I think this should work :)

+7
source

All Articles