Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Alignment of Labels and input fields

Posted on 2013-11-20
4
Medium Priority
?
309 Views
Last Modified: 2013-11-20
What's the best way to align text and a input field.  With the below code everything works correctly, but the alignment of the text and the actual input fields are all over the place.

You can see the example here:
http://jsfiddle.net/gallitin/nsPdB/

How can I make them all align evenly the best way?

          <form method="get" action="#">
          Interest Rate <input type="text" name="interestrate" value="'.$interestrate.'" style="width:50px;"/>%<br>
          Term <input type="text" name="term" value="'.$term.'" style="width:50px;"/>Months<br>
          Down Payment <input type="text" name="downpayment" value="'.$downpayment.'" style="width:50px;"/><br>
          Monthly Payment
          <input type="image" src="assets/img/recalculate.png" style="margin-top:5px;"/>
          <a href="#"><img src="assets/img/continue.png" style="margin-top:5px;"/></a>
          </form>

Open in new window

0
Comment
Question by:Nathan Riley
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 58

Accepted Solution

by:
Gary earned 1000 total points
ID: 39664273
Put your text in a label styled with display:inline-block and a set width - like so
http://jsfiddle.net/nsPdB/1/
0
 
LVL 44

Assisted Solution

by:Chris Stanyon
Chris Stanyon earned 1000 total points
ID: 39664281
Gary just beat me to it:

http://jsfiddle.net/ChrisStanyon/nsPdB/2/

Also, give your labels a 'for' attribute to match the ID of your inputs - then you can select the input by clicking the label
0
 
LVL 58

Expert Comment

by:Gary
ID: 39664301
I never bother with a for for input labels, not intuitive (at least for me) like it is for radio/checkboxes.
0
 
LVL 44

Expert Comment

by:Chris Stanyon
ID: 39664329
@Gary - Accessibility! Screen readers etc. benefit from having labels explicitly tied to their inputs..
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

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

Many old projects have bad code, but the budget doesn't exist to rewrite the codebase. You can update this code to be safer by introducing contemporary input validation, sanitation, and safer database queries.
Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.
Suggested Courses

636 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