Register  |  Login




Advertisement

Start Your Own Q&A Site

Create your own Q&A site easily, allowing you to quickly grow a new community around any subject matter or generate new organic traffic for your existing website.

Question

Status: Closed Points: 75 Time: 06:32 - Nov 21, 2006  

mary2

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?

Answer Discussion
Tutorials

 

jgivoni

Date:: Nov 21, 2006

Time:: 12:06

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 :-)

mary2

Date:: Nov 21, 2006

Time:: 13:32

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.

jgivoni

Date:: Feb 11, 2007

Time:: 12:41

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.

bundimun211

Date:: Aug 23, 2007

Time:: 01:39

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

Question Answered

This question has been closed, 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 a Tutorial in the Tutorial Area.

Answer 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:

Forgot Your Password?

jgivoni

Date:: Feb 11, 2007

Time:: 12:43

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 tutorial.


Login to rate this tutorial: Good  |  Bad

Answer 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:

Forgot Your Password?

Ask a Question

Have a new question? Ask!

You have 100 characters to use



Top Experts

View More

Rank

Expert

Points

1.

nidhi

10354

2.

oracleofDelphi

6493

3.

rcastagna

5596

4.

LAGM

4848

5.

PeterNZ

3487

6.

gonzalo

2840

7.

Mason

2770

8.

jgivoni

2303

9.

xarcus

1820

10.

Anpanman

917

Become an Expert

Register today to share your knowledge with the community and be recognized and rewarded for your contributions.


Register Here




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



Language Options

English:

www.quomon.com

Español:

www.quomon.es