Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Wrap the textarea around a HTML element

Tags:

html

css

textarea

Is there any way I can wrap a textarea HTML element around a HTML element? In my case I want to wrap the textarea around the label.

This is what I try to achieve:

Label name: *********
*********************
*********************

Where the * is the text area.

like image 858
Canutza Avatar asked Jun 11 '14 08:06

Canutza


1 Answers

You can't use HTML tags inside <textarea> but you can use absolute positioning to place the label at the desired position.

Then, you can use the CSS text-indent property (more info on MDN) to offset the first line of the textarea so the label doesn't overlap it.

div {
  position: relative;
}

label {
  position: absolute;
  top: 0;
  left: 0;
  border: 1px solid #000;
  width: 115px;
  line-height: 1em;
}

textarea {
  text-indent: 120px;
  margin: 0;
  line-height: 1.2em;
}
<div>
  <label>This is the label :</label>
  <textarea cols="30" rows="10"></textarea>
</div>
like image 83
web-tiki Avatar answered Oct 14 '22 05:10

web-tiki