user1275375 user1275375 - 7 months ago 33
HTML Question

Adjust the textArea height and width to fit in <td> of a table

I am displaying the html content in a table. For printing the tags i am using

in the
of the table. So i want to adjust the height and width of
so that it is equal to the
. How can i do this


enter image description here

the problem is that textarea behave not normal box-model, that's why we need this trick with box-sizing

this CSS will help you:

textarea {
    border: none;
    width: 100%;
    -webkit-box-sizing: border-box; /* <=iOS4, <= Android  2.3 */
       -moz-box-sizing: border-box; /* FF1+ */
            box-sizing: border-box; /* Chrome, IE8, Opera, Safari 5.1*/

if you have no access to css file, you can use inline css

like this:

<textarea style="border: none; width: 100%; -webkit-box-sizing: border-box; -moz-box-sizing: border-box; box-sizing: border-box;"> </textarea>