I hope you can help me, I'm junior in html/css
I have a textarea with known height in percentage value inside a div of unknown height, when I'm trying to write inside this textarea, it's height get changed.
my question is, how to fix textarea height when trying to write inside it by percentage value
I know that I need to fix div height first by specify its height using px or % in order to make textarea height fix.
I tried these attributes but no luck
resize: none;
display:block;
Please note that the div height is changeable and it works as container for multiple textarea so that I can't add a specific height for it,
BTW, this issue is happening on all browsers
Please help
A simple way to ensure that the control is not resizable is to add an explicit style="resize: none;" attribute on the textarea element using the HTML Form Element Attributes property.
In some cases, there is a need of putting a limit on the size of characters that can be typed in a textarea. So in that case, we can use maxlength attribute to control the number of characters entered in a textarea.
You can resize a textarea by clicking on the bottom right corner of the textarea and dragging the mouse.
It can be achieved by using JavaScript and jQuery. Method 1: Using JavaScript: To change the height, a new function is created which changes the style property of the textarea. The height of the textarea is first set to auto. This value makes the browser set the height of an element automatically.
CSS rule resize: none;
does this job.
You can also set your textarea height in rows count with rows
attribute.
textarea {
resize: none;
}
textarea.ta10em {
height: 10em;
}
<div>
<textarea rows=3>Some text
Second line
Third line</textarea>
</div>
<div>
<textarea class="ta10em">Some text
Second line</textarea>
</div>
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