Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How will I align the label of a text area to top?

I do have a table data as shown below:

<td>     <label for="title">Title : </label>     <textarea rows="5" id="title" name="title"></textarea> </td> 

the default location for the label is at the bottom. How will I place the label aligned with the top of the text area?

like image 226
Arjel Avatar asked Jun 13 '12 07:06

Arjel


People also ask

How do I align text to the top in HTML?

To place an item at the top or bottom of its cell, insert the "VALIGN=" attribute within the code for that cell. To vertically align an entire row (e.g., placing all data in that row at the tops of the cells), insert the "VALIGN=" attribute within the code for that row.

How do I align text in a label?

We specify the margin-bottom of our <div> element. Then, we set the display of the <label> element to "inline-block" and give a fixed width. After that, set the text-align property to "right", and the labels will be aligned with the inputs on the right side.


2 Answers

With the following CSS:

​textarea { vertical-align: top; }​ 

  • jsFiddle Demo
  • vertical-align on MDN:

    The vertical-align CSS property specifies the vertical alignment of an inline or table-cell element.

  • What is Vertical Align? on CSS-Tricks
like image 117
kapa Avatar answered Sep 20 '22 11:09

kapa


@Bazmegakapa Great answer! We can also do it this way

label{display:block; float:left;}​ 

fiddle demo: http://jsfiddle.net/kaMqg/1/

like image 22
SVS Avatar answered Sep 22 '22 11:09

SVS