Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get align a form like table using 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 table to get aligned, but the perfection should be like same, and don't want to apply style to individual elements. Any help is appreciated.

like image 785
illuminatus Avatar asked Dec 17 '10 11:12

illuminatus


1 Answers

I'm assuming you want to align the labels and inputs next to one another, in which case you'll be needing 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 that should work :)

like image 79
Tiny Giant Studios Avatar answered Nov 28 '22 06:11

Tiny Giant Studios