The solution provided by another responder addresses the issue at hand, however, it lacks an explanation. When using % to specify width/height in CSS, you are essentially making it a percentage of the container element's width/height.
For example, if you set your textarea to be 100% of an empty <td>
, it will appear small due to the lack of content within the cell.
While setting it to position:absolute may work when no ancestor elements are positioned, a simpler alternative would be to use units other than %. You could try using width:10em;
and adjust accordingly until achieving the desired result.
Edit:
In response to a comment question: The reason why using % for height works in this scenario is because the empty cell has a defined height but not width. An empty table cell inherits the height of the row, which is determined by the tallest <td>
. If there were additional rows with content in the same column, using % for width would also be feasible.
However, it is generally advised against utilizing % for width and height in tables as changes to the table's content can impact these percentages. Moreover, % does not expand the parent container like px or em do.
Edit once more:
Upon closer examination, I realized there is a form element present. In this case, the percentages specified are relative to the height/width of the form element, not the <td>
. It is possible that padding is affecting the dimensions of the cells while the form itself may have no set dimensions.