Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Web Programming > HTML > HTML Code Clinic
|
HTML Code Clinic Do you have some HTML code you'd like to share and get suggestions from others for tweaking or improving it? This discussion is the place.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the HTML Code Clinic section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old June 4th, 2007, 01:45 AM
Authorized User
 
Join Date: Feb 2007
Posts: 14
Thanks: 0
Thanked 0 Times in 0 Posts
Default Align to right not working

I designed below this form.
<form id="frmlgn" action="">
  <label for="username">Username:</label>
  <input id="username" name="" type="text" class="textBox" size="15" />
  &nbsp;&nbsp;
  <label for="pwd">Password:</label>
  <input id="pwd" name="" type="password" class="textBox" size="15" />
  &nbsp;&nbsp;
  <input name="" type="button" value="Login" class="buttonStyle" />
  <br />
  <a href="#" class="alignright">Forgot Password?</a>
</form>

This form is controlled through a CSS class file. Here is the class details:
#frmlgn{
float:right;
margin-bottom:20px;
}

The problem in browser is, the Forgot Password link aligns to left. I used a class to align it to right, that is not working. Can anybody help to fix it?

Shivanand Yerva
__________________
Shivanand
 
Old June 4th, 2007, 08:51 AM
Registered User
 
Join Date: Jun 2007
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Although I would do a bit different from that, to avoid messing up with your code, here's my suggestion:

Instead of using "<br />" to break the line, put the link inside of a div and align the contents of this div on the right.

In other words, use the same code above and just delete the <br> tag and replace the next line for: <div class="alignright"><a href="#">Forgot Password?</a></div>

Of course, you'd have to add the class:
.alignright {
text-align:right;
}

This will do the job.

 
Old June 5th, 2007, 12:48 AM
Authorized User
 
Join Date: Feb 2007
Posts: 14
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks PauloAmado. You mentioned that you will do it differntly, let me know what is that approach.

Shivanand Yerva
 
Old June 5th, 2007, 02:46 AM
Registered User
 
Join Date: Jun 2007
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Nothing wrong with your approach, Shiva. Actually, I find it pretty clean. When I said I would do different, I really meant "I have done differently before", but, of course, that will depend highly on the other elements of the page and the design you chose. Good luck with your work.

 
Old July 19th, 2007, 01:49 PM
Friend of Wrox
 
Join Date: Jun 2007
Posts: 477
Thanks: 10
Thanked 19 Times in 18 Posts
Default

There is one thing I would do differently. alignright is a functional classname, it describes what you are trying to do to the element. I'd use a descriptive class name, one that describes what the element is, like class="forgotPassword". Otherwise, when you change your mind later (or your client changes your mind for you ), all of a sudden your CSS has things like

.alignright {
text-align:left
}

Worse, when you look at your XHTML code it's actually lying to you, because now it's not aligned to the right at all.

-------------------------

Whatever you can do or dream you can, begin it. Boldness has genius, power and magic in it. Begin it now.
-Johann von Goethe

When Two Hearts Race... Both Win.
-Dove Chocolate Wrapper

Chroniclemaster1, Founder of www.EarthChronicle.com
A Growing History of our Planet, by our Planet, for our Planet.





Similar Threads
Thread Thread Starter Forum Replies Last Post
EASY Q: Left-Align and Right-Align DIV? panuvin ASP.NET 1.0 and 1.1 Basics 0 December 16th, 2006 02:02 AM
Textbox align surendran Java GUI 2 August 24th, 2004 07:54 AM
align=right? larry Javascript How-To 11 July 6th, 2004 05:07 PM
Align text acko ASP.NET 1.x and 2.0 Application Design 2 January 9th, 2004 10:21 AM
align Center melvik C# 1 September 7th, 2003 04:50 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.