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?
Status:
Open Nov 21, 2006 - 02:32 AM
html, Textbox, forms, center text, css, web development
5answers
Answers
Nov 21, 2006 - 08:06 AM
Hi John2,
There are two kinds of textboxes in HTML, and
For the first one ( ) 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 it is quite simple with center"
You can change the height of a to make it look like an field :-)
Nov 21, 2006 - 09:32 AM
Hi Jgivoni,
I actually found the answer myself also. I was able to center the textbox like this:
It worked like a charm. Thanks for your input.
Feb 11, 2007 - 08:41 AM
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.
Feb 11, 2007 - 08:43 AM
The simple solution:
text-align: center
This css property will center text within textboxes and textareas.
Examples:
Jan 05, 2015 - 12:01 AM
You can do center text withina textbox by writing this code <text align="center"> you can write this code in html body part and if you are looking to do text in a left then write <text align="left">.
Answer this question
Share Your Own Experience & Expertise
We look to ensure that every question is answered by the best people with relevant expertise and experience, the best answers include multiple perspectives. Do you have relevant expertise or experience to contribute your answer to any of these commonly asked questions?
Add New Comment