7

Is anyone have solution for textarea height problem in Chrome?

In simple case like this:

<div> <textarea> </textarea> </div> 

Google Chrome add two pixels, so div.height = textarea.height + 2px. And yes, I try Eric's "reset.ccs" — didn't work.

P.S. of course in my "simple case" textarea and div have border, padding and margin 0px.

3 Answers 3

17

It's because textarea is a replaced inline element.

textarea { display:block; } 

should solve your "problem".

Sign up to request clarification or add additional context in comments.

3 Comments

This finally ensures the same textarea height across Chrome and Firefox
I think the additional margin underneath the textarea is due to leaving space for text descenders. For example, you can also set line-height/font-size on the parent to increase/decrease it, or vertical-align on the textarea.
@Ben J yep, vertical-align top or bottom would solve it.
0

The 2px is the standard border size. It's the same across all browsers though.

This works in Chrome, Firefox..

No borders : http://jsfiddle.net/NctDT/2/

Borders and ajusted div height : http://jsfiddle.net/NctDT/4/

In both cases the div and textarea are both perfectly aligned in height.

3 Comments

thanks, actually, it was my fault and MatTheCat's answer help me
You misunderstood the problem slightly. Here's your first demo with a height on only textarea, check it in Chrome: jsfiddle.net/NctDT/5
Well, then you add textarea {display:block;} .) +1 for MatTheCat
-1

Sorry, But adding
html,body{ height:100%; }
really seems to work

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.