Skip to content
View in the app

A better way to browse. Learn more.

Web Designer Forum

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

How to align form box with css

Featured Replies

HI,

I try to align form box with css but not working. I can do with table but want to learn with css.

 

<form id="form1" name="form1" method="post" action="send.php">
 <p>Last  name:                             

   <input name="lastname" type="text" id="lastname" size="30" maxlength="50" />
 </p>


 <p>First  name:                            
   <input name="firstname" type="text" id="firstname" size="30" maxlength="50" />
 </p>
 <p>Email:                                      
   <input name="email" type="text" id="email" size="30" maxlength="50" />
 </p>

 

I use

#lastname, #firstname, #telephone, #email{

 

margin-left: 100px;

}

But still not line up, how can I do?

  • 3 weeks later...

Hi there!

 

P tags are not really what you want to use, here is a link to a simple page explaining fieldsets, legends, and labels with CSS too.

 

http://www.pixy.cz/blogg/clanky/css-fieldsetandlabels.html

 

so something like;

...

 

<form id="form1" name="form1" method="post" action="send.php">

<fieldset>

<legend>Send Message</legend>

<label for="lastname">Last name:</label>                             

<input name="lastname" type="text" id="lastname" size="30" maxlength="50" />

 

<label for="firstname">First name:</label>                            

<input name="firstname" type="text" id="firstname" size="30" maxlength="50" />

 

<label for="email">Email:</label>                                     

<input name="email" type="text" id="email" size="30" maxlength="50" />

</fieldset>

</form>

...

 

good luck!

MikeyB

 

HI,

I try to align form box with css but not working. I can do with table but want to learn with css.

 

<form id="form1" name="form1" method="post" action="send.php">
 <p>Last  name:                             

   <input name="lastname" type="text" id="lastname" size="30" maxlength="50" />
 </p>


 <p>First  name:                            
   <input name="firstname" type="text" id="firstname" size="30" maxlength="50" />
 </p>
 <p>Email:                                      
   <input name="email" type="text" id="email" size="30" maxlength="50" />
 </p>

 

I use

#lastname, #firstname, #telephone, #email{

 

margin-left: 100px;

}

But still not line up, how can I do?

Give your input tags a class. eg

 

<input name="lastname" type="text" id="lastname" size="30" maxlength="50" class="inputbox" />

First name:

<input name="firstname" type="text" id="firstname" size="30" maxlength="50" class="inputbox" />

Email:

<input name="email" type="text" id="email" size="30" maxlength="50" class="inputbox" />

 

in your CSS:

.inputbox { margin-left: 100px; }

 

But do, take a look at the link above as you should add Fieldset/s, labels and legends(if needed.).

 

Best of luck.

Create an account or sign in to comment

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.