m.Elouafi
m.Elouafi

Reputation: 159

html / css how to Middle (vertically) align text inside a <textarea>

I want to centre the text inside a text area; I am trying with the line height, but it doesn't work.

screenshot

Upvotes: 10

Views: 5860

Answers (3)

Boris Delormas
Boris Delormas

Reputation: 2549

You could use the contenteditable="true" attribute on a <div> and then skin it with CSS.

Here is a link for cross browser compatibility: Reliable cross-browser info on ContentEditable

Upvotes: 3

Rohit Azad Malik
Rohit Azad Malik

Reputation: 32202

Hey now you can used input tag

Replace textarea into input tag as like this

and define height and line-height

Css

input[type="text"]{
line-height:125px;
    height:125px;
}

HTML

<input type="text" value="">

Live demo http://jsfiddle.net/MTCrt/

Upvotes: 1

Malyo
Malyo

Reputation: 2000

You can use padding only to achieve that, but it's not pretty way to do things. You can also use jQuery to make the padding flexible, instead of just setting it by yourself.

Upvotes: 2

Related Questions