duncanportelli
duncanportelli

Reputation: 3229

Center elements within div

Is it good convention to center elements using text-align: center? Why can't I centre a textbox using the same text-align: center?

jsFiddles: Div with buttons & Textarea

Upvotes: 0

Views: 437

Answers (3)

Vinod Vishwanath
Vinod Vishwanath

Reputation: 5911

To center align a text-area, you have to style it as display:block;, since textareas are inline elements.

http://jsfiddle.net/M9Mnz/18/

Upvotes: 1

Vinod Vishwanath
Vinod Vishwanath

Reputation: 5911

Add this to the style:

text-align:center;

http://jsfiddle.net/M9Mnz/10/

Upvotes: 1

Zoltan Toth
Zoltan Toth

Reputation: 47687

Sure it is a good convention - that why text-align: center was made for

DEMO

Upvotes: 1

Related Questions