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.

Text allignment issue

Featured Replies

Hi,

 

I'm mainly a coder, PHP at the moment, but from time to time need to design and use some css.

 

I've a css text alignment issue. Mostly to align text neatly in the past I've used tables. But now I know I should be getting into the 21st C and using css properly.

 

Here are 2 mock up page with some forms on it, obviously I want the text boxes aligned neatly. The first page shows a nice alignment, the second does not, take a look.

 

http://tinyurl.com/2ef9o5

http://tinyurl.com/27rf4e

 

My form alignment uses 2 css entries:

 

ItemLeft
{
position: relative;
left: 10px;
}

ItemRight
{
position: relative;
left: 75px;
}

To achieve the first page -the one neatly aligned- I use a fixed-width font (Courier New), and then added multiple entries so that the number of chars on the left are the same, so that the alignment of the text boxes are neat.

 

EG.

 

<FormItemLeft>
Subject:
</FormItemLeft>

<FormItemRight>
<input name="subject" type="text" /> <br />
</FormItemRight>

<FormItemLeft>
CC:     
</FormItemLeft>

<FormItemRight>
<input name="cc" type="text" /> <br />
</FormItemRight>

Here you can see for the <FormItemLeft> entries 'Subject:' is 8 chars and 'CC:' is 3, so I've added 5 'forced space' (can't use the symbols here cos just get spaces!) entries after the 'CC:'.

 

Obviously this is a work-around which is rather amateurish and it does not work with non-fixed-width fonts. My instinct was to use a table, but this is exactly what css is supposed to stop.

 

How do I get my alignment to work with non-fixed-width fonts, no forced spaces, and no tables? I just can't seem to find the right way to do this.

 

Thanks all.

I find forms a complete nightmare and was about to link you to the same article as I'm sure that's one that Thomas posted for me a while back...it's a good article...still doesn't make me enjoy creating forms though!

I find forms a complete nightmare and was about to link you to the same article as I'm sure that's one that Thomas posted for me a while back...it's a good article...still doesn't make me enjoy creating forms though!

Aye! And the more different controls the worse. ...do I need to mention the dreaded file input field? *shivers*

 

Forms is one of them mucky areas of webdesign where we got inconsistent partial control over the elements. I found in most cases that the less I do the better it generally works.

Like making a card house. Stack it up neatly, then slowly back away from the table!

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.