I\'m trying to align the label for this text area in the middle of the text box, but it just isn\'t working. The output looks something like this:
xxxx
This will always work and you have the flexibility of placing the label at either; top, middle or bottom
HTML:
<div id="mydiv">
<label for="mytextarea">My Label</label>
<textarea name="mytextarea"></textarea>
</div>
CSS:
#mydiv{
display: table-cell;
}
label, textarea{
display: inline-block;
vertical-align: middle; /** Can be switched to 'top' if you so wish **/
}
This worked for me. First the textarea is floated right, then the word "address" appears before it. It's in reverse order, but displays correctly
<p>
<span style="float:right;"><textarea rows="3" cols="32" name="Add"></textarea></span>
<span style="float:right;">Address</span>
</p>
To show:
Address┌──────────────┐
you forgot : ","
<style>
label, textarea{
vertical-align: middle;
}
</style>
<label>Synopsis: </label> <textarea style="border: 1" rows="3" cols="10"></textarea>
you can do it like this:
label { display:inline-block; vertical-align:central; }
textarea { display:inline-block; vertical-align:middle; }
CODEPEN DEMO
HTML
<div>
<label for="textarea">Textarea:</label>
<textarea cols="40" rows="8" name="textarea" id="textarea"></textarea>
</div>
CSS
label,
textarea{
display:inline-block;
vertical-align:middle;
}