Register  |  Login

Question Details    

   Question

Time: 06:32 - Nov 21, 2006     Asked by: john2      Status: Answered      Points: 75   

How do I center text within a textbox for an HTML form?

I am looking to have the text within a textbox centered, does anyone know how to accomplish this?

Ask a New Question

Become a Quomon Expert

Current Categories

 

Similar Questions


   

Answer Discussion
Answer Discussion
Answer Summaries
Answer Summary
 
Hi John2,

There are two kinds of textboxes in HTML, <input type="text"> and <textarea>

For the first one (<input type="text">) I don't think it is possible to change the alignment (not even CSS's direction: rtl seems to have any effect...)
but for the <textarea> it is quite simple with style="text-align: center"

You can change the height of a <textarea> to make it look like an <input type="text"> field :-)

Expert:

jgivoni

Date:

Nov 21, 2006

Time:

12:06

 

Votes: Good (0) | Bad (0)
Login to rate this answer

Hi Jgivoni,

I actually found the answer myself also. I was able to center the textbox like this:

<input type="text" style="text-align:center">

It worked like a charm. Thanks for your input.

Expert:

john2

Date:

Nov 21, 2006

Time:

13:32

 

Votes: Good (0) | Bad (0)
Login to rate this answer

I realized that my first answer relied on a typing error, therefore I couldn't get it to work!
John is right, "text-align: center" is all that is needed. Sorry for my mistake.

Expert:

jgivoni

Date:

Feb 11, 2007

Time:

12:41

 

Votes: Good (0) | Bad (0)
Login to rate this answer

thanks for d answer...it really helps :)

Expert:

bundimun211

Date:

Aug 23, 2007

Time:

01:39

 

Votes: Good (0) | Bad (0)
Login to rate this answer

Question Answered

This question has been answered, and points have been rewarded to the following experts:

jgivoni: 75

You're welcome however to comment or give additional information or if you wish, you have the ability to write an Answer Summary for this question by clicking on the "Answer Summaries" Tab.


The simple solution:
text-align: center

This css property will center text within textboxes and textareas.
Examples:
<input type="text" style="text-align: center"/>
<textarea style="text-align: center"></textarea>

Click here to see the Answer Discussion that preceded this summary.

Expert:

jgivoni

Date:

Feb 11, 2007

Time:

12:43

 
 

Login to rate this summary: Good  |  Bad

Respond to this question:

New User

  Email:

Upon submission of this form, you will automatically be registered as a Quomon user and we will send your login information to this address

Registered User

Username:

Password:


Forgotten Password

 

New User

  Email:

Upon submission of this form, you will automatically be registered as a Quomon user and we will send your login information to this address

Registered User

Username:

Password:


Forgotten Password

   

"Psst, Quomon is a great site. Pass it on."     Tell a Friend  |   Link To Us  |   Save to Delicious  |   Digg! Digg it


All Questions


Language Options

English:

www.quomon.com

Español:

www.quomon.es

Sponsors

Questions and Answers Software
Real Estate Postcards
Marketing Fulfillment