views:

42

answers:

1

I'm trying to get a label lined up with the baseline of the first line of text in a text area.

The naive attempt:

<div style="vertical-align: baseline; display: inline-block">
   <label for="comments">Comments:</label>
</div>
<div style="vertical-align: baseline; display: inline-block">
   <textarea name="comments" id="comments"></textarea>
</div>

results in the label being aligned with the bottom of the text area. I'd prefer to have it lined up with the first line of the area.

Thanks.

+1  A: 

You need to put the label div inside of the same div as the textarea, then, if you want it set to the top of the textarea you're looking for vertical-align: top, not baseline.

View and example here:
http://jsfiddle.net/anhus/

Robert
The problem is that i want the text lined up on the baseline of the text in the textarea. Aligning it to the top just for text areas looks wrong when you compare it to the rest of the label+text fields that are aligned with the baseline.
jmo
Okay, well just change `vertical-align:top` to what you want it to be. baseline, or whatever.
Robert