I have a Textarea inside a TD tag and I want to set the textarea width to 100% so the width is the same as the TD width.
I've used:
textarea{width:100%}
But it didn't work.
Anyone have any ideas why it's not working please?
Thanks
Inside that <div> element, we create a text area with a certain number of columns and rows. In this case, it is 30 and 15 respectively. After that, we set the width property to 100% to make a textarea width 100%. HTML Code: The HTML code contains a <textarea> element that holds rows and columns values.
In CSS, you need to use the width and height properties for the <textarea> element.
It seems like this should be one of the easiest things to understand in CSS. If you want a block-level element to fill any remaining space inside of its parent, then it's simple — just add width: 100% in your CSS declaration for that element, and your problem is solved.
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.
The problem is, as far as I can think of: that your textarea wants to get its width (100%) from the td
it is in. But a td
has a dynamic width by default, so unless you don't specify the width of your td
, you won't get your textarea to be 100% of your cell.
A cell has no width by itself, even though you would think it will autoscale with your table. Well, it doesn't, because this auto scaling is determined by the content inside it. So content of 100% is not interpreted correct, because the 100% depends on the width of the td
which is dynamic by itself.
And I can continue looping with this answer like this...
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