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?
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.
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.
With the following CSS:
textarea { vertical-align: top; }
vertical-align
on MDN: The vertical-align CSS property specifies the vertical alignment of an inline or table-cell element.
@Bazmegakapa Great answer! We can also do it this way
label{display:block; float:left;}
fiddle demo: http://jsfiddle.net/kaMqg/1/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With