How To Adjust Textarea Label Position Without Table

| One Comment

If a label is placed next to a textarea the text will be place at the bottom line. Often this don’t look good. In this tutorial I will show how you can have the label placed anywhere along side the textarea as shown below.

positioning-label-text-alongside-textarea-form-element

The reason why I am writing this post is because when I searched for this solution I came across expert-exchange solution. But I couldn’t see the solution because I had to pay to see it. So I decided to find a solution myself. The solution is very simple, it’s simply using the positioning technique in CSS.

The code that I used for my comment section is as follows.

and the CSS styling is as follows. The ‘top’ position can be altered to adjust the label position.

.comment-form-comment {
   position:relative;
}

label[for="comment"] {
   position:absolute;
   top:5px;
}

Read CSS positioning techniques for more details.

One Response to How To Adjust Textarea Label Position Without Table

  1. Pingback: » CSS Positioning: Tips and Tricks With Relative and Absolute Positioning @Blokeish.com

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

 
Designed and developed by Alfie Punnoose @ Blokeish.com