Solved

Aligning Fields On A Form

Posted on 2014-01-28
3
206 Views
Last Modified: 2014-01-28
I have a contact form that I want to be in the center of the page but the fields to be left aligned.  How can I do this?  Thanks.
<div align="center"><h2>Contact Form</h2></div>
<div align="center">
<form action="contact.php" method="post">
	Your name<br>
    <input type="text" name="cf_name"><br>
    Your e-mail<br>
    <input type="text" name="cf_email"><br>
	Message<br>
    <textarea name="cf_message"></textarea><br>
    <p>&nbsp;</p>
<input type="submit" value="Send">
<input type="reset" value="Clear">
</form>
</div>

Open in new window


The link:
http://www.mediascrubber.com/contactemploy.html
0
Comment
Question by:DS928
  • 2
3 Comments
 
LVL 4

Expert Comment

by:ravikantninave
ID: 39815721
Use Div or simply Table;
<style>
.LeftDiv{width:100px; float:left;}
.RightDiv{width:150px; float:left;}
.Clear {clear:both;}
</style>


<div align="center"><h2>Contact Form</h2></div>
<div style="width:500px; margin:auto;">
<form action="contact.php" method="post">
<div class="LeftDiv">Your name</div>
<div class="RightDiv"><input type="text" name="cf_name"></div><div class="Clear"></div>
<div class="LeftDiv">Your e-mail<br></div>
<div class="RightDiv"><input type="text" name="cf_email"></div><div class="Clear"></div>
<div class="LeftDiv">Message</div>
<div class="RightDiv"><textarea name="cf_message"></textarea></div><div class="Clear"></div>
    <p>&nbsp;</p>
<input type="submit" value="Send">
<input type="reset" value="Clear">
</form>
</div>

Open in new window

0
 
LVL 4

Accepted Solution

by:
ravikantninave earned 500 total points
ID: 39815737
or
<div align="center"><h2>Contact Form</h2></div>
<div style="width:500px; margin:auto;">
<form action="contact.php" method="post">
<table style=" border:none;">
<tr>
<td>Your name</td>
<td><input type="text" name="cf_name"></td>
</tr>
<tr>
<td>Your e-mail<br></td>
<td><input type="text" name="cf_email"></td>
</tr>
<tr>
<td>Message</td>
<td><textarea name="cf_message"></textarea></td>
</tr>
</table>
    <p>&nbsp;</p>
<input type="submit" value="Send">
<input type="reset" value="Clear">
</form>
</div>

Open in new window

0
 

Author Closing Comment

by:DS928
ID: 39815914
Excellent!  Thank you.
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This is a PowerShell web interface I use to manage some task as a network administrator. Clicking an action button on the left frame will display a form in the middle frame to input some data in textboxes, process this data in PowerShell and display…
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
In this tutorial viewers will learn how to style elements, such a divs, with a "drop shadow" effect using the CSS box-shadow property Start with a normal styled element, such as a div.: In the element's style, type the box shadow property: "box-shad…
HTML5 has deprecated a few of the older ways of showing media as well as offering up a new way to create games and animations. Audio, video, and canvas are just a few of the adjustments made between XHTML and HTML5. As we learned in our last micr…

829 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question